Timezone startOf DST off-by-one
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
In Australia DST ends on the 4th of April 2021.
Using the timezone plugin and v1.10.4 (latest):
- Getting the start of the day before this date (in DST) returns the correct value
- Getting the start of the day after this date (outside DST) returns an incorrect value.
```js
dayjs.tz('2021-04-01 08:00', 'Australia/Melbourne').startOf('day').format()
// 2021-04-01T00:00:00+11:00 (correct)
dayjs.tz('2021-04-15 08:00', 'Australia/Melbourne').startOf('day').format()
// 2021-04-14T23:00:00+11:00 (incorrect)
```
Curiously, the changelog mentions this issue was fixed in v1.9.7, so I switched to 1.9.6 to test this and it seems to be working correctly:
```js
dayjs.tz('2021-04-01 08:00', 'Australia/Melbourne').startOf('day').format()
// 2021-04-01T00:00:00+11:00 (correct)
dayjs.tz('2021-04-15 08:00', 'Australia/Melbourne').startOf('day').format()
// 2021-04-15T00:00:00+11:00 (correct)
```
Is anyone up for fixing this? I'll throw a $100 bounty down. Surely there are some others who also need this fixed and want to add to the pool!
Contributor guide
Research direction
Reproduce the examples with the timezone plugin on v1.10.4 and compare them with v1.9.6, focusing on the Australia/Melbourne DST transition. Trace the plugin's startOf('day') handling and add a regression test for the date after the transition. Done means that startOf('day') returns local midnight with the correct 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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100