Context:
A user provides a date and time, along with a specific UTC offset
1994-06-05T08:15:30-05:00
This is then passed through some Java datetime libraries, which determine that this occurs during daylight savings time, and helpfully adds an hour to the offset (if the timestamp is not in daylight savings time, it is returned without modification):
1994-06-05T08:15:30-04:00
(Note that the time of the day 15:30
is NOT changed)
Finally, I receive that string in the frontend (javascript), and I need to display only the original UTC offset exactly as it was entered, -05:00
in this case.
I cannot change any parts of the process leading up to this point, so my only option is to try to reverse engineer the daylight savings time detection, and subtract an hour of offset when appropriate.
Since the date and time of day remain unchanged, an obvious solution is to just check IF date and time are in daylight savings time THEN subtract one hour from offset
. For the majority of timestamps this works, however there are problems at the DST boundary, since for example the same timestamps can occur twice from 1am to 2am the day the DST goes into effect. Is there any method I can use to disambiguate some or all of the timestamps that occur at the DST boundary, given the information about how the final timestamp is generated?