Documentation
¶
Overview ¶
Package localtimezone provides timezone lookup for a given location
Features ¶
* The timezone shapefile is embedded in the build binary using go-bindata
* Supports overlapping zones
* You can load your own geojson shapefile if you want
* Sub millisecond lookup even on old hardware
Problems ¶
* The shapefile is simplified using a lossy method so it may be innacurate along the borders
* This is purely in-memory. Uses ~50MB of ram
Index ¶
Constants ¶
const MockTimeZone = "America/Los_Angeles"
MockTimeZone is the timezone that is always returned from the NewMockLocalTimeZone client
const TZBoundaryVersion = "2022f"
TZBoundaryVersion is the version of tzdata that was used to generate timezone boundaries
Variables ¶
var ErrNoZoneFound = errors.New("no corresponding zone found in shapefile")
ErrNoZoneFound is returned when a zone for the given point is not found in the shapefile
var ErrOutOfRange = errors.New("point's coordinates out of range")
ErrOutOfRange is returned when latitude exceeds 90 degrees or longitude exceeds 180 degrees
var MockTZShapeFile []byte
MockTZShapeFile is similar to TZShapeFile but maps the entire world to the timezone America/Los_Angeles. This data is a small json blob compressed with gzip. It is meant for testing.
var TZShapeFile []byte
TZShapeFile is the data containing geographic shapes for timezone borders. This data is a large json blob compressed with gzip.
Functions ¶
This section is empty.
Types ¶
type FeatureCollection ¶
type FeatureCollection struct {
Features []*Feature
}
FeatureCollection is a set of Features
type Geometry ¶
Geometry represents a set of points that draw a geographic geometry
func (*Geometry) UnmarshalJSON ¶
UnmarshalJSON parses json data into a geometry
type LocalTimeZone ¶
LocalTimeZone is a client for looking up time zones by Points
func NewLocalTimeZone ¶
func NewLocalTimeZone() (LocalTimeZone, error)
NewLocalTimeZone creates a new LocalTimeZone with real timezone data The client is threadsafe
func NewMockLocalTimeZone ¶ added in v2.1.0
func NewMockLocalTimeZone() LocalTimeZone
NewMockLocalTimeZone creates a new LocalTimeZone that always returns America/Los_Angeles as the timezone The client is threadsafe
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Code generation tool for embedding the timezone shapefile in the gotz package run "go generate" in the parent directory after changing the -release flag in gen.go
|
Code generation tool for embedding the timezone shapefile in the gotz package run "go generate" in the parent directory after changing the -release flag in gen.go |