iamkun / iamkun/dayjs

Timezone conversion incorrect when daylight saving in effect

Open
#1,260 42 comments 53 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**
Dayjs does not seem to convert timezone correctly when DST is in effect. It produces different results from Moment. The Moment results seem intuitively what I'd expect, so believe to be correct unless there is some subtlety I'm missing.

**Expected behavior**
With this code:
```javascript
const when = '2020-07-30T12:00:00+00:00'; // Midday GMT in summer
console.log('Moment London: ' + moment(when).tz('Europe/London').format('HH:mm Z'));
console.log('Moment New York: ' + moment(when).tz('America/New_York').format('HH:mm Z'));

console.log('Dayjs London: ' + dayjs(when).tz('Europe/London').format('HH:mm Z'));
console.log('Dayjs New York: ' + dayjs(when).tz('America/New_York').format('HH:mm Z'));
```

The output is:
```javascript
Moment London: 13:00 +01:00
Moment New York: 08:00 -04:00
Dayjs London: 12:00 +00:00 // Expect 13:00 +01:00
Dayjs New York: 08:00 -05:00 // Expect 08:00 -04:00
```

**Information**
- Day.js: v1.9.6
- OS: Windows 10 Home
- Nodejs: v12.8.3
- Time zone: GMT+00:00

Contributor guide

Open the contributing guide

Research direction

The issue names no source file or test; begin by running the supplied JavaScript reproduction with the timezone conversion entry point and compare Day.js with Moment for London and New York. Done means DST-aware output matches the stated expectations: 13:00 +01:00 for London and 08:00 -04:00 for New York.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.