Skip to content

Commit 82ef9a3

Browse files
authored
fix: parse a string for MMM month format with underscore delimiter (#1349)
1 parent e93e6b8 commit 82ef9a3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/plugin/customParseFormat/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const match4 = /\d{4}/ // 0000 - 9999
99
const match1to2 = /\d\d?/ // 0 - 99
1010
const matchSigned = /[+-]?\d+/ // -inf - inf
1111
const matchOffset = /[+-]\d\d:?(\d\d)?/ // +00:00 -00:00 +0000 or -0000 +00
12-
const matchWord = /\d*[^\s\d-:/()]+/ // Word
12+
const matchWord = /\d*[^\s\d-_:/()]+/ // Word
1313

1414
let locale = {}
1515

test/plugin/customParseFormat.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,12 @@ describe('meridiem locale', () => {
338338
expect(dayjs(date, format, 'zh-cn').format(format2)).toBe(input)
339339
})
340340
})
341+
342+
it('parse a string for MMM month format with underscore delimiter', () => {
343+
const input = 'Jan_2021'
344+
const format = 'MMM_YYYY'
345+
expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf())
346+
const input2 = '21_Jan_2021_123523'
347+
const format2 = 'DD_MMM_YYYY_hhmmss'
348+
expect(dayjs(input2, format2).valueOf()).toBe(moment(input2, format2).valueOf())
349+
})

0 commit comments

Comments
 (0)