Some Luxon zone offsets seem to be incorrect #1478
-
Hey! When I'm using Luxon timezones, some zone offsets seem to be incorrect. Ex. Singapore returns +7:30, even though it is UTC + 8:00 (last time it was +7:30 was in 1981). Other examples include: Turkey - returns +2 but is actually +3 Is there any fix / support for this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Luxon gets its time zone (and other locale) data from the underlying platform via the |
Beta Was this translation helpful? Give feedback.
now.millisecond
is a value between 0 and 999 denoting the fractional milliseconds of theDateTime
.Zone#formatOffset
expects a unix timestamp in milliseconds. Therefor your code will always format the offset on some fractional offset within the first second of 1970/01/01. At this pointAsia/Singapore
was at offset +7:30, the zone was only shifted to +8:00 in 1982.If you pass the correct timestamp to
formatOffset
you will receive the correct offset.Edit: to get the unix timestamp in millseconds from a
DateTime
useDateTime#valueOf
orDateTime#toMillis
.Edit again: I jused noticed that in your code you are using
luxonDateObject.setZone("Singapore")
without using the return value. Luxon's …