iamkun / iamkun/dayjs

CustomParseFormat doesn't parse double digit days and months properly in strict mode

Open
#902 11 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When in strict mode, format "D.M.YYYY" should parse both "1.1.2020" and "01.01.2020", but it fails with Invalid date for the second.
https://runkit.com/embed/w5jkq082wagg

moment.js works this way https://github.com/moment/moment/issues/2554
there even seems to be code for this https://github.com/iamkun/dayjs/blob/dev/src/plugin/customParseFormat/index.js (regexes match1to2) but probably doesn't work.

**Expected behavior**
dayjs("01.02.2020", "D.M.YYYY", true) should be parsed correctly

**Information**
- Day.js Version 1.8.26
- OS: Windows 10
- Browser Chrome 81.0.4044.129

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.