dayjs().tz(timezone) uses current timezone offset instead of date timezone offset
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
`dayjs().tz(timezone)` methods uses Timezone offset at the time of execution. This pose issues when working with Timezone affected by DST.
```js
dayjs('2020-08-01', 'Europe/Paris').format()
// returns 2020-08-01T00:00:00+02:00 all the time
dayjs('2020-08-01', 'Europe/Paris').tz('Europe/Paris').format()
// returns 2020-08-01T00:00:00+02:00 during summer and 2020-08-01T00:00:00+01:00 during winter
```
**Expected behavior**
```js
dayjs('2020-08-01', 'Europe/Paris').tz('Europe/Paris').format()
// should always return 2020-08-01T00:00:00+02:00 because August 1st has a 2h offset (GMT+2) for Europe/Paris
```
**Information**
- Day.js Version 1.9.4
- OS: macOS
- Node.js v12
- Time zone:CET / 'Europe/Paris' (GMT+1)
Contributor guide
Research direction
Start by reproducing the two `dayjs(...).tz('Europe/Paris').format()` examples from the issue with a winter and summer date. Trace the `tz(timezone)` entry point and compare the offset used at execution time with the offset for the represented date; done means August 1 consistently formats with the +02:00 offset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100