Call for proposals: time zone support in Elixir

I only skimmed this so pardon if this has been said before, or if it isn’t exactly a problem.
also I use timex in a Nerves application, which pulls in the tzdata application. These are my only experiences with time libraries in Elixir other than the stdlib.

Firstly, i would love for stdlib to have timezone support, because that is the only reason i use/need timex. (I try not to use deps unless i really need them due to various constraints).

However, syncing the timezone database is something a little weird. tzdata downloads the package on a timer of some sort and writes it to disk. From what i know about the elixir stdlib, and a quick poke thru :observer, i don’t think there is anything else that does anything to this extent right now.

obviously defining a @behaviour as described above would alleviate this to some extent, even so i think implementing this at the stdlib level would be a little difficult and messy to cover all situations. (thinking from a Nerves point of view where the filesystem is read only, and network is not guaranteed.)

anyway sorry for that longwinded post, just wanted to express that blurb while this is being discussed.

I’m not sure if this would be bubble up to the interface level that we are discussing here–but how would that work in multi-node setups?

That’s why we don’t want to implement it in stdlib we want to define how a provider of time zone info should look like, so third party libraries can provide it, while the stdlib can offer functions that use it (and would error if no provider is specified). So you could have a nerves-specific provider that does something special.

Similar here. The stdlib doesn’t care how the provider gets the info - it might sync it in the cluster, sync it with some external resources (like current tzdata does) or compile it into modules (like old tzdata does) or do something I cant even think of right now.


As stated in the original post, this is not the thing we should be discussing here. How the provider will obtain the time zone database is beyond the scope of this discussion. We want only to explore what functions would require the time zone information and what would be the best interface for a library to expose it to stdlib.

4 Likes

Let it be known that @kip and I are collaborating together on a proposal. We’ll keep you posted :slight_smile:.

7 Likes

I have made a proposal that includes a behaviour and Elixir code that uses it, so that DateTime functions can be used to get the time in any time one and convert between timezones: https://github.com/elixir-lang/elixir/pull/7914

3 Likes

Hi @Qqwy and @kip, is a proposal still coming? In case it has been halted, what are your thoughts on the current proposal? Thanks. :slight_smile:

Hello, is anyone working on this? Is there currently a proposal?

I want to drop some links here.

EcmaScript TC39’s new date and time API proposal is in stage 2 currently:


https://tc39.es/proposal-temporal/spec-rendered

JSR-310, Java’s date and time API:
https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html

JS implementation of JSR-310 :


A more functional library for JS:

Here’s the behaviour: Calendar.TimeZoneDatabase — Elixir v1.16.0
And this is the module elixir ships with: Calendar.UTCOnlyTimeZoneDatabase — Elixir v1.16.0

tzdata does also ship an implementation of the behaviour, which does use the IANA timezone database.

This was released in elixir 1.8

2 Likes