Skip to content

Latest commit

 

History

History
21 lines (11 loc) · 1.39 KB

README.md

File metadata and controls

21 lines (11 loc) · 1.39 KB

So you never again have to say “It’s 5 o’clock somewhere…”

If you dig it, consider tossing some 🍺💰 my way: venmo.com/segdeha

colophon

It was weirdly hard to answer the question, “where is it currently 5 o’clock?” I ended up cobbling together a solution using a couple of different data sources and a bit of scripting.

I start by calling the GET /list-time-zone endpoint on TimeZoneDB.com to get the current time in each time zone around the world.

I then loop through the results and pull out each time zone (America/Los_Angeles, Europe/Andorra, Antarctica/McMurdo, etc.) where the current hour is 17 (i.e. 5pm).

Next, I query a simple database consisting of 2 tables, one containing 24,297 cities with their associated time zones, the other that’s used to look up country names from country codes, the data for both coming from geonames.org.

Finally, I cache the JSON response I send back to the browser so it’s regenerated at most once every half hour.

Super simple, but it works! ¯\_(ツ)_/¯

The spinning globe was, um…borrowed from a blog post by Bjørn Sandvik.