iamkun / iamkun/dayjs

Incorrect parsing of year string with leading zeros

Open
#596 2 comments 8 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

Thanks for a great library, just has moved a project to it.

**Describe the bug**
Incorrect parsing of dates in the format "YYYY-MM-DD" when YYYY contains leading zeros.
dayjs("0001-01-01") is Jan 01 1901

This issue is related to the usage of the following constructor of Date in JS
`new Date(year, monthIndex)`;
[source code](https://github.com/iamkun/dayjs/blob/dev/src/index.js#L60)

**Expected behavior**
dayjs("0001-01-01") should be Jan 01 0001

**Information**
- Day.js Version 1.8.13
- OS: Windows 10 1809 x64
- Browser Chrome 70/Firefox 62
- Time zone: GMT+0300

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.