iamkun / iamkun/dayjs

Incorrect time zone offset +08:41 for Tokyo

Open
#2,164 3 comments 1 reaction 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**

dayjs displays an incorrect time zone offset `+08:41` at January 1, 1888.
JS's native Date object and mement shows the correct offset `+09:00`.
Note that January 1, 1888, is the first day of the current JST Japan Standard Time started.

```js
// No.1 native Date: OK

process.env.TZ = "Asia/Tokyo";
new Date("1888-01-01T00:00:00+09:00").toString().split(/GMT(.\d{4})/)[1];
// => '+0900'

// No.2 moment: OK

const moment = require("moment");
require("moment-timezone");
moment("1888-01-01T00:00:00+09:00").tz("Asia/Tokyo").format("Z");
// => '+09:00'

// No.3 dayjs: NG

const dayjs = require("dayjs");
dayjs.extend(require("dayjs/plugin/utc"));
dayjs.extend(require("dayjs/plugin/timezone"));
dayjs("1888-01-01T00:00:00+09:00").tz("Asia/Tokyo").format("Z");
// => '+08:41'
```

**Expected behavior**

dayjs should displays the correct offset `+09:00` as moment does.

**Information**

- Day.js Version: 1.11.6
- OS: macOS
- Browser: node v18
- Time zone: Japan Standard Time GMT+09:00

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.