TimeZoneInfo - just another TimeZoneDatabase


TimeZoneInfo is just another TimeZoneDatabase.

Motivation: Before Tz was released my motivation was to fix some things in Tzdata. So TimeZoneInfo includes all fixes that are also in Tz and mentioned in this post. After Tz was released I keep on coding because I have some different approaches and I wanted to play with :persistent_term, :ets, NimbleParsec, and ETF (Erlang Term Format).

The most differences to the other both libraries are mentioned in the last section, but here are some details.

Some benchmarks to compare TimeZoneInfo, Tz, and Tzdata.

TimeZoneInfo uses NimbleParsec to parse the IANA data. The parsed data is related to the pure IANA data, which means it should be easy to write this data back to a valid IANA file. After that, this data will be transformed into a TimeZoneInfo.data format.

The data will be persisted in the priv dir in a zipped ETF format. If you want to save the data in another way you can configure this as you need.

At runtime, the data can be stored in two different ways. Either with :persistent_term (OTP >
21.2) or with :ets. That can be also configured as data_store: :detect (default), in this case TimeZoneInfo will select :persistent_term if it is available.

An automatic update is supported but is disabled by default. The downloader for the update is configurable and custom downloader can be used. It is also possible to download directly TimeZoneInfo.data in a zipped ETF file.

Furthermore, you can configure which time zones should be used and how many years should be calculated in advance.
For time zones with continuation rules transitions in the future will be calculated on the fly if the periods-table does not contain enough info for those date times.

Thanks for your attention.

Comments, critic, reviews, issues and PRs are welcome!


TimeZoneInfo 0.4.0 is released.

In this release, the format for the Downloader is changed to mode. Possible modes are :iana, :etf, and :ws. The mode :ws is new and is used for fetching data from a web service. For now, such a web service exist just as an example at time_zone_info/examples/time_zone_info_server.
The advantage of the new mode is, that the transformation of the IANA data happens on the server.

I have also added a clock example that is using the example server.

This asciinema screencast shows the examples in action.

I’m wondering if a :os mode would be possible on unix machines using Tzinfo - Parsing the time zone information format (zonefiles)

Maybe, I’ll check it out.

Hello, @LostKobrakai . I have taken a look in the TZif data, and if I understand it right (and please correct if I misunderstood it) is here the offset for a period utc-offset + std-offset. But the callbacks in TimeZoneDatabase want std-offset and std-offset separated (time_zone_period).

Yeah, it seems it’s not divided up in those files.

Version 0.5.0 is released. The new version comes with some performance improvements and some bugfixes.
I have also added a benchmark to compare the DataStores with :ets and :persistent_term. The benchmark to compare TimeZoneInfo, Tz, and Tzdata is using the DataStore with :persistent_term.

1 Like