pdamoc

pdamoc

Is there a library that allows one to get the timezone from city+zipcode combo?

I need to translate a time that I have in a known timezone to a time in a location for which I know the city and zipcode.

Is there a library that already does this?
If not is there a free online service/API that could be used to solve this?
If not, how do you suggest to approach this task?

The cities are all in USA but I don’t live in USA. Maybe there is some official database that I can use.

Most Liked

andrewb

andrewb

Hi,

I ended up using the Google Maps API and having a field for user to search for their City. I then extracted the timezone and other location data I needed.

I could not find a reliable alternative.

If this is an option let me know and I can post some code (However it is just javascript on the client as per the docs).

Andrew

PS: not free but low cost

hauleth

hauleth

You can use GeoNames to fetch position from the zip code, however I wouldn’t rely on that too much, because people can use different TZ than their “local” one (for example they are dealing with customers in different TZ, and it is easier for them to use TZ of the client). So I would rather ask - what for you need that?

kip

kip

ex_cldr Core Team

The tz_world packages translates a geo point (a location with a lat, lng) into a timezone using map data from osm and timezone data from iana. So if you can translate a place into a location (with geonames for example), then tz_world will give you the timezone name. Its very cool.

Note that tz_data on hex requires ecto and postgres with postgis, but the master branch on GitHub does not and the author has indicated he will publish that version to hex this week.

tme_317

tme_317

I have found this data (which I use in my project) to be accurate and relatively low cost: https://www.zipinfo.com/products/z5p/z5p.htm

Google maps API could work but check the cost/TOS restrictions.

pdamoc

pdamoc

It is exactly one of these solutions that we’re implementing. Our app should display the time in the TZ of the client.

Thank you all for the suggestions. I will propose these solutions to my contact.

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
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
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
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
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New

Other popular topics Top

Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
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
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
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
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
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
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement