Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #2043

Open
lizelu opened this issue Aug 26, 2022 · 0 comments

Comments

@lizelu
Copy link

lizelu commented Aug 26, 2022

The code example is as follows

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

//  local timezone is Australia/Sydney, Output Wrong
BeijingTime 2022-10-02 + 1 =  2022-10-02

How to solve the above problems ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant