1 line
19 KiB
JSON
1 line
19 KiB
JSON
|
{"ast":null,"code":"import dayjs from 'dayjs';\nimport { noteOnce } from \"rc-util/es/warning\";\nimport weekday from 'dayjs/plugin/weekday';\nimport localeData from 'dayjs/plugin/localeData';\nimport weekOfYear from 'dayjs/plugin/weekOfYear';\nimport weekYear from 'dayjs/plugin/weekYear';\nimport advancedFormat from 'dayjs/plugin/advancedFormat';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\ndayjs.extend(customParseFormat);\ndayjs.extend(advancedFormat);\ndayjs.extend(weekday);\ndayjs.extend(localeData);\ndayjs.extend(weekOfYear);\ndayjs.extend(weekYear);\ndayjs.extend(function (o, c) {\n // todo support Wo (ISO week)\n var proto = c.prototype;\n var oldFormat = proto.format;\n proto.format = function f(formatStr) {\n var str = (formatStr || '').replace('Wo', 'wo');\n return oldFormat.bind(this)(str);\n };\n});\nvar localeMap = {\n // ar_EG:\n // az_AZ:\n // bg_BG:\n bn_BD: 'bn-bd',\n by_BY: 'be',\n // ca_ES:\n // cs_CZ:\n // da_DK:\n // de_DE:\n // el_GR:\n en_GB: 'en-gb',\n en_US: 'en',\n // es_ES:\n // et_EE:\n // fa_IR:\n // fi_FI:\n fr_BE: 'fr',\n // todo: dayjs has no fr_BE locale, use fr at present\n fr_CA: 'fr-ca',\n // fr_FR:\n // ga_IE:\n // gl_ES:\n // he_IL:\n // hi_IN:\n // hr_HR:\n // hu_HU:\n hy_AM: 'hy-am',\n // id_ID:\n // is_IS:\n // it_IT:\n // ja_JP:\n // ka_GE:\n // kk_KZ:\n // km_KH:\n kmr_IQ: 'ku',\n // kn_IN:\n // ko_KR:\n // ku_IQ: // previous ku in antd\n // lt_LT:\n // lv_LV:\n // mk_MK:\n // ml_IN:\n // mn_MN:\n // ms_MY:\n // nb_NO:\n // ne_NP:\n nl_BE: 'nl-be',\n // nl_NL:\n // pl_PL:\n pt_BR: 'pt-br',\n // pt_PT:\n // ro_RO:\n // ru_RU:\n // sk_SK:\n // sl_SI:\n // sr_RS:\n // sv_SE:\n // ta_IN:\n // th_TH:\n // tr_TR:\n // uk_UA:\n // ur_PK:\n // vi_VN:\n zh_CN: 'zh-cn',\n zh_HK: 'zh-hk',\n zh_TW: 'zh-tw'\n};\nvar parseLocale = function parseLocale(locale) {\n var mapLocale = localeMap[locale];\n return mapLocale || locale.split('_')[0];\n};\nvar parseNoMatchNotice = function parseNoMatchNotice() {\n /* istanbul ignore next */\n noteOnce(false, 'Not match any format. Please help to fire a issue about this.');\n};\nvar generateConfig = {\n // get\n getNow: function getNow() {\n return dayjs();\n },\n getFixedDate: function getFixedDate(string) {\n return dayjs(string, ['YYYY-M-DD', 'YYYY-MM-DD']);\n },\n getEndDate: function getEndDate(date) {\n return date.endOf('month');\n },\n getWeekDay: function getWeekDay(date) {\n var clone = date.locale('en');\n return clone.weekday() + clone.localeData().firstDayOfWeek();\n },\n getYear: function getYear(date) {\n return date.year();\n },\n getMonth: function getMonth(date) {\n return date.month();\n },\n getDate: function getDate(date) {\n return date.date();\n },\n getHour: function getHour(date) {\n return date.hour();\n },\n getMinute: function getMinute(date) {\n return date.minute();\n },\n getSecond: function getSecond(date) {\n return date.second();\n },\n getMillisecond: function getMillisecond(date) {\n return date.millisecond();\n },\n // set\n addYear: function addYear(date, diff) {\n return date.add(diff, 'year');\n },\n addMonth: function addMonth(date, diff) {\n return date.add(diff, 'month');\n },\n addDate: function addDate(date, diff) {\n return date.add(diff, 'day');\n },\n setYear: function setYear(date, year) {\n return date.year(year);\n },\n setMonth: function setMonth(date, month) {\n return date.month(month);\n },\n setDate: function setDate(date, num) {\n return date.date(num);\n },\n setHour: function setHour(date, hour) {\n return date.hour(hour);\n },\n setMinute: function setMinute(date, minute) {\n return date.minute(minute);\n },\n setSecond: function setSecond(date, second) {\n return date.second(second);\n },\n setMillisecond: function setMillisecond(date, milliseconds) {\n return date.millisecond(milliseconds);\n },\n // Compare\n isAfter: function isAfter(date1, date2) {\n return date1.isAfter(date2
|