Skip to content
/ tz Public
forked from go-playground/tz

Timezone Country and Zone data generated from timezonedb.com

License

Notifications You must be signed in to change notification settings

nicola-spb/tz

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package tz (timezone)

Project status Build Status Go Report Card GoDoc License

Package tz contains information about Timezones (Country, Zone and Timezones) generated from timezonedb.com

This library is nothing special, it contains alphabetically sorted Country, Zone and Timezone info that can be used within your project.

Motivation

I got timezone abbreviation and offset in browser and I wanted to find timezone by this data. This package can do it.

I found https://github.com/go-playground/tz and forked it. I hope it is help you!

Thank you @go-playground!

Get zones by country, abbreviation and offset
tz.GetZones(country string, abbr string, offset int)
Get zones by abbreviation and offset
tz.GetZonesByAbbrAndOffset(abbr string, offset int)
Get zones by country code
tz.GetZonesByCountry(countryCode string)
Get zone by id
GetZoneById(zoneId int)
Get all countries
tz.GetCountries()
Get country by code
tz.GetCountry(countryCode string)
Example using with
timezones := tz.GetZones("AF", "LMT", 16608)
if len(timezones) > 0 {
    loc, _ := time.LoadLocation(timezones[0])
    // now that you have location can use with Go's time package which handles timezone offsets & Daylight savings times.
    time.ParseInLocation(...)
    time.Now().In(loc)
}

NOTES

This is intended to be used along side Go's own time logic eg. time.LoadLocation

Licence

This project is released under the MIT licence. See LICENCE for more details.

About

Timezone Country and Zone data generated from timezonedb.com

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%