Incorrect endOf & startOf when daylight saving in effect
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
startOf and endOf functions does not work correctly when timezone plugin in use and daylight saving in effect.
This seems to be regression from 1.9.6 (worked in 1.9.6 and does not work in 1.9.7).
This is output from 1.9.7:
````
dayjs("2021-02-25T22:00:00.000Z").tz('Europe/Prague').endOf('month').toISOString() // 2021-02-28T22:59:59.999Z
dayjs("2021-03-25T22:00:00.000Z").tz('Europe/Prague').endOf('month').toISOString() // 2021-03-31T22:59:59.999Z
````
This is output from 1.9.6:
````
dayjs("2021-02-25T22:00:00.000Z").tz('Europe/Prague').endOf('month').toISOString() // 2021-02-28T22:59:59.999Z
dayjs("2021-03-25T22:00:00.000Z").tz('Europe/Prague').endOf('month').toISOString() // 2021-03-31T21:59:59.999Z
````
**Expected behavior**
Momentjs produces correct result:
````
moment("2021-02-25T22:00:00.000Z").tz('Europe/Prague').endOf('month').toISOString() // 2021-02-28T22:59:59.999Z
moment("2021-03-25T22:00:00.000Z").tz('Europe/Prague').endOf('month').toISOString() // 2021-03-31T21:59:59.999Z
````
**Related**
I believe the error is caused by this pull request: https://github.com/iamkun/dayjs/pull/1229
Not sure but this is maybe related to this bug: https://github.com/iamkun/dayjs/issues/1260
Contributor guide
Research direction
Start by reproducing the two endOf('month') examples with the timezone plugin and compare the 1.9.6 and 1.9.7 behavior. Then inspect pull request #1229 and issue #1260 for the regression's context. Done means the Europe/Prague DST transition produces the expected ISO timestamp without breaking the non-DST case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100