dayjs icon indicating copy to clipboard operation
dayjs copied to clipboard

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 lizelu opened this issue 2 years ago • 0 comments

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

lizelu avatar Aug 26 '22 02:08 lizelu