iamkun / iamkun/dayjs

Old dates have weird minute offsets in utc

Open
#1,996 14 comments 0 reactions 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**
Take this as an example:
```js
// loop same day every 11 years for the past 200 years
for (let i = 2022; i > 1800; i -= 11) {
console.log(dayjs(`12/31/${i}`).utc(true).toDate());
}
```

**Expected behavior**
```
2022-12-31T00:00:00.000Z
2011-12-31T00:00:00.000Z
2000-12-31T00:00:00.000Z
1989-12-31T00:00:00.000Z
1978-12-31T00:00:00.000Z
1967-12-31T00:00:00.000Z
1956-12-31T00:00:00.000Z
1945-12-31T00:00:00.000Z
1934-12-31T00:00:00.000Z
1923-12-31T00:00:00.000Z
1912-12-31T00:00:00.000Z
1901-12-31T00:00:00.000Z
1890-12-31T00:00:00.000Z
1879-12-31T00:00:00.000Z
1868-12-31T00:00:00.000Z
1857-12-31T00:00:00.000Z
1846-12-31T00:00:00.000Z
1835-12-31T00:00:00.000Z
1824-12-31T00:00:00.000Z
1813-12-31T00:00:00.000Z
1802-12-31T00:00:00.000Z
```

**Actual behavior**
```
2022-12-31T00:00:00.000Z
2011-12-31T00:00:00.000Z
2000-12-31T00:00:00.000Z
1989-12-31T00:00:00.000Z
1978-12-31T00:00:00.000Z
1967-12-31T00:00:00.000Z
1956-12-31T00:00:00.000Z
1945-12-31T00:00:00.000Z
1934-12-31T00:00:00.000Z
1923-12-31T00:00:00.000Z
1912-12-31T00:06:00.000Z /// what???
1901-12-31T00:06:00.000Z
1890-12-31T00:06:00.000Z
1879-12-31T00:03:44.000Z /// huh??!
1868-12-31T00:03:44.000Z
1857-12-31T00:03:44.000Z
1846-12-31T00:03:44.000Z
1835-12-31T00:03:44.000Z
1824-12-31T00:03:44.000Z
1813-12-31T00:03:44.000Z
1802-12-31T00:03:44.000Z /// it goes on like this until 100 AC
```

**Information**
- Day.js Version ^1.11.4
- OS: MacOs Big Sur 11.6
- NodeJS
- Time zone: [e.g. GMT+03:00 DST]

Contributor guide

Open the contributing guide

Research direction

Start by running the provided Node.js reproduction with the utc(true) and toDate entry points, comparing the actual output with the expected UTC timestamps. Trace the date parsing and UTC conversion behavior for years before 1912; done means the listed historical dates no longer acquire unexpected minute or second offsets.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.