{"id":15412245,"url":"https://github.com/robthree/timezonemapper","last_synced_at":"2025-04-19T04:19:24.496Z","repository":{"id":11672440,"uuid":"14181929","full_name":"RobThree/TimeZoneMapper","owner":"RobThree","description":"Library for mapping *N*X TimeZone ID's (e.g. Europe/Amsterdam) to .Net's TimeZoneInfo classes.","archived":false,"fork":false,"pushed_at":"2024-03-07T18:11:55.000Z","size":2006,"stargazers_count":19,"open_issues_count":0,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-14T18:05:50.101Z","etag":null,"topics":["c-sharp","cldr","cldr-data","dotnet","mapper","timezone","unicode-consortium"],"latest_commit_sha":null,"homepage":"","language":"C#","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/RobThree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":["RobThree"],"custom":["https://paypal.me/robiii"]}},"created_at":"2013-11-06T18:43:57.000Z","updated_at":"2025-01-11T20:39:21.000Z","dependencies_parsed_at":"2024-03-07T18:26:23.906Z","dependency_job_id":"5c15b880-3d25-4c3e-9148-bb4eb53a5725","html_url":"https://github.com/RobThree/TimeZoneMapper","commit_stats":{"total_commits":62,"total_committers":3,"mean_commits":"20.666666666666668","dds":"0.032258064516129004","last_synced_commit":"2ce1999d1d3c9bd3ea8672a1f9451c358be73042"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FTimeZoneMapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FTimeZoneMapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FTimeZoneMapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobThree%2FTimeZoneMapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobThree","download_url":"https://codeload.github.com/RobThree/TimeZoneMapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249191333,"owners_count":21227547,"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":["c-sharp","cldr","cldr-data","dotnet","mapper","timezone","unicode-consortium"],"created_at":"2024-10-01T16:51:58.374Z","updated_at":"2025-04-19T04:19:24.477Z","avatar_url":"https://github.com/RobThree.png","language":"C#","readme":"# ![Logo](https://raw.githubusercontent.com/RobThree/TimeZoneMapper/master/TimeZoneMapper/ResourceFiles/TimezoneMapper.png) TimeZoneMapper\n\n![Build Status](https://img.shields.io/github/actions/workflow/status/RobThree/TimeZoneMapper/test.yml?branch=master\u0026style=flat-square) [![Nuget version](https://img.shields.io/nuget/v/TimeZoneMapper.svg?style=flat-square)](https://www.nuget.org/packages/TimeZoneMapper/)\n\n\nLibrary for mapping \\*N\\*X TimeZone ID's (e.g. `Europe/Amsterdam`) to .Net's [TimeZoneInfo](http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx) classes. This mapping is one-way since, for example, `Europe/Amsterdam` maps to `W. Europe Standard Time` but `W. Europe Standard Time` could map to `Europe/Stockholm` or `Arctic/Longyearbyen` just as easily.\n\nThe library provides a simple static `TimeZoneMap` object that exposes 3 types of mappers, each described below under [usage](#usage). The project is kept up-to-date with the latest mapping information as much as I can, but TimeZoneMapper can use the latest mapping information available online completely transparently.\n\nTimeZoneMapper is available as a [NuGet package](https://www.nuget.org/packages/TimeZoneMapper/) and comes with (basic) documentation in the form of a Windows Helpfile (.chm).\n\n# Usage\n\nThe most basic example is as follows:\n```c#\nTimeZoneInfo tzi = TimeZoneMap.DefaultValuesTZMapper.MapTZID(\"Europe/Amsterdam\");\n````\n\nThis uses the static TimeZoneMap.DefaultValuesTZMapper to map the string to the specific [TimeZoneInfo](http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx). The DefaultValuesTZMapper object uses a built-in resource containing the mapping information. If you want more up-to-date mapping information, you can use the `OnlineValuesTZMapper`.\n```c#\nTimeZoneInfo tzi = TimeZoneMap.OnlineValuesTZMapper.MapTZID(\"Europe/Amsterdam\");\n````\n\nThis will retrieve the [information](https://unicode-org.github.io/cldr-staging/charts/) from the [Unicode Consortium](http://unicode.org/)'s latest [CLDR data](https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml). There is a catch though: what if, for some reason, this information is not available (for example an outbound HTTP request is blocked, the data is not available (HTTP status 404 for example) or the data is corrupt (invalid XML for some reason))? Well, simple, we just use the `OnlineWithFallbackValuesTZMapper`!\n```c#\nTimeZoneInfo tzi = TimeZoneMap.OnlineWithFallbackValuesTZMapper.MapTZID(\"Europe/Amsterdam\");\n````\n\nThis will try to download the CLDR data from the Unicode Consortium and when that, for some reason fails, it uses the built-in values as fallback.\n\nNote that an HTTP request will be made only once for as long as the TimeZoneMapper is around (usually the lifetime of the application). Also note that the TimeZoneMapper is **case-*in*sensitive**; the TimeZone ID `Europe/Amsterdam` works just as well as `EUROPE/AMSTERDAM` or `eUrOpE/AmStErDaM`.\n\nFinally, when you want control over the actual CLDR data and where it is stored, how you cache it etc. you can use the `CustomValuesTZMapper`. Be sure to add the `TimeZoneMapper.TZMappers` namespace if you want to use this class. This class' constructor has 3 overloads demonstrated below:\n\n```c#\n// Overload 1: CustomValuesTZMapper(string, Encoding)\n\n// Load XML from file\nvar mapper = new CustomValuesTZMapper(\"myfile.xml\", Encoding.UTF8);\nTimeZoneInfo tzi = mapper.MapTZID(\"Europe/Amsterdam\");\n````    \n```c#\n// Overload 2: CustomValuesTZMapper(string)\n    \n// Get XML from database, cache, online resource, file, etc. or, in this case, \"hard-coded\":\nstring cldrdata = \"\u003csupplementalData\u003e\u003cwindowsZones\u003e\u003cmapTimezones otherVersion=\\\"xyz\\\" typeVersion=\\\"zyx\\\"\u003e...\"; \nvar mapper = new CustomValuesTZMapper(cldrdata);\nTimeZoneInfo tzi = mapper.MapTZID(\"Europe/Amsterdam\");\n````\n```c#\n// Overload 3: CustomValuesTZMapper(Stream)\n\n// Use a Stream\nusing (var mystream = new GZipStream(File.OpenRead(\"myfile.gz\"), CompressionMode.Decompress))\n{\n    var mapper = new CustomValuesTZMapper(mystream);\n    TimeZoneInfo tzi = mapper.MapTZID(\"Europe/Amsterdam\");\n}\n````\nAll you need to do is ensure the data you supply to the CustomValuesTZMapper is valid CLDR data (see [this example](TimeZoneMapper/ResourceFiles/windowsZones.xml))\n\n# Future\n\nI will try to update the built-in resource every now-and-then.\n\n---\n\n[Icon](https://www.deviantart.com/deviantdark/art/Oxygen-Refit-70199755) made by [deviantdark](https://www.deviantart.com/deviantdark), licensed by [Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0)](https://creativecommons.org/licenses/by-nc-sa/3.0/) ([Archived page](http://riii.me/jcgob)).\n","funding_links":["https://github.com/sponsors/RobThree","https://paypal.me/robiii"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobthree%2Ftimezonemapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobthree%2Ftimezonemapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobthree%2Ftimezonemapper/lists"}