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
Hi, I'm trying to migrate from date-fns-tz. According to the documentation, transpose is the date-fns-tz's toZonedTime equivalent. However, it seems both functions return different results depending on the time zone provided.
The output clearly shows that the results of toZonedTime (the first three lines) and transpose (the last three lines) differ.
Tue Dec 17 2024 13:00:00 GMT+0100 (Central European Standard Time)
Tue Dec 17 2024 14:00:00 GMT+0100 (Central European Standard Time)
Wed Dec 18 2024 02:00:00 GMT+0100 (Central European Standard Time)
Tue Dec 17 2024 13:00:00 GMT+0100 (Central European Standard Time)
Tue Dec 17 2024 12:00:00 GMT+0100 (Central European Standard Time)
Tue Dec 17 2024 00:00:00 GMT+0100 (Central European Standard Time)
Does it mean toZonedTime cannot be simply changed to transpose and some additional work is needed when migrating from date-fns-tz? Or maybe I'm doing something wrong?
The text was updated successfully, but these errors were encountered:
kkwasnyrtb
changed the title
Unexpected transpose results
Migrating from date-fns-tzDec 17, 2024
I was experiencing the same problem. I never heard about transpose, but I thought that I need to do something like this:
// making new TZDate from system time, casting `toISOString` because otherwise it's same time as with `new Date()`parseISO(newTZDate(newDate(),'America/Chicago').toISOString(),{in: tz('America/Chicago'),})
Output is still incorrect
So now that you mentioned transpose, I achieve the same result as toZonedTime using following logic:
I am unsure if this solution is the correct solution, but it works for me. I'll keep an eye on this issue, to learn more when someone with more experience with this library hops in.
Hi, I'm trying to migrate from
date-fns-tz
. According to the documentation,transpose
is thedate-fns-tz
'stoZonedTime
equivalent. However, it seems both functions return different results depending on the time zone provided.Please take a look at the code below.
The output clearly shows that the results of
toZonedTime
(the first three lines) andtranspose
(the last three lines) differ.Does it mean
toZonedTime
cannot be simply changed totranspose
and some additional work is needed when migrating fromdate-fns-tz
? Or maybe I'm doing something wrong?The text was updated successfully, but these errors were encountered: