Closed chetan closed 10 months ago
Thanks for contributing this! I'm looking at it right now.
Could you detail how you obtained the gzip-ed JSON file (embedded rawData
), and what is its license?
Sorry, meant to include the url in a comment. I believe the json is from here but will need to confirm later when I get back to my computer -
https://github.com/karunais13/country-timezone-list
MIT licensed package
I've worked out a way to list zones without parsing JSON, using the system's tz database. It's more for search than listing though.
Would that work for you too?
The go-timezone library simply embeds most of the data as go structs instead of JSON or similar. The purpose of adding the extra json file here is simply to get the additional country name information as the actual timezone names are often not enough to locate the correct zone. For example, if I know a colleague is in Chile, but not their city, I can find it like so:
Any concerns with the JSON parsing in particular? Perhaps we can convert it to a struct as well to make things safer (and faster)? We can likely also drop the need for the go-timezone package and use only the one source to reduce size if that's a concern. Both speed and size looked ok to me so I didn't spend much time looking at that.
The go-timezone library simply embeds most of the data as go structs instead of JSON or similar. The purpose of adding the extra json file here is simply to get the additional country name information as the actual timezone names are often not enough to locate the correct zone.
In the case of Chile, filtering on the zone names still yields usable information:
CLT (-04:00) :: Chile/Continental
EAST (-06:00) :: Chile/EasterIsland
But, if you try to find "Italy", or "France" then you're out of luck.
I think that using external JSON data could be a nice UX improvement. Thanks for making the case more clear. 👍🏻
Any concerns with the JSON parsing in particular? Perhaps we can convert it to a struct as well to make things safer (and faster)?
It seems wasteful to parse an entire JSON file each time yes. Do you think we could use go generate
to download the file instead, and generate a list of structs before building?
This PR adds a
--list
flag which displays a complete listing of timezones with offsets and country names.