3 ms·
My recommendation is actually to store the local time and the exact location, if you can get it. Then use that location to determine the correct timezone. Some
by simonw 2y ago
My recommendation is actually to store the local time and the exact location, if you can get it. Then use that location to determine the correct timezone.
Some users may not know that their Timezone is America/Los_Angeles but they should hopefully know where their venue is.
You always treat the local time - 6pm on 5th December in Boise, Idaho - as the core truth and derive the UTC version from that. Then if Idaho decide to cancel daylight savings time you can update your calculated and stored UTC timestamps to the correct values.
- mixmastamyk 2y agoHmm, some hard parts for automation left unsaid. > use that location to determine the correct timezone Does this mean consult an "address to timezone lookup service?" Not sure if they exist, and I don't see another way without user specifying manually. Maybe a string match, but it could be wrong/unsure somewhat often. > Then if Idaho decide to cancel daylight savings time you can update Looking up events within a time interval is easy enough, those in city (timezone?) limits not so much. Consult a GIS system, search within polygons??? String match or every city in your database?
- simonw 2y agoThey do exist: many geocoding APIs (address to lat/lon) can optionally return a timezone as well, like this one: https://opencagedata.com/api#forward-resp https://opencagedata.com/api#forward-resp Or you can get a latitude/longitude and derive the timezone from that - I built an API for that here https://timezones.datasette.io/timezones/by_point?longitude=-116.23&latitude=43.61 https://timezones.datasette.io/timezones/by_point?longitude=...
- mixmastamyk 2y agoDanke. I wonder about making one's business dependent on such services however.
- simonw 2y agoIt's possible these days to run an entirely open source geocoding stack of your own. Here's one of the better options for that: https://github.com/osm-search/Nominatim https://github.com/osm-search/Nominatim I wouldn't recommend it though: it needs a beefy machine and applying updates on an ongoing basis is fiddly. Better to use a commercial option and have that as an escape hatch.