Skip to content

13rac1/tzcoord

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tzcoord

Go library that maps IANA timezone names to the approximate geographic coordinates of their reference cities.

Coordinates are parsed from the IANA timezone database zone1970.tab file, embedded at build time via go:embed. No runtime dependencies or network access required.

Install

go get github.com/13rac1/tzcoord

Usage

// Look up by timezone name
coord, ok := tzcoord.Lookup("America/New_York")
// coord.Lat = 40.7142, coord.Lon = -74.0064

// Auto-detect from system timezone
coord, err := tzcoord.LookupLocal()
if err != nil {
    log.Fatal(err)
}

LookupLocal detects the system timezone via $TZ, /etc/localtime symlink, or time.Local. Works on macOS and Linux.

Updating zone1970.tab

Download the latest from IANA:

curl -o zone1970.tab https://data.iana.org/time-zones/data/zone1970.tab

License

Apache 2.0

About

Go library that maps IANA timezone names to the approximate geographic coordinates of their reference cities

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors