fhunleth

fhunleth

Co-author of Nerves

Zoneinfo - a TimeZoneDatabase that uses /usr/share/zoneinfo

Zoneinfo is a TimeZoneDatabase library for Elixir that reads OS-supplied TZif files from /usr/share/zoneinfo.

If you’re happy with Tzdata, Tz or TimeZoneInfo, then there’s no reason to change.

Zoneinfo addresses a need we had with Nerves to minimize code and data sizes on metered network connections. We found that the TZif files in /usr/share/zoneinfo compress really well and were easily tunable using the zic(8) compiler to remove date ranges we’d never use. An added size benefit was only having one copy of the time zone database since /usr/share/zoneinfo was already used by non-BEAM programs.

Zoneinfo works on Linux and OSX out of the box. The library has no dependencies. If you keep your OS patched, one hopes that your OS will also update these zoneinfo files from their IANA sources. Or, you could add something like apt install --only-upgrade tzdata -y to a crontab.

Will it return the right answer?

We tested Zoneinfo by brute force comparing its output to Tz’s within the supported date ranges of the TZif files. There are caveats:

  1. TZif files contain time change records that go from about 100 years ago to 2038 or 2050. It’s possible to calculate time changes outside of this range, but Zoneinfo currently doesn’t attempt this.
  2. Calendar.TimeZoneDatabase splits the overall time offset to the amount that gets you to standard time and then the DST offset. TZif files only have the overall time offset so Zoneinfo uses a heuristic to split it up. The heuristic currently disagrees with the split for Monaco and Paris in 1945 and Morocco. Since most conversions only require the overall time offset, this is a non-issue, but it is a discrepancy nonetheless.
  3. We assume that Tz is correct. Having reviewed many discrepancies while debugging Zoneinfo, I believe that Tz very accurately reflects the IANA Time Zone database rules and the many unusual time zone decisions that people have made over the past century.

If you are using Nerves and need local time for a clock display or for scheduling events, check out NervesTimeZones. It provides a small data base, makes NaiveDateTime.local_now return the expected time, and helps you pass the appropriate environment variables to non-BEAM apps so they use the right time zone.

Where Next?

Popular in Libraries Top

RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 11851 134
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
dbern
I’m excited to announce that TaxJar has developed and open-sourced DateTimeParser. We developed it because we found a need to parse user ...
New
woutdp
Hi! I wanted to introduce my latest project LiveSvelte. It allows you to render Svelte inside LiveView with end-to-end reactivity. It’s ...
New
aditya7iyengar
Rummage.Ecto and Rummage.Phoenix provide ways to perform Searching, Sorting and Pagination over Ecto queries and Phoenix collections. Fo...
New
martinthenth
Hello everybody :wave: Recently, some of my colleagues talked about database ids and uuids and their problems, and I remembered the pain...
New
vic
Expat is a tiny experiment I did for extracting patterns and being able to reuse them (compose and share patterns between elixir librarie...
New
mattludwigs
Grizzly is a library for working with Z-Wave devices. Z-Wave is a low-frequency radio protocol for controlling smart home devices on a me...
New
anshuman23
Hello all, I have been working on my proposed project called Tensorflex as part of Google Summer of Code 2018.. Tensorflex can be used f...
New

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list....
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New

Sub Categories:

We're in Beta

About us Mission Statement