Not sure what I'm doing wrong here. I am trying to get the current UTC # hour offset for East Australia. The code I use is returned from GMT + 10 hours, while it should be 11, since they are in DST at the moment.
This is what I use to get it:
With TimeZoneInfo.FindSystemTimeZoneById("E. Australia Standard Time") Console.Write(.GetUtcOffset(Now.ToUniversalTime).Hours) End With
It seems to derive a "base" offset, apart from the DST. How to get the actual current offset that DST takes into account?
Update 1 in response to jlew's suggestion. I tried to get IsDaylightSavingTime, but this seems to give inconsistent result. I know that both East Australia and New Zealand are currently in the summer.
However, the following returns FALSE (incorrect):
TimeZoneInfo.FindSystemTimeZoneById("E. Australia Standard Time").IsDaylightSavingTime(Now.ToUniversalTime)
And returns TRUE (correct):
TimeZoneInfo.FindSystemTimeZoneById("New Zealand Standard Time").IsDaylightSavingTime(Now.ToUniversalTime)
Update 2 . After looking at this post, I checked IsAmbiguousTime, but in both cases it is False. So this is not “ambiguous,” but the “E. Australia” zone does not use DST when it should be.
Update 3 After watching this message, I installed the Dec 2011 cumulative DST update from MS, but there was no joy. Zone E. Australia is still incorrect.
I also tried running the code on two other servers with the same result. Mine -.net v3.5, the rest - v4.
Update 4 Well, I might have decided. Looking through the list of system time zones again, I noticed another name for the zone for East Aus. It was called Eastern Standard Time AUS. Using this zone, it gives the correct result, different from DST. Use "standard time E. Australia" no.
A search around seems to make a perverse kind of sense, since different cities in the same time zone of the same country may have different DST rules. Who allowed them to do this?
This is a problem that does not have a global map of which zone identifiers apply to those cities. Of course, this is not so difficult for MS. The DisplayName property can be used to display a list that users can select, but if the application needs to convert the time from one city to another, it needs to somehow find out which identifiers these cities should use.
If MS included City-to-ZoneID search, at least for large cities, time zones would require a lot of trouble.