import moment from 'dayjs'
import duration from 'dayjs/plugin/duration'
import updateLocale from 'dayjs/plugin/updateLocale'
import customParseFormat from 'dayjs/plugin/customParseFormat'
import 'dayjs/locale/zh-cn'

moment.locale('zh-cn')
moment.extend(updateLocale)
moment.extend(customParseFormat)
moment.extend(duration)
moment.updateLocale('zh-cn', {
  weekdays: "星期日|星期一|星期二|星期三|星期四|星期五|星期六".split("|"),
  meridiem(hour) {
    let word = ""
    if (hour < 6) {
      word = "凌晨"
    } else if (hour < 9) {
      word = "早上"
    } else if (hour < 12) {
      word = "上午"
    } else if (hour < 14) {
      word = "中午"
    } else if (hour < 17) {
      word = "下午"
    } else if (hour < 19) {
      word = "傍晚"
    } else if (hour < 22) {
      word = "晚上"
    } else {
      word = "夜里"
    }
    return word;
  }
})
export default moment
