Skip to content

Commit

Permalink
refactor: move declaration for english 'ordinal' to 'en' locale file (#…
Browse files Browse the repository at this point in the history
…2071)

* refactor: move declaration for english 'ordinal' to 'en' locale file

* fix: lint issue in this pr
  • Loading branch information
BePo65 authored Oct 9, 2022
1 parent c9370ea commit 7ae1a1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
export default {
name: 'en',
weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_')
months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
ordinal: (n) => {
const s = ['th', 'st', 'nd', 'rd']
const v = n % 100
return `[${n}${(s[(v - 20) % 10] || s[v] || s[0])}]`
}
}
8 changes: 1 addition & 7 deletions src/plugin/advancedFormat/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { FORMAT_DEFAULT } from '../../constant'

export default (o, c, d) => { // locale needed later
export default (o, c) => { // locale needed later
const proto = c.prototype
const oldFormat = proto.format
d.en.ordinal = (number) => {
const s = ['th', 'st', 'nd', 'rd']
const v = number % 100
return `[${number}${(s[(v - 20) % 10] || s[v] || s[0])}]`
}
// extend en locale here
proto.format = function (formatStr) {
const locale = this.$locale()

Expand Down

0 comments on commit 7ae1a1d

Please sign in to comment.