`tz(timezone, true).utc()` is not always changing the time to UTC
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Calling `utc()` without passing `true` as parameter should change the current time to UTC. However this doesn't **always** work on a dayjs object returned by `tz()` where the second parameter is set to `true` (to keep current time).
Example (`Europe/Paris` is `GMT+1` / `GMT+2` in DST):
```
dayjs('2021-02-01T15:00').tz('Europe/Paris', true).utc().format()
dayjs('2021-09-01T15:00').tz('Europe/Paris', true).utc().format()
```
returns
```
'2021-02-01T15:00:00Z' => NON DST: INCORRECT
'2021-09-01T13:00:00Z' => DST: CORRECT
```
**Expected behavior**
For non DST it should return
```
'2021-02-01T14:00:00Z'
```
**Information**
- Day.js Version [1.10.7]
- OS: [MacOS 11.5.2]
- Browser [Chrome 93]
- Time zone: [GMT+02:00 DST (Europe/Paris)]
Contributor guide
Research direction
Reproduce the two Europe/Paris examples from the issue, comparing the non-DST and DST results. Trace the timezone and UTC conversion entry points to find why the kept local time is handled differently, then verify that the non-DST case formats as 2021-02-01T14:00:00Z without regressing the DST result.
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
- Mostly clear
- Newbie friendliness
- 42/100