+00:00 timezone bug
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
This line is causing several bugs when working with +00:00 timezones (for example Europe/Lisbon):
https://github.com/iamkun/dayjs/blob/b5a1391011b247d08863d291542db5937b23b427/src/plugin/utc/index.js#L117
It is because $localOffset is 0 (this is correct offset) and therefore value of `(new Date()).getTimezoneOffset()` is used (instead of the value 0).
Operator || cannot be used here, because it does not work correctly with $localOffset == 0.
This line should be changed into:
```
? this.$offset + (this.$x.$localOffset === null || this.$x.$localOffset === undefined ? (new Date()).getTimezoneOffset()) : 0
```
Contributor guide
Research direction
Start by reading src/plugin/utc/index.js around line 117 and reproduce the reported behavior with a +00:00 timezone such as Europe/Lisbon. Verify the timezone offset handling and add or update a regression test for the case; done means +00:00 retains offset 0 without using the local system offset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100