Skip to content

Commit

Permalink
fix: Fix CustomParseFormat plugin bug (#568)
Browse files Browse the repository at this point in the history
fix #555
  • Loading branch information
waseemahmad31 authored and iamkun committed Apr 15, 2019
1 parent 9007cc5 commit 1f5a9db
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function makeParser(format) {
const match = regex.exec(part)
const value = match[0]
parser.call(time, value)
start += value.length
input = input.replace(value, '')
}
}
correctHours(time)
Expand Down
9 changes: 9 additions & 0 deletions test/plugin/customParseFormat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ it('return Invalid Date when parse corrupt short string', () => {
expect(dayjs(input, format).format()).toBe('Invalid Date')
})

it('Invalid Dates', () => {
expect(dayjs('10/12/2014', 'YYYY-MM-DD').format('MM-DD-YYYY')).toBe('Invalid Date')
expect(dayjs('10-12-2014', 'YYYY-MM-DD').format('MM-DD-YYYY')).toBe('Invalid Date')
})

it('Valid Date', () => {
expect(dayjs('2014/10/12', 'YYYY-MM-DD').format('MM-DD-YYYY')).toBe('10-12-2014')
})

it('correctly parse month from string after changing locale globally', () => {
const input = '2018 лютий 03'
const format = 'YYYY MMMM DD'
Expand Down

0 comments on commit 1f5a9db

Please sign in to comment.