Skip to content

Use the IANA Time Zone Database to build a set of JSON files

License

Notifications You must be signed in to change notification settings

justinmimbs/timezone-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timezone-json

Use the IANA Time Zone Database to build a set of JSON files for all time zones. Each JSON file contains a time zone's offset at 1970 and a list of offset changes through 2037.

Note: The standard file type for time zone data is TZif; you may consider serving TZif files instead of JSON files.

Build

./build.sh
  • clones the IANA Time Zone Database repository
  • compiles zone information files for the latest release
  • uses a script from tz.js to read the compiled files
  • writes a set of JSON files to dist/<version>

For example, if the latest release is version 2018e, then the file for America/Los_Angeles will be written to dist/2018e/America/Los_Angeles.json.

Elm examples

The elm/time library provides a Posix type for representing an instant in time. Extracting human-readable parts from a Posix time requires a Time.Zone. These JSON files can be used by Elm applications that need Time.Zone values at runtime.

For an example of fetching and decoding Time.Zone values, see the getZone function in this file; it takes a path to your JSON files and returns a task for getting the local zone name and zone as a ( String, Time.Zone ).

import Time
import TimeZone.Json exposing (Error)

getLocalZone : Task Error ( String, Time.Zone )
getLocalZone =
    TimeZone.Json.getZone "/dist/2018e"

See examples/GetZone.elm for a full example.

About

Use the IANA Time Zone Database to build a set of JSON files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published