Issues with tz and utcOffset
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
**Describe the bug**
When I try to convert a utc tz to 'etc/GMT-1' tz, it doesn't give the good result only on the timing of the swap DST/STD (I am in Europe/Paris tz).
It happens the same thing on utcOffset function. The error is also in the tz format.
Script :
```
console.log(dayjs.utc('2022-03-27T00:00:00').utcOffset(60).format())
console.log(dayjs.utc('2022-03-27T01:00:00').utcOffset(60).format())
console.log(dayjs.utc('2022-03-27T02:00:00').utcOffset(60).format())
console.log(dayjs.utc('2022-03-27T03:00:00').utcOffset(60).format())
console.log(dayjs.utc('2022-03-27T00:00:00').tz('etc/GMT-1').format())
console.log(dayjs.utc('2022-03-27T01:00:00').tz('etc/GMT-1').format())
console.log(dayjs.utc('2022-03-27T02:00:00').tz('etc/GMT-1').format())
console.log(dayjs.utc('2022-03-27T03:00:00').tz('etc/GMT-1').format())
```
Result :
```
2022-03-27T01:00:00+01:00
2022-03-27T01:00:00+01:00
2022-03-27T03:00:00+01:00
2022-03-27T04:00:00+01:00
2022-03-27T01:00:00+01:00
2022-03-27T03:00:00+02:00
2022-03-27T03:00:00+01:00
2022-03-27T04:00:00+01:00
```
**Expected behavior**
Result :
```
2022-03-27T01:00:00+01:00
2022-03-27T02:00:00+01:00
2022-03-27T03:00:00+01:00
2022-03-27T04:00:00+01:00
2022-03-27T01:00:00+01:00
2022-03-27T02:00:00+01:00
2022-03-27T03:00:00+01:00
2022-03-27T04:00:00+01:00
```
**Codepen**
[https://codepen.io/BokehJS/pen/JjvwVYZ](https://codepen.io/BokehJS/pen/JjvwVYZ)
**Information**
- Day.js Version v1.11.5
- OS: Microsoft Windows 10
- Browser : Chrome
- Time zone: 'Europe/Paris'
I current use add method as a workaround because all my input datas are in UTC.
Thank you very much
Contributor guide
Research direction
Start by reproducing the timezone transition case in the linked CodePen with Day.js's utcOffset() and tz() calls around 2022-03-27 in Europe/Paris. Compare both result sets with the expected output; done means the UTC conversions produce the listed offsets and times across the DST/STD boundary.
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
- 35/100