{"id":13735910,"url":"https://github.com/GULPF/timezones","last_synced_at":"2025-05-08T12:31:36.889Z","repository":{"id":51668919,"uuid":"116312829","full_name":"GULPF/timezones","owner":"GULPF","description":"Nim timezone library compatible with the standard library.","archived":false,"fork":false,"pushed_at":"2021-06-29T16:37:44.000Z","size":2083,"stargazers_count":42,"open_issues_count":4,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T16:46:10.411Z","etag":null,"topics":["nim","time","timezone"],"latest_commit_sha":null,"homepage":null,"language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GULPF.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-04T22:13:46.000Z","updated_at":"2024-05-29T17:39:50.000Z","dependencies_parsed_at":"2022-08-22T04:00:18.260Z","dependency_job_id":null,"html_url":"https://github.com/GULPF/timezones","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GULPF%2Ftimezones","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GULPF%2Ftimezones/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GULPF%2Ftimezones/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GULPF%2Ftimezones/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GULPF","download_url":"https://codeload.github.com/GULPF/timezones/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253068554,"owners_count":21848829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nim","time","timezone"],"created_at":"2024-08-03T03:01:12.858Z","updated_at":"2025-05-08T12:31:36.146Z","avatar_url":"https://github.com/GULPF.png","language":"Nim","funding_links":[],"categories":["Operating System"],"sub_categories":["Date and Time"],"readme":"# Timezones ![CI](https://github.com/GULPF/nimquery/workflows/CI/badge.svg)\n\nA Nim library for working with timezones. It uses the [IANA timezone database](https://en.wikipedia.org/wiki/Tz_database) as a source for the timezone definitions. Both the C based backends and the JS backend are supported.\n\n## Installation\n\nTimezones is available on Nimble:\n```\nnimble install timezones\n```\n\n## Usage\n```nim\nimport times\nimport timezones\n\n# Create a timezone representing a static offset from UTC.\nlet zone = tz\"+02:30\"\necho initDateTime(1, mJan, 2000, 12, 00, 00, zone)\n# =\u003e 2000-01-01T12:00:00+02:30\n\n# Static offset timezones can also be created with the proc ``staticTz``,\n# which is preferable if the offset is only known at runtime.\ndoAssert zone == staticTz(hours = -2, minutes = -30)\n\n# Create a timezone representing a timezone in the IANA timezone database.\nlet stockholm = tz\"Europe/Stockholm\"\necho initDateTime(1, mJan, 1850, 00, 00, 00, stockholm)\n# =\u003e 1850-01-01T00:00:00+01:12\n\n# Like above, but returns a `TimezoneInfo` object which contains some\n# extra metadata.\nlet stockholmInfo = tzInfo\"Europe/Stockholm\"\n# Countries are specified with it's two character country code,\n# see ISO 3166-1 alpha-2.\ndoAssert stockholmInfo.countries == @[\"SE\"]\ndoAssert stockholmInfo.timezone == stockholm\n\n# Note that some timezones are used by multiple countries.\nlet bangkok = tzInfo\"Asia/Bangkok\"\ndoAssert bangkok.countries == @[\"TH\", \"KH\", \"LA\", \"VN\"]\n```\n\n## API\n- [Generated docs for timezones module](https://gulpf.github.io/timezones/timezones.html).\n- [Generated docs for times/posixtimezones module](https://gulpf.github.io/timezones/posixtimezones.html).\n\n## Advanced usage\nThe timezone definitions from a [IANA timezone database](https://en.wikipedia.org/wiki/Tz_database) release are stored in a JSON file. This repo includes the currently latest release, but no guarantee is given as to how fast the bundled timezone database is updated when IANA releases a new version. The JSON file can either be embeeded into the executable (which is the default behavior), or be loaded at runtime.\n\nIf you want control over when the timezone definitions are updated, there are two options:\n- Embeed a custom JSON file\n- Load a JSON file at runtime\n\nBoth options require you to generate the JSON file yourself. See [fetchjsontimezones](#fetchjsontimezones) for information on how to accomplish that.\n\nTo embeed a custom JSON file, simply pass `-d:timezonesPath={path}\u003e`, where `{path}` is the **absolute** path to the file.\n\nTo load a JSON definition at runtime, either of these procs can be used:\n```nim\nproc parseJsonTimezones*(content: string): TzData\nproc loadJsonTimezones*(path: string): TzData # Not available for the JS backend\n```\nIf you load the JSON timezones at runtime, it's likely that you don't need the bundled definitions. To disable the embeededing of the bundled JSON file, `-d:timezonesNoEmbeed` can be passed.\n\n## fetchjsontimezones \u003ca name=\"fetchjsontimezones\"\u003e\u003c/a\u003e\n\n**NOTE**: The `fetchjsontimezones` tool isn't supported on Windows for now.\n\n`fetchjsontimezones` is a command line tool for downloading IANA timezone database releases and converting them to the JSON format used by the `timezones` module. It's part of this repo and is installed by running `nimble install timezones`. Using `fetchjsontimezones` isn't required for using the `timezones` module, but it's needed to load timezone data during runtime.\n\nUsage (`fetchjsontimezones --help`):\n ```\n    fetchjsontimezones \u003cversion\u003e # Download \u003cversion\u003e, e.g '2018d'.\n\n    --help                       # Print this help message\n    --out:\u003cfile\u003e, -o:\u003cfile\u003e      # Write output to this file.\n                                 # Defaults to './\u003cversion\u003e.json'.\n    --timezones:\u003czones\u003e          # Only store transitions for these timezones.\n    --regions:\u003cregions\u003e          # Only store transitions for these regions.\n```\n\nFor example, `fetchjsontimezones 2020d --out:tzdata.json --regions:\"europe northamerica\"` will create a timezone data file called `tzdata.json` containing timzeone transitions for the regions 'europe' and 'northamerica' generated from the `2020d` timezone database release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGULPF%2Ftimezones","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGULPF%2Ftimezones","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGULPF%2Ftimezones/lists"}