{"id":32161635,"url":"https://github.com/lfborjas/timezone-detect","last_synced_at":"2025-10-21T13:56:48.664Z","repository":{"id":53780022,"uuid":"291366968","full_name":"lfborjas/timezone-detect","owner":"lfborjas","description":"Haskell bindings to the ZoneDetect C library","archived":false,"fork":false,"pushed_at":"2021-03-14T17:41:50.000Z","size":3586,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T13:56:48.431Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lfborjas.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":"2020-08-29T23:43:30.000Z","updated_at":"2021-03-14T17:41:26.000Z","dependencies_parsed_at":"2022-09-05T18:12:52.903Z","dependency_job_id":null,"html_url":"https://github.com/lfborjas/timezone-detect","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/lfborjas/timezone-detect","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfborjas%2Ftimezone-detect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfborjas%2Ftimezone-detect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfborjas%2Ftimezone-detect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfborjas%2Ftimezone-detect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lfborjas","download_url":"https://codeload.github.com/lfborjas/timezone-detect/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lfborjas%2Ftimezone-detect/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280272339,"owners_count":26302260,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-10-21T13:56:46.827Z","updated_at":"2025-10-21T13:56:48.660Z","avatar_url":"https://github.com/lfborjas.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TimezoneDetect\n\n![build](https://github.com/lfborjas/timezone-detect/workflows/Haskell%20CI/badge.svg)\n\n\nHaskell bindings to the excellent [ZoneDetect](https://github.com/BertoldVdb/ZoneDetect) library, plus additional\nUNIX-aware facilities to determine the UTC time of a given local time in a latitude and longitude.\n\n## Usage\n\nYou'll need timezone database files to work with this library, see instructions [in the original repository](https://github.com/BertoldVdb/ZoneDetect/tree/master/database).\nA copy is provided in the `test` directory of this repository, but it's intentionally not bundled in the package. We make no guarantees of its correctness,\nwe recommend you use the original authors' files!\n\n\n### Timezone Name Lookup\n\nOnce you have those files in hand, you'll be able to get a timezone from a given latitude and longitude:\n\n```haskell\n\u003e\u003e\u003e db \u003c- openTimeZoneDatabase \"./test/tz_db/timezone21.bin\" \n\u003e\u003e\u003e let tz = lookupTimeZoneName db 40.7831 (-73.9712) :: Maybe TimeZoneName\nJust \"America/New_York\"\n\u003e\u003e\u003e closeTimeZoneDatabase db\n```\n\nYou can use `withTimeZoneDatabase` to \"bracket\" access to the file (take care of opening and closing,)\nbut if all you want to do is do a one-off lookup, a convenience function that opens and closes the file when done\nis also provided, specialized to `IO`:\n\n```haskell\n\u003e\u003e\u003e tz \u003c- lookupTimeZoneNameFromFile \"./test/tz_db/timezone21.bin\" 40.7831 (-73.9712)\n\"America/New_York\"\n```\n\n### LocalTime to UTCTime conversion\n\nAdditionally, we depend on the [timezone-series](https://hackage.haskell.org/package/timezone-series) and [timezone-olson](https://hackage.haskell.org/package/timezone-olson) packages to add awareness of `tz database` information.\n\nWith that, you can look up the UTC time at a point in time and space:\n\n```haskell\n\u003e\u003e\u003e import Data.Time\n\u003e\u003e db \u003c- openTimeZoneDatabase \"./test/tz_db/timezone21.bin\"\n\u003e\u003e\u003e localWinter \u003c- parseTimeM True defaultTimeLocale \"%Y-%-m-%-d %T\" \"2019-12-25 00:30:00\"\n\u003e\u003e\u003e utcTime \u003c- timeAtPointToUTC db 40.7831 (-73.9712) localWinter\n2019-12-25 05:30:00 UTC\n\n\u003e\u003e\u003e localSummer \u003c- parseTimeM True defaultTimeLocale \"%Y-%-m-%-d %T\" \"2019-07-25 00:30:00\"\n\u003e\u003e\u003e utcTime \u003c- timeAtPointToUTC db 40.7831 (-73.9712) localWinter\n2019-07-25 04:30:00 UTC\n\u003e\u003e\u003e closeTimeZoneDatabase db\n```\n\nYou can also opt to obtain the timezone name separately (if you wanted to isolate that as a failure scenario,)\nand, once in possession of it, use `timeInTimeZoneToUTC`:\n\n```haskell\n\u003e\u003e\u003e localSummer \u003c- parseTimeM True defaultTimeLocale \"%Y-%-m-%-d %T\" \"2019-07-25 00:30:00\"\n\u003e\u003e\u003e utcTime \u003c- timeInTimeZoneToUTC \"America/New_York\" localSummer\n2019-07-25 04:30:00 UTC\n```\n\n## Copyright\n\nThis library is released under the GPL v2; but the license for the underlying C library bears the following copyright:\n\n\u003e Copyright (c) 2018, Bertold Van den Bergh (vandenbergh@bertold.org) \n\u003e All rights reserved.\n\u003e Redistribution and use in source and binary forms, with or without\n\u003e modification, are permitted provided that the following conditions are met:\n\u003e    * Redistributions of source code must retain the above copyright\n\u003e       notice, this list of conditions and the following disclaimer.\n\u003e    * Redistributions in binary form must reproduce the above copyright\n\u003e       notice, this list of conditions and the following disclaimer in the\n\u003e       documentation and/or other materials provided with the distribution.\n\u003e    * Neither the name of the author nor the\n\u003e       names of its contributors may be used to endorse or promote products\n\u003e       derived from this software without specific prior written permission.\n\u003e\n\u003e THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n\u003e ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n\u003e WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n\u003e DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR DISTRIBUTOR BE LIABLE FOR ANY\n\u003e DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n\u003e (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n\u003e LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n\u003e ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\u003e (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n\u003e SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfborjas%2Ftimezone-detect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flfborjas%2Ftimezone-detect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfborjas%2Ftimezone-detect/lists"}