Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gopkg.in/photoprism/go-tz.v2

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gopkg.in/photoprism/go-tz.v2

  • v2.1.3
  • Go
  • Socket score

Version published
Created
Source

gopkg.in/photoprism/go-tz.v2

GoDoc Go Report Card License: MIT

Go library for fast offline timezone lookup by latitude and longitude. This is a fork of ugjka/go-tz that includes the latest timezone boundaries data and a Makefile for build automation.

Uses a simplified shapefile from timezone-boundary-builder for the lookups. The GeoJSON simplification was done with mapshaper.

Usage Example

import "gopkg.in/photoprism/go-tz.v2/tz"

func TimeZone(lat, lng float64) (result string) {
    result = "UTC"

    zones, err := tz.GetZone(tz.Point{Lat: lat, Lon: lng})

    if err == nil && len(zones) > 0 {
        result = zones[0]
    }

    return result
}

Key Features

  • Fast sub-millisecond lookups, even on old hardware
  • Timezone shapefile for lookups is embedded in the build binary
  • Supports overlapping timezones
  • You can load your own geojson shapefile if you want

Known Issues

  • The shapefile is simplified using a lossy method, so it may be inaccurate along the boundaries
  • Since the library runs completely in memory, it requires about 50 MB of RAM

Licensing

The embedded timezone data is licensed under the Open Data Commons Open Database License (ODbL). Any other code in this library can be used under the terms of the MIT License.

FAQs

Package last updated on 06 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc