Skip to content

Commit a7e05e0

Browse files
committed
fix: Copy & export built-in en locale to /locale folder as a separate file
1 parent 5eaf77b commit a7e05e0

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

src/constant.js

-6
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,3 @@ export const INVALID_DATE_STRING = 'Invalid Date'
2828
// regex
2929
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})?$/
3030
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
31-
32-
export const en = {
33-
name: 'en',
34-
weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
35-
months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_')
36-
}

src/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import * as C from './constant'
22
import U from './utils'
3+
import en from './locale/en'
34

45
let L = 'en' // global locale
56
const Ls = {} // global loaded locale
6-
Ls[L] = C.en
7+
Ls[L] = en
78

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

src/locale/en.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
name: 'en',
3+
weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
4+
months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_')
5+
}

test/locale/keys.test.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ it('Locale keys', () => {
3636

3737
expect(months).toEqual(expect.any(Array))
3838
// function pass date return string or number or null
39-
for (let i = 1; i <= 31; i += 1) {
40-
expect(ordinal(i)).toEqual(expect.anything())
39+
if (name !== 'en') { // en ordinal set in advancedFormat
40+
for (let i = 1; i <= 31; i += 1) {
41+
expect(ordinal(i)).toEqual(expect.anything())
42+
}
4143
}
44+
4245
expect(dayjs().locale(name).$locale().name).toBe(name)
4346
if (formats) {
4447
expect(Object.keys(formats).sort()).toEqual(['L', 'LL', 'LLL', 'LLLL', 'LT', 'LTS'].sort())

0 commit comments

Comments
 (0)