Skip to content

Commit

Permalink
fix: Copy & export built-in en locale to /locale folder as a separate…
Browse files Browse the repository at this point in the history
… file
  • Loading branch information
iamkun committed Feb 11, 2019
1 parent 5eaf77b commit a7e05e0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
6 changes: 0 additions & 6 deletions src/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,3 @@ export const INVALID_DATE_STRING = 'Invalid Date'
// regex
export const REGEX_PARSE = /^(\d{4})-?(\d{1,2})-?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d{1,3})?$/
export const REGEX_FORMAT = /\[.*?\]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g

export const en = {
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('_')
}
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as C from './constant'
import U from './utils'
import en from './locale/en'

let L = 'en' // global locale
const Ls = {} // global loaded locale
Ls[L] = C.en
Ls[L] = en

const isDayjs = d => d instanceof Dayjs // eslint-disable-line no-use-before-define

Expand Down
5 changes: 5 additions & 0 deletions src/locale/en.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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('_')
}
7 changes: 5 additions & 2 deletions test/locale/keys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ it('Locale keys', () => {

expect(months).toEqual(expect.any(Array))
// function pass date return string or number or null
for (let i = 1; i <= 31; i += 1) {
expect(ordinal(i)).toEqual(expect.anything())
if (name !== 'en') { // en ordinal set in advancedFormat
for (let i = 1; i <= 31; i += 1) {
expect(ordinal(i)).toEqual(expect.anything())
}
}

expect(dayjs().locale(name).$locale().name).toBe(name)
if (formats) {
expect(Object.keys(formats).sort()).toEqual(['L', 'LL', 'LLL', 'LLLL', 'LT', 'LTS'].sort())
Expand Down

0 comments on commit a7e05e0

Please sign in to comment.