From fd229fa5bd26bcba810e2535eb937ea8d99106c2 Mon Sep 17 00:00:00 2001 From: Tan Zhen Yong Date: Sun, 3 Jan 2021 15:45:40 +0800 Subject: [PATCH] fix: add ordinal to localeData plugin (#1266) --- src/plugin/localeData/index.js | 6 ++++-- test/plugin/localeData.test.js | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/plugin/localeData/index.js b/src/plugin/localeData/index.js index 579c0ec36..034dbea13 100644 --- a/src/plugin/localeData/index.js +++ b/src/plugin/localeData/index.js @@ -29,7 +29,8 @@ export default (o, c, dayjs) => { // locale needed later weekdaysShort: instance => (instance ? instance.format('ddd') : getShort(this, 'weekdaysShort', 'weekdays', 3)), longDateFormat: format => getLongDateFormat(this.$locale(), format), - meridiem: this.$locale().meridiem + meridiem: this.$locale().meridiem, + ordinal: this.$locale().ordinal } } proto.localeData = function () { @@ -46,7 +47,8 @@ export default (o, c, dayjs) => { // locale needed later months: () => dayjs.months(), monthsShort: () => dayjs.monthsShort(), longDateFormat: format => getLongDateFormat(localeObject, format), - meridiem: localeObject.meridiem + meridiem: localeObject.meridiem, + ordinal: localeObject.ordinal } } diff --git a/test/plugin/localeData.test.js b/test/plugin/localeData.test.js index 6aa9637b6..51171268a 100644 --- a/test/plugin/localeData.test.js +++ b/test/plugin/localeData.test.js @@ -110,3 +110,10 @@ it('meridiem', () => { expect(typeof dayjs().localeData().meridiem).toEqual('function') dayjs.locale('en') }) + +it('ordinal', () => { + dayjs.locale('zh-cn') + expect(typeof dayjs.localeData().ordinal).toEqual('function') + expect(typeof dayjs().localeData().ordinal).toEqual('function') + dayjs.locale('en') +})