Set hour not working with UTC timezone
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Set hour does not work properly when timezone is UTC or any other timezone with UTC offset 0.
`dayjs('2024-06-16T00:00:00.000Z').tz('UTC').set('hour', 13).toDate().toISOString()`
**Expected behavior**
Expected Return: `2024-06-16T13:00:00:00.000Z`
Actual Return `2024-06-15T21:00:00:00.000Z`
**Information**
- Day.js Version [1.11.10]
- OS: [MacOS]
- Browser [Chrome 125.0.6422.142]
- Time zone: [GMT+8 Singapore Time]
Contributor guide
Research direction
Start by reproducing the reported Day.js 1.11.10 expression with the timezone plugin and UTC offset 0. Trace how the timezone conversion interacts with set('hour') and compare the UTC output with the expected ISO string. Done means the reported case returns 2024-06-16T13:00:00.000Z and a regression test covers it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100