Skip to content

Commit fd229fa

Browse files
Xenonymiamkun
authored andcommitted
fix: add ordinal to localeData plugin (#1266)
1 parent f9d79d5 commit fd229fa

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/plugin/localeData/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export default (o, c, dayjs) => { // locale needed later
2929
weekdaysShort: instance =>
3030
(instance ? instance.format('ddd') : getShort(this, 'weekdaysShort', 'weekdays', 3)),
3131
longDateFormat: format => getLongDateFormat(this.$locale(), format),
32-
meridiem: this.$locale().meridiem
32+
meridiem: this.$locale().meridiem,
33+
ordinal: this.$locale().ordinal
3334
}
3435
}
3536
proto.localeData = function () {
@@ -46,7 +47,8 @@ export default (o, c, dayjs) => { // locale needed later
4647
months: () => dayjs.months(),
4748
monthsShort: () => dayjs.monthsShort(),
4849
longDateFormat: format => getLongDateFormat(localeObject, format),
49-
meridiem: localeObject.meridiem
50+
meridiem: localeObject.meridiem,
51+
ordinal: localeObject.ordinal
5052
}
5153
}
5254

test/plugin/localeData.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,10 @@ it('meridiem', () => {
110110
expect(typeof dayjs().localeData().meridiem).toEqual('function')
111111
dayjs.locale('en')
112112
})
113+
114+
it('ordinal', () => {
115+
dayjs.locale('zh-cn')
116+
expect(typeof dayjs.localeData().ordinal).toEqual('function')
117+
expect(typeof dayjs().localeData().ordinal).toEqual('function')
118+
dayjs.locale('en')
119+
})

0 commit comments

Comments
 (0)