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
If the current behavior is expected, can you clarify what the purpose of using TZDate() with a date string and a time zone in the documentation? And what's expected?
The text was updated successfully, but these errors were encountered:
The way I understand it is that if you instantiate TZDate using string, the underlying date is always the same. So if you have 2024-10-31, which is interpreted as UTC in Date object, the underlying date will always be 2024-10-31T00:00:00Z, which would be displayed as Wed Oct 30 2024 17:00:00 GMT-0700 (Pacific Daylight Time) in console in your case.
But the difference between using Date and TZDate is that when calling it's methods, you will get results for the target timezone, so calling new TZDate("2024-10-31", "Asia/Singapore").toString() would return Thu Oct 31 2024 08:00:00 GMT+0800 (Singapore Standard Time), which is the GMT+8 equivalent of 2024-10-31 in UTC.
You can perhaps take a look at discussion for issue #9, where creating TZDate instances is discussed. It is possible to use transpose function if you want to take a certain date and shift it so you get the same date but in different timezone. Or you can use parseISO as you mentioned.
When I use a date string in the TZDate constructor, it appears that the time zone has no effect.
My machine is in Pacific Daylight Time and all of these produce the same time, midnight UTC interpreted in my machine's local time:
I see that it is possible to use
parseISO()
to accomplish this, eg:If the current behavior is expected, can you clarify what the purpose of using
TZDate()
with a date string and a time zone in the documentation? And what's expected?The text was updated successfully, but these errors were encountered: