Skip to content

Commit

Permalink
fix: parse a string for MMM month format with underscore delimiter (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sumbad committed Jan 22, 2021
1 parent e93e6b8 commit 82ef9a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugin/customParseFormat/index.js
Expand Up @@ -9,7 +9,7 @@ const match4 = /\d{4}/ // 0000 - 9999
const match1to2 = /\d\d?/ // 0 - 99
const matchSigned = /[+-]?\d+/ // -inf - inf
const matchOffset = /[+-]\d\d:?(\d\d)?/ // +00:00 -00:00 +0000 or -0000 +00
const matchWord = /\d*[^\s\d-:/()]+/ // Word
const matchWord = /\d*[^\s\d-_:/()]+/ // Word

let locale = {}

Expand Down
9 changes: 9 additions & 0 deletions test/plugin/customParseFormat.test.js
Expand Up @@ -338,3 +338,12 @@ describe('meridiem locale', () => {
expect(dayjs(date, format, 'zh-cn').format(format2)).toBe(input)
})
})

it('parse a string for MMM month format with underscore delimiter', () => {
const input = 'Jan_2021'
const format = 'MMM_YYYY'
expect(dayjs(input, format).valueOf()).toBe(moment(input, format).valueOf())
const input2 = '21_Jan_2021_123523'
const format2 = 'DD_MMM_YYYY_hhmmss'
expect(dayjs(input2, format2).valueOf()).toBe(moment(input2, format2).valueOf())
})

0 comments on commit 82ef9a3

Please sign in to comment.