reading Historical Data

Topics: Developer Forum, User Forum
Mar 3, 2008 at 9:56 PM
Hi all,

I 'm trying to get historial TimeZone Information for e.g. Europe/Berlin:
e.g. for year 1900
Dim zone As TzTimeZone = TzTimeZone.GetTimeZone("Europe/Berlin")
Dim theYear As Integer = 1900
Dim dayLight As DaylightTime = zone.GetDaylightChanges( theYear, DateTimeKind.Utc )
Dim abbrevStart As String = zone.GetAbbreviation( dayLight.Start ).ToString
Dim startUTCOffSet As String = zone.GetUtcOffset( dayLight.Start ).ToString

returns dayLight.Start = #3/25/1900 2:00:00 AM#, should be nothing cause in 1900 there was no DST Rule
returns abbrevStart = CET, should be LMT
returns startUTCOffSet = 02:00:00, should be 0:53:28

I've also tried to use the PublicDomain.TzTimeZone.TzZoneInfo.HistoricalData Property but ... what to do with this ?? ... looks like the orginal tz data !?
can someboby post some samples/ideas to help me out of my dilemma ?

cheers StarSteve

Mar 4, 2008 at 1:32 AM
hmm, after digging into TzTimeZoneTests.cs I see the System.Globalization Daylight class utilised, which uses the Windows TimeZone database/registry but not the olson db to lookup Daylight Change dates ?! confusing....

e.g.
foreach (string zName in TzTimeZone.AllZoneNames)
{
TzTimeZone zone = TzTimeZone.GetTimeZone(zName);
DaylightTime daylightTime = zone.GetDaylightChanges(1894);
if (daylightTime != null)
{
Console.WriteLine(zName + "\t" + daylightTime.Start + "\t" + zone.GetAbbreviation(DateTime.Parse(daylightTime.Start.ToString())));
Console.WriteLine(zName + "\t" + daylightTime.End + "\t" + zone.GetAbbreviation(DateTime.Parse(daylightTime.End.ToString())));
}
}

sorry, but the generated list is absolute nonsense !?
same for 1940 or 1965 etc.

' Note: In the en-US culture, all start dates are calculated from
' the first Sunday in April, based on a standard set in 1986. For
' dates prior to 1986, the calculated start date may not be accurate.

how can I bypass the Windows TimZone db - any ideas ???

cheers StarSteve

Coordinator
Mar 8, 2008 at 7:52 PM
Hey StarSteve,

For your first post, your code should work which means there's a bug in PublicDomain for getting the daylight info for Berlin in that year. I'm so deluged with work unrelated to this project, I may not be able to get to it for some time, but I will try to fix it when I can.

For your second post, I'm not sure what you mean -- I couldn't find any use of the .NET time zone information in the tests there. TzTimeZone is a subclass of the .NET TimeZone class and overrides the GetDaylightChanges method (see line 281 of TzTimeZone.cs). All of the daylight changes returned are from the Olson Database data.

Any errors you see are bugs. If you need any help digging into the code yourself, please feel free to email me directly, and I'm glad to help you wade through the code. Otherwise, it might take some time for me to get around to these bugs...

Thanks!
Kevin