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.
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!
tz.GetZones(country string, abbr string, offset int)
tz.GetZonesByAbbrAndOffset(abbr string, offset int)
tz.GetZonesByCountry(countryCode string)
GetZoneById(zoneId int)
tz.GetCountries()
tz.GetCountry(countryCode string)
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)
}
This is intended to be used along side Go's own time logic eg. time.LoadLocation
This project is released under the MIT licence. See LICENCE for more details.