{"id":21654686,"url":"https://github.com/localvoid/timezone","last_synced_at":"2025-04-11T21:13:46.602Z","repository":{"id":21943697,"uuid":"25268184","full_name":"localvoid/timezone","owner":"localvoid","description":"Maintained repo: https://github.com/srawlins/timezone","archived":false,"fork":false,"pushed_at":"2022-08-22T21:07:29.000Z","size":703,"stargazers_count":3,"open_issues_count":4,"forks_count":60,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T21:13:41.798Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/localvoid.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":"2014-10-15T18:38:37.000Z","updated_at":"2020-08-22T22:46:31.000Z","dependencies_parsed_at":"2022-08-20T02:51:01.255Z","dependency_job_id":null,"html_url":"https://github.com/localvoid/timezone","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localvoid%2Ftimezone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localvoid%2Ftimezone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localvoid%2Ftimezone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localvoid%2Ftimezone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/localvoid","download_url":"https://codeload.github.com/localvoid/timezone/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248480427,"owners_count":21110937,"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":[],"created_at":"2024-11-25T08:28:43.113Z","updated_at":"2025-04-11T21:13:46.582Z","avatar_url":"https://github.com/localvoid.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TimeZone\n\nThis package provides time zone database and time zone aware `DateTime`\nobject.\n\nCurrent Time Zone database version:\n[2015b](http://www.iana.org/time-zones/repository/releases/tzcode2015b.tar.gz)\n\n## Initialization\n\nTimeZone objects require time zone data, so the first step is to load\none of our [time zone databases](#databases).\n\nWe are providing two different APIs for browsers and standalone\nenvironments.\n\n### Initialization for browser environment\n\nImport `package:timezone/browser.dart` library and run async function\n`Future initializeTimeZone([String path])`.\n\n```dart\nimport 'package:timezone/browser.dart';\n\ninitializeTimeZone().then((_) {\n  final detroit = getLocation('America/Detroit');\n  final now = new TZDateTime.now(detroit);\n});\n```\n\n### Initialization for standalone environment\n\nImport `package:timezone/standalone.dart` library and run async function\n`Future initializeTimeZone([String path])`.\n\n```dart\nimport 'package:timezone/standalone.dart';\n\ninitializeTimeZone().then((_) {\n  final detroit = getLocation('America/Detroit');\n  final now = new TZDateTime.now(detroit);\n});\n```\n\n### Local Location\n\nBy default, when library is initialized, local location will be `UTC`.\n\nTo overwrite local location you can use `setLocalLocation(Location\nlocation)` function.\n\n```dart\ninitializeTimeZone().then((_) {\n  final detroit = getLocation('America/Detroit');\n  setLocalLocation(detroit);\n});\n```\n\n## API\n\n### Location\n\n\u003e Each location in the database represents a national region where all\n\u003e clocks keeping local time have agreed since 1970. Locations are\n\u003e identified by continent or ocean and then by the name of the\n\u003e location, which is typically the largest city within the region. For\n\u003e example, America/New_York represents most of the US eastern time\n\u003e zone; America/Phoenix represents most of Arizona, which uses\n\u003e mountain time without daylight saving time (DST); America/Detroit\n\u003e represents most of Michigan, which uses eastern time but with\n\u003e different DST rules in 1975; and other entries represent smaller\n\u003e regions like Starke County, Indiana, which switched from central to\n\u003e eastern time in 1991 and switched back in 2006.\n\u003e\n\u003e [The tz database](http://www.twinsun.com/tz/tz-link.htm)\n\n#### Get location by Olsen timezone ID\n\n```dart\nfinal detroit = getLocation('America/Detroit');\n```\n\nWe don't provide any functions to get locations by timezone\nabbreviations because of the ambiguities.\n\n\u003e Alphabetic time zone abbreviations should not be used as unique\n\u003e identifiers for UTC offsets as they are ambiguous in practice. For\n\u003e example, \"EST\" denotes 5 hours behind UTC in English-speaking North\n\u003e America, but it denotes 10 or 11 hours ahead of UTC in Australia;\n\u003e and French-speaking North Americans prefer \"HNE\" to \"EST\".\n\u003e\n\u003e [The tz database](http://www.twinsun.com/tz/tz-link.htm)\n\n### TimeZone\n\nTimeZone object represents time zone and contains offset, dst flag,\nand name in the abbreviated form.\n\n```dart\nfinal timeInUtc = new DateTime.utc(1995, 1, 1);\nfinal timeZone = detroit.timeZone(timeInUtc.millisecondsSinceEpoch);\n```\n\n### TimeZone aware DateTime\n\n`TZDateTime` object implements standard `DateTime` interface and\ncontains information about location and time zone.\n\n```dart\nfinal date = new TZDateTime(detroit, 2014, 11, 17);\n```\n\n#### Converting DateTimes between Time Zones\n\nTo convert between time zones, just create a new `TZDateTime` object\nusing `from` constructor and pass `Location` and `DateTime` to the\nconstructor.\n\n```dart\nfinal localTime = new DateTime(2010, 1, 1);\nfinal detroitTime = new TZDateTime.from(time, detroit);\n```\n\nThis constructor supports any objects that implements `DateTime`\ninterface, so you can pass native `DateTime` object or ours\n`TZDateTime`.\n\n## \u003ca name=\"databases\"\u003e\u003c/a\u003e Time Zone databases\n\nWe are using [IANA Time Zone Database](http://www.iana.org/time-zones)\nto build our databases.\n\nWe are currently building three different database variants:\n\n- default (doesn't contain deprecated and historical zones with some\n  exceptions like US/Eastern). 308kb/72kb gzip\n- all (contains all data from the\n  [IANA Time Zone Database](http://www.iana.org/time-zones)). 370kb/100kb\n  gzip\n- 2010-2020 (default database that contains historical data from 2010\n  until 2020). 71kb/16kb gzip\n\n### Updating Time Zone databases\n\nScript for updating Time Zone database, it will automatically download\n[the IANA Time Zone Database](http://www.iana.org/time-zones) and\ncompile into our native format.\n\n```sh\n$ pub run tool/get -s 2014h\n```\n\nArgument `-s` is for specifying source version.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalvoid%2Ftimezone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flocalvoid%2Ftimezone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalvoid%2Ftimezone/lists"}