-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map Unix TimeZoneId to Windows TimeZoneId #18644
Comments
Next steps: We need formal API proposal. |
Any such implementation will require the mapping data from CLDR. This may or may not already be available on the OS, or may have to be included manually. Then you have to consider overrides. That is - since CLDR only updates twice annually, what do you do to keep in sync when new time zones come out (on either side)? FYI, Noda Time also had this concern, and this same problem. See nodatime/nodatime#473 IMHO, if there were to be a library for this, it should be done in its own nuget package. It might contain a fair amount of data, and would rev frequently to keep up with overrides. |
Any update on this, maybe a netstandard 2.0 thing? |
.NET Standard 2.0 is about APIs which are common across runtimes/implementations - .NET Core, Desktop and Xamarin. This is new API, so it does not fit that bucket. The next steps are highlighted in my earlier comment. If anyone from the community is passionate about it, feel free to help and contribute. So far there is only 1 person interested. There is also suggestion to make it external to CoreFX (I don't have personal opinion on that yet), it should be seriously considered as well. |
I plan to create a separate OSS library that will properly do CLDR-based IANA to Windows time zone conversions, in a maintainable way, and isolated from other libraries. This will complement the framework, as well as other libraries in this space, such as NodaTime and my GeoTimeZone and TimeZoneNames libraries. I'll ship it as a netstandard library. That will give people a viable solution to this problem. |
@karelz I'm here to say that i'm interested in this too. TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"); But fails on Linux, I should use this instead: TimeZoneInfo.FindSystemTimeZoneById("America/New_York"); And to help the TimeZoneNotFoundException isn't exposed in .NET Core. |
I was hoping that Unix + Windows would share timezone ID's and finally enable a cross platform API that uses date time data to work properly without having to do hacky stuff server side. I really wanted the Windows version to use the same as Unix so in our company's Angular (2) app we could use something like momentjs to do datetime calculations browser side without having to talk to the server incase the API is running on Windows. Momentjs uses the standard timezones so won't work with Window's database versions. Really disappointing this isn't a higher priority. |
Thanks for feedback @linflux @philjones88 , for easier tracking can you please upvote top most post? It is something easy to sort and look at in future. Overall, after reading https://github.com/dotnet/corefx/issues/11897#issuecomment-259851156 by @mj1856 it seems to me that a standalone library is probably the best solution in this case. I don't think it is a great idea to include in the framework something that changes twice annually. ... just my 2 cents for now. |
It revs much more than that because we can't only rely on CLDR release versions. We also have to take into consideration the changes that ship in IANA TZDB releases, and in Windows updates. These tend to make it into the dev-trunk of CLDR in a relatively timely manner, but then they sit there until the next semiannual CLDR release. So really - having a separate microlibrary for this bit makes a lot of sense because a maintainer (like myself) can rev the library as necessary, regardless of which input signal changes. |
I've completed this work. The package is on Nuget as https://github.com/mj1856/TimeZoneConverter Example usages in the readme, including one to get a |
Awesome work. Thank you!!
…On 28 January 2017 at 01:28, Matt Johnson ***@***.***> wrote:
I've completed this work. The package is on Nuget as TimeZoneConverter,
and it targets .NET Standard 1.1.
https://github.com/mj1856/TimeZoneConverter
Example usages in the readme, including one to get a TimeZoneInfo
regardless of which platform you're on or which flavor of time zone you
have.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://github.com/dotnet/corefx/issues/11897#issuecomment-275816438>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGappAyIT5qOfDCOAFnJoSqs0HNUQ9Rks5rWpnMgaJpZM4KBbk1>
.
|
FYI - I merged the |
Great, thanks!
…On 1 June 2017 at 01:47, Matt Johnson ***@***.***> wrote:
FYI - I merged the GetTimeZoneInfo code into the library in version 2.0.0.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://github.com/dotnet/corefx/issues/11897#issuecomment-305357781>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGapibBD0NdF8e88JVr5TBJSUoljePkks5r_goqgaJpZM4KBbk1>
.
|
Is this issue still paused?! I'm using dotnet core 2.0 trying use alternative solution like |
The exception message is correct. For years 2015 and prior, Troll Station rotated through three distinct time zone offsets (+0, +1, +2), causing the transitions between offsets also to deviate (+1, +1 -2). See reference here. This data cannot be represented in the underlying Windows registry It would be possible for a Windows zone to be established, but conversions would only be accurate for 2016 forward (when they switched to alternating between just +0 and +2) . If you have sufficient need for such a time zone to exist, please explain in detail here (or contact me directly) and I will take it up with the Windows time zone servicing team here at Microsoft. Note that according to Wikipedia's entry on Troll Station, it has a capacity of 8 people in winter and 40 in the summer. To my knowledge, we haven't had a request from any of them, or from the Norwegian government, or other parties that may have an interest in timekeeping of Troll Station. It is mildly annoying that there exists an unmappable time zone between the two data sets, but other than that - it is difficult to justify creation of one in this particular case. |
@mj1856 thank you for reply, I tell So, to solve my question temporarily I'm using fixed IANA TimeZone. |
Be carefull about using I hope .Net Core get independent from system timezone and evolve into IANA time (or windows get new timezone API) |
@CShepartd - there is a constructive way to go about requesting perf improvements and this is not it. Note that in your tests you posted to the issue in my repo, you are primarily testing conversion - which is outside the scope of what the library provides. We can discuss improving perf on the lookup/mapping, perhaps by adding some internal caching, but as I pointed out before - being inflammatory and flippant does not get you very far. |
FYI - I have addressed the perf concern @CShepartd described. It is resolved in version 2.3.1. |
Take a look how I'm using @CShepartd
I'm using |
@alexsandro-xpt The perf issue was not with the The issue was specifically related to a control-flow-by-exception in the implementation, which has since been refactored out. The latest version, 2.3.1, does not have this perf issue. |
I'd like this functionality built into .NET Core. Thanks for your effort on the library @mj1856, it's very useful for us. |
well it would be enough if the Library would be named Microsoft.TimeZone or something along the lines and be officially supported (or at least listed in the official docs) |
* Update everything to netcoreapp2.2 Tests pass and generation works for both KO and Vue * Remove deps on obsolete logging setup. Fix some netcoreapp2.1 refs. Upgraded vue-cli to fix build issues. * Updated some Vue npm bits * Update Sourcelink to latest to remove dep on GitSharpLib * Changed to use 'webpack-env' instead of node in tsconfig per microsoft/nodejstools#2085 * Don't serve the /public/index.html, serve the one out of wwwroot * Make UseTimeZone cross-platform until https://github.com/dotnet/corefx/issues/11897 is fixed. * Fix VS trying to be "helpful" * Not hardcode the wwwroot convention
So it did get far enough for it get to resolved. He´s word were really noisy and correct to ignore. |
Would be great to have this. I am running into a scenario where I'm building a Docker container containing an ASP.NET Core 3.1 website, and I offer up a dropdown of timezones. In certain container environments, And, as mentioned before, if the It would be great if we could address this and/or find a better cross-platform solution for .NET 5! (P.S. Timezones are really hard. |
@qJake - Unix-style timezone strings are indeed parseable - on Unix derivatives.
This is the actual problem - your string should be parseable, but because it can't find any timezones, it looks like your specific ones don't work. For that matter, if Note that varying the list of timezones offered to your users based on the OS would likely be a mis-feature - and given the prevalence elsewhere, in a web context I'd default to the Unix/Olson tzdb identifiers (even if my OS was Windows). |
The PR #49412 now allowing to create a TZI objects using IANA or Windows Ids no matter you are running on Windows or Linux. |
We have merged the time zone names conversion #51093. I am closing this issue but feel free to send any quesstion as needed. |
If I execute
TimeZoneInfo.GetSystemTimeZones()
on Linux & Windows I get different lists, this is because each OS uses a different timezone db.However, is there a way in .netcore to get a consistent list no matter the OS and/or is there a way that
TimeZoneInfo.FindSystemTimeZoneById
on Windows will work with a Unix timezone id and vice versa a Windows id parsed on a Unix OS?The text was updated successfully, but these errors were encountered: