iamkun / iamkun/dayjs

Setting minute make hour invalid

Open
#2,266 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Setting minute() changes hours if using timezone

**Expected behavior**
Only minute is changed

**Information**
- Day.js Version dayjs@1.11.7
- Linux
- Chrome Version 108.0.5359.124 (Official Build) (64-bit)
- Time zone: UTC +3

```
let testTime = dayjs().tz('Europe/Dublin')
console.log('INITIAL', testTime.format('YYYY-MM-DDTHH:mm:ssZ[Z]'))
testTime = testTime.minute(0)
console.log('AFTER MINUTE SET', testTime.format('YYYY-MM-DDTHH:mm:ssZ[Z]'))
```

Output:

INITIAL 2023-03-23T10:23:09+00:00Z
AFTER MINUTE SET 2023-03-23T07:00:09+00:00Z

I expect
AFTER MINUTE SET 2023-03-23T10:00:09+00:00Z

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the provided dayjs().tz('Europe/Dublin') and minute(0) snippet, then inspect the timezone-related date-setting path. Done means changing the minute preserves the existing hour and produces the expected 10:00:09+00:00Z output.

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
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.