With the source code that is available, can we recompile the historical DST data and TZ rules class(es) ourselves? Which Olson database files are the tools compatible with? IOW, which files do we need to recompile the classes?
Is the project itself available? Are there any existing test pages or tools for testing the functionality?
Aug 10, 2007 at 6:21 PM
Hi Mario, Thanks for the question. I've gotten this question a few times before so it's good to put an answer here.
1. Can we recompile the historical DST data and TZ rules class(es) ourselves.
Yes. First, just to recap how PublicDomain converts the tzdatabase into something that it uses, here is the design:
- tzdata is downloaded from ftp://elsie.nci.nih.gov/pub/
- The PublicDomain Project has the following structure:
- tzdata (Solution folder)
- Contains the data downloaded in step 1
- PublicDomain (C# DLL project)
- This is all of the main code. All source files in this project are packaged into the setup file and installed onto the user's computer.
- PublicDomainTests (C# DLL project)
- NUnit tests including unit tests and regression tests
- PublicDomainConsole (C# Console project)
- A simple test harness to use to print some usage of PublicDomain
- PublicDomainSetup (.NET Setup project)
- The project that creates PublicDomain.msi
So, that is the project structure. Once tzdata has been updated, the next step in the design is to run an NUnit Test in PublicDomainTests which will create C# code which is placed into PublicDomain.
The main method to run is PublicDomainTests/TzDatabaseTests.cs, method ReadDatabase().
This will emit C# code representing all of the zones and rules in the TZ database in objectified format (using two classes, TzDatabase.TzRule and TzDatabase.TzZone).
This code is then placed into PublicDomain/TzTimeZone.cs. The code emitted is simply a static initializer marked by the region "#region Generated Time Zones."
This whole process has been automated with the PublicDomainTests/TzDatabaseTests.cs, method ExecuteReplaceData(). This will run ReadDatabase, and then actually modify TzTimeZone.cs, replacing the old static initialization.
- Once TzTimeZone.cs has been updated, a simple build makes the new tzdatabase used.
- To recap, all we do is convert the tzdatabase into C# code which is then placed into the static initializer of the TzTimeZone class and the whole project is built.
- The interesting aspect to this is that any user of PublicDomain can use the TzDatabase class to read the database at run time and do various analysis.
2. Which Olson database files are the tools compatible with?
The tools do not work on the code (tzcode), only the tzdata archive. All files without an extension are the data files (e.g. africa, northamerica, etc.). The iso3166.tab file can also be parsed by the TzDatabase class, but we don't really use that for anything.
3. IOW, which files do we need to recompile the classes?
I'm not sure what you mean exactly? If you're talking about PublicDomain, simply recompiling the PublicDomain project which includes TzTImeZone.cs will do the trick.
4. Is the project itself available?
Yes, you can download the whole solution from the Source Code tab:
5. Are there any existing test pages or tools for testing the functionality?
All of the tests are in NUnit form in the PublicDomainTests project. I've added regression tests for the work item you brought up in TzDateTimeTests.cs.
I like to use TestDriven.NET (http://www.testdriven.net/) to do testing, since I can just right click on a single NUnit Test, the whole class, or the whole project and do "Run Test(s)." Before I commit any changes, I always run all tests in the PublicDomainTests
project by right clicking on it in the solution explorer and hitting "Run Test(s)." This is also how I updated the olson time zone database into the code, simply by right clicking within PublicDomainTests/TzDatabaseTests.cs, method ExecuteReplaceData().
I'm curious about whether this project is being maintained and what the current status is wrt bugs. I'm desperately looking for the time zone functionality that's missing from .NET 2, but had a bit of trouble with the instructions outlined above
(the assertions in TzTimeZoneTests.Bug13252a aren't right and couldn't have possibly been verified).
Apr 18, 2009 at 9:51 PM
Hi, sorry but this project is no longer under active development. The effort was part of a for-profit venture which is in hibernation. The source code is available and there were also some patches people had made to get it working as attachments in the
bugs, although I never tested them myself and never fixed/added assertions to fix the bugs.
There is also this alternative:
I have been out of the space for some time so I'm not aware if there are other alternatives. I don't see anything new @ http://www.twinsun.com/tz/tz-link.htm
Good luck! Let us know how you solve your problems...