iamkun / iamkun/dayjs

Wrong offset for America/Phoenix

Open
#1,898 2 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**
When using America/Phoenix, it gives an offset of 4 hours from UTC/ZULU/GMT, but the real offset is 7 hours.

**Expected behavior**
Expected offset is 7 hours, specifically, 420 minutes, but it outputs 240.

Full code to be ran in Node:

```
const dayjs = require('dayjs');
const customParseFormat = require('dayjs/plugin/customParseFormat')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')

dayjs.extend(customParseFormat)
dayjs.extend(utc)
dayjs.extend(timezone)

let date = dayjs.tz("2021/12/25", "YYYY/MM/DD", "America/Phoenix");
let date2 = dayjs.tz("2021/12/25", "YYYY/MM/DD", "zulu");

console.log(date["$d"], date["$x"]);
console.log(date2["$d"], date2["$x"]);
```

The output is:

2021-12-25T04:00:00.000Z { '$localOffset': 240, '$timezone': 'America/Phoenix' }
2021-12-25T00:00:00.000Z { '$timezone': 'zulu' }

Also, running `date.toISOString()` and `date2.toISOString()` it outputs the right strings:

2021-12-25T07:00:00.000Z
2021-12-25T00:00:00.000Z

**Information**
- Day.js Version 1.10.7
- Linux
- Node v14.19.2

Contributor guide

Open the contributing guide

Research direction

Start with the timezone plugin entry point and reproduce the provided Node.js snippet for America/Phoenix on 2021/12/25. Compare the reported $localOffset with the documented 420-minute offset and the existing toISOString() output; done means the offset metadata is consistent without regressing the ISO strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
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.