Show HN: A Simple Server to Match Long/Lat to a TimeZone
40 ChrisMarshallNY 19 5/20/2025, 9:43:50 PM github.com ↗
I figured this might be useful to folks.
It's a simple PHP server that requires a single-table database (It's fairly "agnostic," but all my uses are in MySQL).
I won't publish any of the servers that I've set up for my apps, because someone is bound to write an application that drives my bandwidth into the stratosphere.
I could definitely take it further, but this gives me all I need for my purposes.
Here's an app I wrote, that uses it: https://apps.apple.com/us/app/we-are-never-alone/id650482602...
If you'd like to avoid shipping a giant geojson, with the generosity of CDN providers you can actually hit the npm-hosting servers with HTTP Range requests and do this completely on demand from the client: https://github.com/kevmo314/browser-geo-tz
So I guess it's a bit of a lie that it's only geojson :)
The way it works is you load the index file which contains the large regions (in other words, the first level or two of the quad tree) and if the time zone can't be resolved, it relies on querying the data file which is actually a multi-record protobuf file so you can load the specific range of data you're looking for. The algorithm is here: https://github.com/evansiroky/node-geo-tz/blob/master/src/fi...
Here's the step that resolves individual tree nodes: https://github.com/kevmo314/browser-geo-tz/blob/main/src/fin...
- Go: https://github.com/ringsaturn/tzf - Rust: https://github.com/ringsaturn/tzf-rs - Python: https://github.com/ringsaturn/tzfpy - Swift: https://github.com/ringsaturn/tzf-swift - Wasm(browser only): https://github.com/ringsaturn/tzf-wasm - PostgreSQL extension: https://github.com/ringsaturn/pg-tzf
Or online preview: <https://ringsaturn.github.io/tzf-web/>.
Here is a blog post about the packages history: https://blog.ringsaturn.me/en/posts/2023-01-31-history-of-tz...
I just figured it might be useful. One reason that I wrote it, was because I couldn't find a decent SaaS that didn't charge eye-watering prices, for a fairly slow response. I wrote it in an afternoon or two. Not really an ambitious project.
I don't usually do "Show HN." Not interested in competing with anyone. If you like it, use it. If you don't like it, don't use it. If there are clear bugs, I'm always open to feedback.
[0] https://github.com/evansiroky/timezone-boundary-builder
Seems to have changed pricing a bit since. The 'pay as you go' model now has 2500 API calls/day for free, and $1/2000 API calls after that. My needs never grew in to needing much more than what we hit for that $5/month, so I can't vouch for their service at a large scale, but I enjoyed using it.
No affiliation just a happy former customer.
Might add up.
thanks for sharing your tool!
This is static data that only needs to be updated once or twice a year. Why not just make this an npm or py module
There’s a reason that there’s so little support for this kind of thing out there. It’s deceptively simple.
I’m a Swift app developer, not a backend guy. I just need a system that delivers the data I need, at an acceptable performance, and this does it.
It’s part of a system that aggregates about 35,000 records, from about 50 servers, and scrubs a lot of really filthy data. This part is for adding missing timezone info.
The deal is about “frontloading” all the data scrubbing, so that the system can quickly return an arbitrary amount of uniform data, on demand, and that can run on the cheapest hosting possible, without a need for tecchies.
It works a treat.
I found a project that is under active development, that generates a very precise shapefile, and figured out how to use it.
I load a database, as opposed to doing shapefile parsing on the fly, for performance reasons.
The magic juice is the domain rect. It’s a superfast triage, that gets us into the ballpark, and then I use a fast winding number test, to get precise.
I think that I could probably do a whole lot to optimize it, but PHP/SQL is not my forte, so I kept it simple. It works great for the manner in which I use it.
The unit tests have a lot of points, close together, on either side of a TZ boundary. The edges are where the Devil lives.
Thanks for bringing up https://github.com/evansiroky/timezone-boundary-builder !