fireproofsocks

fireproofsocks

Querying for Timezones in Timex or some other library?

I’ve often found it helpful to be able to reference timezones for humans using an app. E.g. we have a database record for a person or a store location and we want to know what timezone they are in.

When I use Timex, I see that it updates “tzdata” constantly in little files named something like 2018e.ets. Is there any way I can search or reference that data? For BI/UI/transparency purposes, I’d prefer to have it available in a relational database, but I’ve never been able to figure out how to do that. Even MySQL had internal timezone tables somewhere. Does anyone know how to get at that data? E.g. say I want to do an auto-complete on a form field or reference the timezone as a foreign key constraint. Possible?

Most Liked

blatyo

blatyo

Conduit Core Team

The data comes from here: https://www.iana.org/time-zones

easco

easco

It looks like Timex depends on another project called tzdata. That project includes functions that let you query time zone data.

iex(2)> Tzdata.zone_list()
["Africa/Abidjan", "Africa/Accra", "Africa/Addis_Ababa", "Africa/Algiers",
 "Africa/Asmara", "Africa/Asmera", "Africa/Bamako", "Africa/Bangui",
 "Africa/Banjul", "Africa/Bissau", "Africa/Blantyre", "Africa/Brazzaville",
 "Africa/Bujumbura", "Africa/Cairo", "Africa/Casablanca", "Africa/Ceuta",
 "Africa/Conakry", "Africa/Dakar", "Africa/Dar_es_Salaam", "Africa/Djibouti",
 "Africa/Douala", "Africa/El_Aaiun", "Africa/Freetown", "Africa/Gaborone",
 "Africa/Harare", "Africa/Johannesburg", "Africa/Juba", "Africa/Kampala",
 "Africa/Khartoum", "Africa/Kigali", "Africa/Kinshasa", "Africa/Lagos",
 "Africa/Libreville", "Africa/Lome", "Africa/Luanda", "Africa/Lubumbashi",
 "Africa/Lusaka", "Africa/Malabo", "Africa/Maputo", "Africa/Maseru",
 "Africa/Mbabane", "Africa/Mogadishu", "Africa/Monrovia", "Africa/Nairobi",
 "Africa/Ndjamena", "Africa/Niamey", "Africa/Nouakchott", "Africa/Ouagadougou",
 "Africa/Porto-Novo", "Africa/Sao_Tome", ...]
NobbZ

NobbZ

You can get a list of timezones as it was shown already, you can use those in your DB as you like.

But thats not actually timezone data.

TZdata is a historic collection about when timezones changed. When leap seconds have been added, when timezones got deleted or created. When regions denied to switch to DST. etc, etc. Nothing what you could use as a key.

But you can query this information directly, just look at the API of the TZdata package you use.

Where Next?

Popular in Questions Top

tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement