You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When you convert a date to the same timezone and with the keepLocalTime set as true the valueOf function returns the wrong milis value.
See this code snippet:
importdayjsfrom'dayjs';importtimezonefrom'dayjs/plugin/timezone';importutcfrom'dayjs/plugin/utc';dayjs.extend(timezone);dayjs.extend(utc);// Update: Apparently it only happens when the timezone is UTCconsttimezoneToUse='UTC'// Set default timezonedayjs.tz.setDefault(timezoneToUse);constdate1=dayjs.tz('2021-08-09T12:45:00Z');console.log(date1.format());// 2021-08-09T12:45:00Zconsole.log(date1.valueOf());// 1628513100000constdate2=dayjs.tz('2021-08-09T12:45:00Z').tz(timezoneToUse);console.log(date2.format());// 2021-08-09T12:45:00Zconsole.log(date2.valueOf());// 1628513100000constdate3=dayjs.tz('2021-08-09T12:45:00Z').tz(timezoneToUse,true);console.log(date3.format());// 2021-08-09T12:45:00Zconsole.log(date3.valueOf());// 1628520300000 -> why?
Expected behavior valueOf should return the same value regardless if you set keepLocalTime on or off if you are parsing from the same timezone.
Information
Day.js Version v1.11.13
OS: MacOS Sonoma 14.7
Browser Chrome v129.0.6668.91
Time zone: Europe/Prague
The text was updated successfully, but these errors were encountered:
Describe the bug
When you convert a date to the same timezone and with the
keepLocalTime
set astrue
thevalueOf
function returns the wrong milis value.See this code snippet:
Expected behavior
valueOf
should return the same value regardless if you setkeepLocalTime
on or off if you are parsing from the same timezone.Information
The text was updated successfully, but these errors were encountered: