Historical daylight savings in Windows

女生的网名这么多〃 提交于 2019-12-22 12:16:42

问题


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.


回答1:


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.

Edit: The project mentioned above seems empty, so I searched further and found the Delphi TimeZone Database project to be still active.

--jeroen




回答2:


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...




回答3:


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



来源:https://stackoverflow.com/questions/3464499/historical-daylight-savings-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!