Dan Horne wrote:
Hi, I'm trying to determine the local time on an MS Windows PC, and would
prefer not to have to explicitly set my timezone. From reading the doco, it
seems that Datetme is pretty UNIX-specific in how it determines local time,
and setting the timezone to "local" on Windows fails). Any ideas for a
workaround appreciated
G'day Dan,
AFAIK, you'll need to ask Uncle Bill for that. It's not that DT's time
zones are unix specific, only that they're more accurate than Windows.
Windows takes a look at all the current time zone and finds all those
with matching rules, then lumps them into a single zone.
So Australia/Melbourne and Australia/Sydney become one zone.
This works for current DateTimes, however it is historically innacurate
as Melbourne and Sydney haven't necessarily always shared the same
rules. And theres no reason why they always will: there's different
governments that make the decisions.
Working this way makes it easier for Windows to handle asking you which
timezone you're in, but for historical accuracy it's totally bogus.
The most accurate time zone you can automatically get from Windows is
the UTC offset. And of course that won't take into consideration DST :)
If you can set an ENV under windows, you can read the DT from there. Of
course, you'll have to set it first as there really is no way of getting
an accurate time zone from a windows OS.
Cheers!
Rick Measham