Imagine you take a local date, say 2016-12-28, in a given time zone, say America/New_York, and convert the start of that date into UTC (in this case 2016-12-28T05:00:00Z).
Is it then possible from that UTC time to get back to the original local date without knowing the time zone? All you know is that the UTC time represents some local midnight/start of day.
I imagine this is possible in certain scenarios, e.g. when the offset is rather small, but I'm not sure that there won't be two possible answers when time zones are close to the date line, i.e. when two time zones have the same time, but different dates/offsets (-10 and +14).
(This problem was originally encountered in a database where local dates where wrongly stored in UTC, and the original time zone data is difficult to retrieve again.)
It may be possible under certain constraints to identify the time zone offset (
UTC-05:00
), but not the original time zone (America/New_York
). You could only list the possible time zones that the offset might belong to at that moment, as Howard showed in his answer. There are other edge cases that make this problem difficult:You gave a very clear case of how one couldn't determine the date for offsets close to the International Date Line.
For example, consider
2016-12-31T10:00:00Z
. That could be2016-12-31T00:00:00-10:00
(possiblyPacific/Honolulu
), or it could be2017-01-01T00:00:00+14:00
(possiblyPacific/Tongatapu
).Both
-10/+14
and-11/+13
pairings could be possible, but no inhabited places on Earth actually use-12
. So if you have values that are at exactly noon, they are likely+12
, unless you are dealing with ships at sea.The local midnight value might not exist in the time zone you're expecting.
2016-10-16T03:00:00Z
is the start of the day in bothAmerica/Sao_Paulo
andAmerica/Bahia
(both in Brazil). However,America/Sao_Paulo
's local time is01:00
, not00:00
. There is no midnight on that day, due to their DST spring-forward transition.The local midnight value might exist twice in the time zone you're expecting.
America/Havana
, both2016-11-06T04:00:00Z
and2016-11-06T05:00:00Z
have a local time of00:00
, due to their DST fall-back transition.So, in the general case, you may be able to resolve most of these back to their original offset, but you will have ambiguities for time zones with
-10
,-11
,+13
, or+14
offsets, and for time zones with DST transitions at midnight (in spring) or at 1:00 AM (in fall). (Keep in mind spring/fall are different between northern/southern hemisphere.)