|
This C# library for the Microsoft .NET Framework is based on an existing library by Anson Goldade (original version
available from GotDotNet) and discussed in this forum thread. Anson's library is very capable but I needed to make a few changes to the classes to properly support my application.
This library is necessary because neither the System.Globalization namespace nor the System.TimeZone class support any TimeZone information except for the local machine settings. No conversions between different time zones are possible with either 1.0 or 1.1 of the .NET Framework. This library makes use of Win32 API functions documented in the Microsoft Platform SDK.
Anson's original description:
Converts local time in one time-zone to local time in another (or UTC). Resembles the TimeZone object in .NET but adds the conversion functions. Uses WindowsAPI functions on the platforms where they are available and when not available, the calculation is done manually.
The original library implements a C# struct for most functions because the struct is required for compatibility with the Win32 API calls. This struct is extremely well done but proves unwieldy when new fields and properties need to be added. For my needs, I have kept the original struct but moved almost all of its functionality into a new class. I keep the struct only as a means for compatibility with the Win32 API's. The new class contains the struct as a private member and adds a name member, ToString() function, CompareTo() functions, IComparable interface plus a few small bug fixes. Adding the name property allows a TimeZoneInfo object to provide a Daylight Savings Time neutral name. Hopefully Anson will incorporate some of these changes into his next release.
There is still a lot of room left for improvement in my additions to these C# classes. I hope to add serialization support in the near future as well as some much needed error checking.
|