package module
v0.0.0-...-f3db6d0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2017 License: Apache-2.0 Imports: 10 Imported by: 33


This is a Go package which maps a (lat, long) to a timezone.

My motivation was figuring out the UTC time of a JPG with EXIF
metadata containing GPS coordinates and local time, but no timezone
offset. This is a surprising number of photos. I built this to
improve sorting in Camlistore, especially when photos are intermixed
with tweets, checkins, etc, but it should be generally applicable.

See docs at

It tries to have a small binary size (~360 KB), low memory footprint
(~1 MB), and incredibly fast lookups (~0.5 microseconds). It does not
try to be perfectly accurate when very close to borders.

To rebuild the data files, see the Makefile (or just run make).
You'll need the data files unzip to the "world" directory.

Some background:

Another image of the underlying data structure:

... the tile borders are only there for debugging, to show areas with
only one timezone. Tiles without borders around them still work; at
that level, the small possible bitmap is used for lookup.



Package latlong maps from a latitude and longitude to a timezone.

It uses the data from compressed down to an internal form optimized for low memory overhead and fast lookups at the expense of perfect accuracy when close to borders. The data files are compiled in to this package and do not require explicit loading.



This section is empty.


This section is empty.


func LookupZoneName

func LookupZoneName(lat, long float64) string

LookupZoneName returns the timezone name at the given latitude and longitude. The returned name is either the empty string (if not found) or a name suitable for passing to time.LoadLocation. For example, "America/New_York".


This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL