Unexpected hour/UTC offset across daylight savings time
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
Adjusting a Dayjs instance for a new timezone across daylight savings time results in unexpected hour and UTC offset.
let date = dayjs('2021-03-17T09:00:00Z');
console.log(date.format('HH:mm DD MMM YY Z'));
date = date.tz('Etc/GMT-6', false);
console.log(date.format('HH:mm DD MMM YY Z'));
date = date.tz('Etc/GMT-6', true);
console.log(date.format('HH:mm DD MMM YY Z'));
**Actual behavior**
05:00 17 Mar 21 -04:00
15:00 17 Mar 21 +05:00
15:00 17 Mar 21 +05:00
**Expected behavior**
I would expect the last date to retain the hour and UTC offset from the original date since keepLocalTime flag was set to true.
05:00 17 Mar 21 -04:00
15:00 17 Mar 21 +05:00
05:00 17 Mar 21 +06:00
**Information**
- Day.js Version 1.10.4
- OS: Window
- Browser Chrome Version 88.0.4324.190 (Official Build) (64-bit)
- Time zone: Eastern Standard Time, GMT-5
Contributor guide
Research direction
No source file or test is named. Start by running the supplied Day.js timezone reproduction with the stated environment and inspect the .tz handling for keepLocalTime across daylight-saving offsets; done means the final output retains 05:00 and reports +06:00 as expected, with coverage for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- internationalization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100