Skip to content

Commit

Permalink
fix: add ordinal to localeData plugin (#1266)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenonym authored and iamkun committed Jan 3, 2021
1 parent f9d79d5 commit fd229fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/plugin/localeData/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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
}
}

Expand Down
7 changes: 7 additions & 0 deletions test/plugin/localeData.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})

0 comments on commit fd229fa

Please sign in to comment.