iamkun / iamkun/dayjs

After the local timezone is switched to Australia/Sydney, the output of the add method is wrong because winter time is not taken into account

Open
#2,043 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

### The code example is as follows

```Typescript
import dayjs from 'dayjs';
import timezone from 'dayjs/plugin/timezone';
import utc from 'dayjs/plugin/utc';
dayjs.extend(utc)
dayjs.extend(timezone)

const datetime = "2022-10-02";
console.log(dayjs.tz.guess())
const bjTime = dayjs.tz(datetime,'Asia/Shanghai'); // 东八区时间
console.log(`BeijingTime ${datetime} + 1 = `, bjTime.add(1, 'd').format('YYYY-MM-DD')); // add one day
```

```Shell
// local timezone is Asia/Shanghai , result is right
BeijingTime 2022-10-02 + 1 = 2022-10-03

// local timezone is America/Toronto, result is right
BeijingTime2022-10-02 + 1 = 2022-10-03
```
### Wrong
```Shell
// local timezone is Australia/Sydney, Output Wrong
BeijingTime 2022-10-02 + 1 = 2022-10-02
```

------------
### How to solve the above problems ???

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied dayjs.tz example with Australia/Sydney and the 2022-10-02 date, then inspect the timezone plugin's handling of add across daylight-saving transitions. Done means adding one day produces 2022-10-03 for this case without regressing the Asia/Shanghai and America/Toronto examples.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.