I need to take an arbitrary date and time in UTC format and then figure out what that time was in a specific time zone.
Here are some examples of the data that we'll have to deal with:
Translate March 28, 2001, 5 PM UTC to the central time zone
Figure out Nov 4, 2007, 12 PM UTC to the eastern time zone
Figure out Jan 1, 2009, 1 AM UTC to the mountain time zone
Let's take the March 28, 2001 example first. In 2001, the United States laws specified that daylight savings time did not begin until the first Sunday of April. Starting in 2007, daylight saving time now starts on the second Sunday in March. So depending on what rules you use, March 25 might or might not require daylight saving time.
Unfortunately, I'm not sure how to address this problem from within C++. Vista and Windows 2008 have functions like GetDynamicTimeZoneInformation() and GetTimeZoneInformationForYear(), but I can't use them in older versions of Windows. The closest function that XP seems to provide is GetTimeZoneInformation(), but this is limited to looking up time zone rules for the current calendar year.
I *could* try to code the logic manually, but what if legislation changes in the near future? Then anyone who statically links to my library will get incorrect time stamps.
Any tips on what I can do to fix this problem?