views:

54

answers:

3

Is there a easy way in Windows (using Delphi, not .NET) to convert UTC times to a local time, with daylight saving adjustments.

Data goes back 12 years, so needs to take account of changes in DST start/end dates over that time.

+2  A: 

Windows does not store historical data, you will need to use a database such as the tz database. I couldn't find any Delphi code listed on that particular page, but there might be some floating around. Otherwise, you'll have to port it from one of the languages that are currently supported...

Dean Harding
A: 

How about: Convert UTC string to TDatetime in Delphi

Also, there is some discussion and Delphi code for doing this at: http://www.tek-tips.com/viewthread.cfm?qid=1486209&page=1

And you can find a fair bit on this with a Google search for: utc local delphi

lkessler
A: 

Funny, a very similar question appeared yesterday on LinkedIn.

This is the answer I gave there:

Time Zones are somewhat fluid, especially when Daylight Saving Time starts/finishes.

This database ( http://en.wikipedia.org/wiki/Tz_database ) defines the time zones, and it changes sometimes, so you need an update mechanism as well.

There is a .NET implementation that you could wrap, or use as a base: http://www.codeproject.com/KB/locale/zoneinfo_dotnet_api.aspx

I'm not sure how up to date this Delphi implementation is: http://sourceforge.net/projects/delphitz/

Let us know your final implementation.

--jeroen

Jeroen Pluimers
Thx, looks like the Delphi implementation will serve as a basis. Was hoping I wouldn't have to roll my own...
John McC