Problems getting correct time zone abbreviation

Topics: Developer Forum, User Forum
Aug 28, 2007 at 3:42 AM
I am writing code in VB.NET and I am having problems getting the correct time zone abbreviation for dates that are not during daylight savings time. For instance I run the following code:

Dim startDate As Date = "1/1/2008 12:00:00"
Dim abbrev As String
abbrev = PublicDomain.TzTimeZone.GetTimeZone("America/Denver").GetAbbreviation(startDate)

This code should set the abbrev variable to MST because 1/1/2008 is not during daylight saving time. However a value of MDT is returned. I would appreciate any assistance in getting this issue resolved. Thanks
Coordinator
Sep 1, 2007 at 2:45 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Sep 8, 2007 at 3:40 AM
This is a bug, thank you! Sorry it took me so long to come around to this. I will be fixing this in release 0.2.16.0...
Coordinator
Sep 8, 2007 at 11:53 PM
This should be fixed in release 0.2.16.0: http://www.codeplex.com/publicdomain/Release/ProjectReleases.aspx?ReleaseId=6962

Thanks!
Mar 28, 2008 at 9:07 PM
Hi schizo,

I'm sorry but I think this bug is still alive... or ?

sample code:
public void getDaylightChanges()
{
foreach (string zName in TzTimeZone.AllZoneNames)
{
string z1Name = zName;
//z1Name = "Pacific/Easter";

int startYear = 2007;
int endYear = 2008;

TzTimeZone zone = TzTimeZone.GetTimeZone(z1Name);

DaylightTime daylightTime;
while (startYear <= endYear)
{
daylightTime = zone.GetDaylightChanges(startYear);
if (daylightTime != null)
{
// pb reports dst start/end for any z1Name for any startYear, although z1Name has no active dst for startYear ???
// see orig TzTimeZoneTests.DaylightChanges()
// ergo filter:
if (daylightTime.Start != daylightTime.End)
{
Console.WriteLine(z1Name + ";" + daylightTime.Start + ";" + zone.GetAbbreviation(DateTime.Parse(daylightTime.Start.ToString())) + ";" + zone.GetUtcOffset(daylightTime.Start).ToString() + ";1");
Console.WriteLine(z1Name + ";" + daylightTime.End + ";" + zone.GetAbbreviation(DateTime.Parse(daylightTime.End.ToString())) + ";" + zone.GetUtcOffset(daylightTime.End).ToString() + ";0");
}
}
startYear += 1;
}
}
}

zone.GetAbbreviation and zone.GetUtcOffset return wrong values
e,g.: (tzData2008b)

Zone Pacific/Easter
...
-6:00 Chile EAS%sT

Pacific/Easter links to Rule Chile
Rule Chile 1999 max - Oct Sun>=9 4:00u 1:00 S
Rule Chile 2000 2007 - Mar Sun>=9 3:00u 0 -
Rule Chile 2008 only - Mar 30 3:00u 0 -

publicdomain result:
Pacific/Easter;13.10.2007 22:00:00;EASST;-05:00:00; isDST = True
Pacific/Easter;29.03.2008 21:00:00;EASST;-05:00:00; isDST = False
Pacific/Easter;11.10.2008 22:00:00;EASST;-05:00:00; isDST = True

should be:
Pacific/Easter;13.10.2007 23:00:00;EASST;-05:00:00; isDST = True
Pacific/Easter;29.03.2008 21:00:00;EAST;-06:00:00; isDST = False
Pacific/Easter;11.10.2008 23:00:00;EASST;-05:00:00; isDST = True

Africa/Johannesburg has no dst in 2007/2008
Zone Africa/Johannesburg
...
2:00 SA SAST

Rule SA 1942 1943 - Sep Sun>=15 2:00 1:00 -
Rule SA 1943 1944 - Mar Sun>=15 2:00 0 -

Africa/Johannesburg;16.09.2007 02:00:00;SAST;03:00:00; isDST = True
Africa/Johannesburg;16.03.2008 02:00:00;SAST;03:00:00; isDST = False

should be nothing....

America/Argentina/Buenos_Aires;16.03.2008 00:00:00;ART;-02:00:00; isDST = False
America/Argentina/Buenos_Aires;05.10.2008 00:00:00;ARST;-02:00:00; isDST = True

should be
America/Argentina/Buenos_Aires;15.03.2008 23:00:00;ART;-03:00:00; isDST = False
America/Argentina/Buenos_Aires;05.10.2008 01:00:00;ARST;-02:00:00; isDST = True

any idea ?

cheers Stefan
Coordinator
May 6, 2008 at 12:43 PM
Hi Stefan, yes, I think this bug is still alive. Unfortunately I can't find the time to "context switch" my brain back into the olson stuff, so I'm not sure when I'll be able to work on this. Sorry, Kevin