{"id":13800918,"url":"https://github.com/dmitryme/erlang_localtime","last_synced_at":"2025-05-13T10:30:40.566Z","repository":{"id":1028318,"uuid":"856437","full_name":"dmitryme/erlang_localtime","owner":"dmitryme","description":"Erlang library for conversion from one local time to another ","archived":false,"fork":false,"pushed_at":"2017-02-04T14:04:23.000Z","size":190,"stargazers_count":57,"open_issues_count":13,"forks_count":51,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-08-04T00:05:38.478Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmitryme.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2010-08-23T11:45:41.000Z","updated_at":"2023-10-15T09:47:21.000Z","dependencies_parsed_at":"2022-08-18T09:50:33.693Z","dependency_job_id":null,"html_url":"https://github.com/dmitryme/erlang_localtime","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/dmitryme%2Ferlang_localtime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitryme%2Ferlang_localtime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitryme%2Ferlang_localtime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitryme%2Ferlang_localtime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmitryme","download_url":"https://codeload.github.com/dmitryme/erlang_localtime/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225198942,"owners_count":17437002,"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-08-04T00:01:17.618Z","updated_at":"2024-11-18T15:31:23.774Z","avatar_url":"https://github.com/dmitryme.png","language":"Erlang","readme":"\nErlang Localtime\n===\n\n\n### Public exports\n\n* `utc_to_local/2` – Converts UTC time to local according to specified Timezone\n* `local_to_utc/2` – Converts local time to UTC\n* `local_to_local/3` – Converts local time to local\n* `tz_name/2` – Returns a timezone name (E.g. MSK, MSD, etc)\n* `tz_shift/2` – Returns time difference between local datetime and GMT\n* `tz_shift/3` – Returns time difference between local datetime and required timezone\n\n### Details\n\n#### Types\n* `DateTime` = `{date(), time()}`.\n* `TimeZone` = `TimeZoneFrom` = `TimeZoneTo` = `list()`, e.g. `\"Europe/Moscow\"`, `\"America/NewYork\"` or abbreviations `\"MSK\"`, `\"MSD\"`, etc.\n* `ZoneName` =  `{StdAbbr :: list(), StdName :: list()}`, e.g. `{\"MSK\",\"MSK\"}`\n* `ZoneShift` = `{Sign :: '+' | '-', Offset :: non_neg_integer(), RemOffset :: non_neg_integer()}`\n\n#### Dialyzer\n\n`utc_to_local(DateTime, TimeZone) → DateTime | {error, Reason}`\n\n`local_to_utc(DateTime, TimeZone) → DateTime | {error, Reason}`\n\n`local_to_local(DateTime, TimeZoneFrom, TimeZoneTo) → DateTime | {error, Reason}`\n\n`tz_name(DateTime, TimeZone) → ZoneName | {error, Reason}`\n\n`tz_shift(DateTime, TimeZone) → 0 | ZoneShift | {error, Reason}`\n\n`tz_shift(DateTime, TimeZoneFrom, TimeZoneTo) → 0 | ZoneShift | {error, Reason}`\n\n#### Note\n\nAabbreviation is just used to find appropriate timezone name. If you want to convert `\"MSK\"` → `\"PDT\"`, but source timezone is not in daylight saving, it will be corrected by library and `\"MSK\"` → `\"PST\"` conversion will be made.\n\n### Examples of usage\n\n#### Converts UTC time to local one\n```erlang\nlocaltime:utc_to_local({{2010, 7, 22}, {17, 56, 23}}, \"Europe/Moscow\").\n{{2010,10,10},{21,56,23}}\n```\n\n#### Converts local time to UTC one\n```erlang\nlocaltime:local_to_utc({{2010, 10, 10}, {21, 56, 23}}, \"Europe/Moscow\").\n{{2010,10,10},{17,56,23}}\n```\n\n#### Converts time from one local timezone to another local one\n```erlang\nlocaltime:local_to_local({{2010, 10, 10}, {21, 56, 23}}, \"Europe/Moscow\", \"Australia/Sydney\").\n{{2010,10,11},{3,56,23}}\n```\n\n#### Returns timezone name\n```erlang\nlocaltime:tz_name({{2010, 10, 10}, {21, 56, 23}}, \"Europe/Moscow\").\n{\"MSK\",\"MSK\"}\n\nlocaltime:tz_name({{2010,10,11},{3,56,23}}, \"Australia/Sydney\").\n{\"EST\",\"EST\"}\n```\n\n#### Calculates time difference between UTC and local one\n```erlang\nlocaltime:tz_shift({{2013, 01, 22}, {18, 17, 00}}, \"Europe/Moscow\").\n{'+',4,0}\n\nlocaltime:tz_shift({{2013, 01, 22}, {18, 17, 00}}, \"America/New York\").\n{'-',5,0}\n```\n\n#### Calculates time difference between two local timezones\n```erlang\nlocaltime:tz_shift({{2013, 01, 22}, {18, 17, 00}}, \"America/New York\", \"Europe/Moscow\").\n{'+',9,0}\n```\n","funding_links":[],"categories":["Date and Time"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitryme%2Ferlang_localtime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmitryme%2Ferlang_localtime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitryme%2Ferlang_localtime/lists"}