iamkun / iamkun/dayjs

The timezone is affected by local DST

Open
#2,675 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

import dayjs from "dayjs";
import utc from "dayjs/plugin/utc";
import timezone from "dayjs/plugin/timezone";
import "dayjs/locale/ja";

dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.tz.setDefault("Asia/Tokyo");

const d1 = dayjs.tz("2024-03-31 00:00", "Asia/Tokyo");
const d2 = dayjs.tz("2024-03-31 01:00", "Asia/Tokyo");
const d3 = dayjs.tz("2024-03-31 02:00", "Asia/Tokyo");

console.log(d1.format("YYYY/MM/DD HH:mm"));
console.log(d2.format("YYYY/MM/DD HH:mm"));
console.log(d3.format("YYYY/MM/DD HH:mm"));

When the time zone is set as follows, 1 o'clock is skipped due to the influence of the local time zone.

**Expected behavior**
2024/03/31 00:00
2024/03/31 01:00
2024/03/31 00:00

expect the output result value as above, but the following value comes out.

2024/03/31 00:00
2024/03/31 02:00
2024/03/31 03:00

**Information**
- Day.js Version [e.g. v1.11.11]
- OS: [e.g. window10]
- Browser [N/A, Node 20.11.1]
- Time zone: [e.g. Europe/London utc+0]

Contributor guide

Open the contributing guide

Research direction

Start with the timezone plugin entry point and the dayjs.tz calls shown in the report, then reproduce them with Node 20.11.1 using Asia/Tokyo while noting the machine's local timezone. Compare the formatted values for d1, d2, and d3 with the reported expected behavior, and add a regression test once the intended handling of the 02:00 case is confirmed.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.