mskfisher
mskfisher

Reputation: 3406

Converting old and new local times to UTC under Windows XP/Server 2003

My application converts past and present dates from local time to UTC.

I need to ensure I will honor any future DST updates to Windows while still correctly handling past dates.

The application is written in C++ and is running on Server 2003.

Options I've researched:

So...

(edit: found out dst_calc_engine doesn't support DST updates)

Upvotes: 4

Views: 1445

Answers (2)

Kim Gräsman
Kim Gräsman

Reputation: 7586

I think I'd prefer to re-implement GetTimeZoneInformationForYear and possibly GetDynamicTimeZoneInformation based on the information in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones.

That way, your code will follow Windows updates and you can swap the dirty code out for the actual implementation on up-level platforms.

Since you don't want to use an external database, I think no other options are viable.

Upvotes: 2

Jim Lewis
Jim Lewis

Reputation: 45075

You could use gmtime() and localtime() for dates in 2007 and later (and take advantage of Windows DST updates), and use Boost or one of the other solutions you mentioned to use the correct DST rules for 2006 and earlier.

Upvotes: 0

Related Questions