Starting from March 2007, the Daylight Savings Time (DST) start date and end date for the United States will change. DST will start at 2:00 A.M. on the second Sunday in March and end at 2:00 A.M on the first Sunday in November.
The C Run-Time (CRT) performs its own time handling only when the TZ environment variable is set, or when an underlying OS API time call fails. If the TZ environment variably is not set, the CRT calls the Windows APIs and exhibits Windows behavior. Windows Updates are available which allow Windows to correctly calculate time based on the new DST rules. CRT Updates are available for the CRTs which ship with every currently supported version of Visual Studio and CRT updates are also available for the CRT which ships with Windows to continue to correctly handle DST conversions in U.S. time zones based on the new DST rules.
Get more information on How to handle dates and times that include DST
Sarita Bafna - Visual C++ Team
I understnad that the information is saved under hklc\software\microsoft\windows nt\currentversion\time zones in XP. You indicated that "If the TZ environment variably is not set, the CRT calls the Windows APIs and exhibits Windows behavior". My questions:
1) What is the API ?
2) Is the API go to this registry to get the info ?
You should check the CRT sources to be sure (VC\crt\...), but I believe the API called is GetTimeZoneInformation
I believe my crt is *NOT* up-to-date because the version is 7.0.2600.2180 and NOT 7.0.2600.3085 as indicated in the VC++ runtime fixes (because I have *NOT* installed Visual Studio 2005 sp1). However, it seems that the O/S has been updated to reflect the DST changes. I am just wondering how does O/S get DST info:
1) Does it get the info directly from registry ? or
2) Does it call some API ? If it does, what API is it calling and which DLL? I would assume that it is *NOT* calling from crt because my crt has *NOT* been updated ?
The CRT has been always calling GetTimeZoneInformation() (as long as the environment variable TZ is not defined). The file you might want to look at is tzset.c.
The OS patch for DST fixes how this API works - and hence anybody who's calling it will get the right information for 2007 and beyond. So, CRT gets that for free (again, if TZ is not defined).
The new DST information is stored in the registry. You might want to check the following link to know about the registry structure:
Thanks for the reply. I can see that in tzset.c, GetTimeZoneInformation is being called when TZ is off. I am trying to understand why when TZ is off, crt library needed to update.
Can you elaborate more as far as which part of the code is wrong?
I meant when tz is on that crt needed update
The download pages for the Visual Studio hotfixes have broken links, at least for 2003 and 2003 SP1. I haven't checked the others yet