startOf with timezone plugin gives wrong output for toISOString
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Current behavior**
```
console.log(dayjs.tz('2022-03-01', 'Europe/Paris').startOf('day').format()); // correct 2022-03-01T00:00:00+01:00
console.log(dayjs.tz('2022-03-01', 'Europe/Paris').format()); // correct 2022-03-01T00:00:00+01:00
console.log(dayjs.tz('2022-03-01', 'Europe/Paris').startOf('day').toISOString()); // incorrect 2022-03-01T00:00:00.000Z
console.log(dayjs.tz('2022-03-01', 'Europe/Paris').toISOString()); // correct 2022-02-28T23:00:00.000Z
```
**Expected behavior**
```
console.log(dayjs.tz('2022-03-01', 'Europe/Paris').startOf('day').format()); // 2022-03-01T00:00:00+01:00
console.log(dayjs.tz('2022-03-01', 'Europe/Paris').format()); // 2022-03-01T00:00:00+01:00
console.log(dayjs.tz('2022-03-01', 'Europe/Paris').startOf('day').toISOString()); // 2022-02-28T23:00:00.000Z
console.log(dayjs.tz('2022-03-01', 'Europe/Paris').toISOString()); // 2022-02-28T23:00:00.000Z
```
I can't figure why but there is a one hour offset when I use `toISOString` after `startOf('day')`.
**Information**
- Day.js Version 1.11.1
- Time zone: Europe/Paris
Contributor guide
Research direction
Start with the timezone plugin behavior shown in the reproduction, focusing on the interaction between startOf('day') and toISOString() for Europe/Paris. Add a regression test covering both the expected formatted and ISO outputs, then run the relevant test suite to confirm the offset is preserved.
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
- Clearly specified
- Newbie friendliness
- 45/100