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 Announcing Top

sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
mischov
import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story <- Meeseeks.all(html, css("tr.athing")) do...
New
josevalim
Hi everyone, We would like to announce that Plataformatec is working on a new MySQL driver called MyXQL. Our goal is to eventually integ...
New
Crowdhailer
The latest release of Ace (0.10.0) includes serving content over HTTP/2. I have started writing a webserver to teach my self more about...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
384 14136 119
New
Crowdhailer
Experimenting with this code. OK.try do user <- fetch_user(1) cart <- fetch_cart(1) order = checkout(cart, user) save_orde...
New
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 12645 134
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
mindok
What is ContEx? A pure Elixir server-side data plotting/charting library outputting SVG. It has nice barcharts in particular and works g...
New
michalmuskala
Hello everybody. I have just released Jason - a new JSON library. You might be wondering, why do we need a new library? The primary foc...
New

Other popular topics Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41989 114
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
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement