diff --git a/src/plugin/localeData/index.js b/src/plugin/localeData/index.js index 65d6e234..579c0ec3 100644 --- a/src/plugin/localeData/index.js +++ b/src/plugin/localeData/index.js @@ -28,8 +28,8 @@ export default (o, c, dayjs) => { // locale needed later (instance ? instance.format('dd') : getShort(this, 'weekdaysMin', 'weekdays', 2)), weekdaysShort: instance => (instance ? instance.format('ddd') : getShort(this, 'weekdaysShort', 'weekdays', 3)), - longDateFormat: format => getLongDateFormat(this.$locale(), format) - + longDateFormat: format => getLongDateFormat(this.$locale(), format), + meridiem: this.$locale().meridiem } } proto.localeData = function () { @@ -45,7 +45,8 @@ export default (o, c, dayjs) => { // locale needed later weekdaysMin: () => dayjs.weekdaysMin(), months: () => dayjs.months(), monthsShort: () => dayjs.monthsShort(), - longDateFormat: format => getLongDateFormat(localeObject, format) + longDateFormat: format => getLongDateFormat(localeObject, format), + meridiem: localeObject.meridiem } } diff --git a/test/plugin/localeData.test.js b/test/plugin/localeData.test.js index 82985640..6aa9637b 100644 --- a/test/plugin/localeData.test.js +++ b/test/plugin/localeData.test.js @@ -103,3 +103,10 @@ it('Locale order', () => { moment.locale('en') expect(dayjs.weekdays(true)).toEqual(moment.weekdays(true)) }) + +it('meridiem', () => { + dayjs.locale('zh-cn') + expect(typeof dayjs.localeData().meridiem).toEqual('function') + expect(typeof dayjs().localeData().meridiem).toEqual('function') + dayjs.locale('en') +}) diff --git a/types/plugin/localeData.d.ts b/types/plugin/localeData.d.ts index 6b0c11c0..bc0aa14b 100644 --- a/types/plugin/localeData.d.ts +++ b/types/plugin/localeData.d.ts @@ -15,6 +15,7 @@ declare module 'dayjs' { months(instance?: Dayjs): MonthNames; monthsShort(instance?: Dayjs): MonthNames; longDateFormat(format: string): string; + meridiem(hour?: number, minute?: number, isLower?: boolean): string; } interface GlobalLocaleDataReturn { @@ -25,6 +26,7 @@ declare module 'dayjs' { months(): MonthNames; monthsShort(): MonthNames; longDateFormat(format: string): string; + meridiem(hour?: number, minute?: number, isLower?: boolean): string; } interface Dayjs {