Time bug under Windows
William O. Dargel
wDargel at shoshana.com
Mon Dec 22 06:12:03 UTC 1997
Bob Hartwig wrote:
> The Win32 function GetTimeZoneInformation() answers whether daylight
> savings time is currently in effect, and the current bias from UTC.
> If you want to get local time, just use GetLocalTime(). If you want
Couldn't you just use GetSystemTime() if you wanted this?
> you need to add the bias value answered by GetTimeZoneInformation().
> addition, if GetTimeZoneInformation()'s return value indicates that
> daylight savings time is in effect, you need to subtract an hour.
> Yet another example of the striking elegance of the Win32 API.
Assuming that you're expressing sarcasm here, I definitely would have to
agree. Your pointers got me to dig into the documentation some more.
You're talking about functions in the Win32 API. The VM seems to be
using functions out of the C/C++ runtime library. From what I can tell,
the different sets of functions use incompatible definitions. Elegant
Whereas the functions in the C/C++ runtime library seem to have a fixed
(US only) handling of daylight savings time, the Win32 API functions
seem to have a complete specification for time zones and daylight
savings time. They can give separate biases for standard and daylight
times and what dates each will go into effect. Assuming that the
SetTimeZoneInformation() has been handled somewhere, the Win32 API
function should work anywhere in the world (as opposed to _tzset() in
the runtime library).
Since the time() function of the runtime library returns the integer
seconds from a base rather than a structure, it is much closer to what
the VM primitive is defined to return. Perhaps the easiest would be to
continue to use time(), but to get the time zone bias, standard bias and
daylight bias, as well as whether daylight savings time is currently in
effect from GetTimeZoneInformation().
Bill Dargel wdargel at shoshana.com
100 West Joy Road, Ann Arbor, MI 48105 USA
More information about the Squeak-dev