iamkun / iamkun/dayjs

Setting UTC offset near start of daylight savings alters the time

Open
#2,218 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**
Adding a UTC offset to a date near the beginning of daylight savings changes the time.

Note: in time zone Europe/London, daylight savings starts on 2023-03-26 at 01:00 GMT.

Example:
> dayjs('2023-03-25T00:00:00+00:00').utc().utcOffset(1)
// '2023-03-25T01:00:00+01:00' The same as the original time.

> dayjs('2023-03-26T00:00:00+00:00').utc().utcOffset(1)
// '2023-03-26T02:00:00+01:00' This is one hour ahead of the original time.

> dayjs('2023-03-27T00:00:00+00:00').utc().utcOffset(1)
// '2023-03-27T01:00:00+01:00' The same as the original time.

**Expected behavior**
Changing the UTC offset should not change the time.

**Information**
- Day.js Version 1.11.7
- OS: macOS Ventura 13.2
- Node version: v17.7.0
- Time zone: GMT

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the three UTC and utcOffset examples from the issue, focusing on the UTC-offset handling around the Europe/London daylight-saving transition. Verify that applying the offset preserves the original instant and add coverage for the dates before, during, and after the transition.

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
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.