Looking at their checkin api when you add a checkin it does not require passing in any datetime or timezone information, but when you query a users checkin history it returns a timezone field indicating the timezone of where the checkin took place. I imagine somehow they’re looking it up by lat/lng or something. Does anyone know specifically how they’re doing it?
Share
It’s most certainly a location-based look up against the check-in location.
My guess is that they compute and cache the timezone for a venue when it is created. I’d store this information as a map of tuples to strings keyed on data like city,[state],country in a distributed hash table database like memcached. I’d keep bounding polygons available for each timezone (as well as many other geographic data) and provide a service for querying it based on lat/lon. This is typically called a geocoding service. Depending on memory constraints and usage variability, I’d populate the tuple mapping from this service lazily (ie, only as users request it).
For venueless check-ins they probably compute it once based on the lat/lon and cache this information for a shorter period of time in case others perform check-ins to the same location. I’d bet that they also routinely take advantage of the fact that the timezone field is optional and don’t populate it if the geocoding service is overloaded.
If you’re looking for a service which can handle these kinds of queries, check out http://www.geonames.com (documentation).