Skip to main content

Haskell Time Zone Library backzone Support

This weekend, a developer of a date and time library that is used with old versions of Java published a blog post titled “Big problems at the timezone database.” There was a discussion on Hacker News as well as a discussion on /r/haskell.

The time zone database officially keeps accurate time zone information from 1970, but some time zones include older information. There are rules for managing the database, including a rule that locations with the same time zone information must use the same time zone, designated by the city in the zone with the highest population.

The issue is that there are some locations that have the same time zone information since 1970 but use separate time zones because the time zone information before 1970 differs. Under the banner of “fairness,” the database is being changed by removing the pre-1970 time zone information so that the locations can use the same time zone in accordance with the rules. Unfortunately, this causes problems for people who use the changed time zones, even in cases when pre-1970 time zone information is not used.

Personally, I am disappointed that these changes because it unquestionably decreases the usefulness of the database to remove information that is known to be accurate. I wish that the database would instead provide metadata about the accuracy of time zone information per time zone, in addition to the current mandate of having accurate time zone information since 1970 for all time zones. I am also surprised that these changes are being pushed through since they introduce problems in existing code, as demonstrated in the above blog post.

Interestingly, the old time zone information is stored in a separate “backzone” file when it is removed from the primary database. This file comes with warnings that it contains time zone information that may be inaccurate. When building (“binary”) zoneinfo files, one can optionally include the time zone information in the backzone file. Since the backzone file contains time zone information that may be inaccurate, it is generally not included. One cannot rely on this information being available in the /usr/share/zoneinfo directory.

As described in Cross-Platform Time Zones in Haskell, I have tentative plans to create a package that caches time zone information for use on platforms without /usr/share/zoneinfo data. The general idea is as follows:

  1. Download the time zone information
  2. Build the C software that builds the binary zoneinfo files
  3. Run that software to build the binary zoneinfo files
  4. Use Template Haskell in an “internal” package to load the time zone information
  5. Copy the Template Haskell splices to the actual package, so that it does not need the build-time dependencies

Since the upstream time zone information is used and the binary zoneinfo files are built locally, it would be possible to include the backzone information. For example, a single library could provide time zone information both with and without the backzone information, or separate libraries could be used. This would provide a way for Haskell developers to use the backzone information even though it is generally not available on the host.

It is unfortunate that the accurate time zone information that is being removed is being stored with time zone information that is presumably inaccurate, however. Because of this, one may want to avoid backzone information completely. I am therefore not planning on providing support for backzone information in the library. This blog entry as well as my comment on Reddit documents the idea, however, so it will hopefully be found if anybody needs backzone information in the future and wonders how to implement it.

Author

Travis Cardwell

Published

Tags
Related Blog Entries