dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

Remarks could/should explain that FindSystemTimeZoneById now supports IANA time zones on Windows

Open adamgf1 opened this issue 1 year ago • 3 comments

Type of issue

Missing information

Description

Hi,

As announced in this blog post, the TimeZoneInfo.FindSystemTimeZoneById method will now actually support IANA time zones on Windows starting in .NET 6.

For example (using C# interactive window in Visual Studio):

> var iana = TimeZoneInfo.FindSystemTimeZoneById("Pacific/Auckland");
> iana
[(UTC+12:00) Auckland, Wellington]

However, the documentation article for this method doesn't actually make any mention of this. It is still written as though the method only retrieves time zones from the Windows registry on Windows (and as though it only supports IANA time zones, via the ICU library, on Linux/macOS):

On Windows systems, FindSystemTimeZoneById tries to match id to the subkey names of the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Time Zones branch of the registry. On Linux and macOS, it uses time zone information available in the ICU Library. If the registry or the library does not have the information for the time zone you desire, you can create a particular time zone either by calling one of the overloads of the CreateCustomTimeZone method or by calling FromSerializedString to deserialize a TimeZoneInfo object that represents the required time zone.

The fact that this API is now fully cross-platform, and supports IANA/tzdata time zone identifiers, is exceptionally helpful, and so I think it would also be really helpful if the documentation made this clearer.

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.timezoneinfo.findsystemtimezonebyid?view=net-6.0

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System/TimeZoneInfo.xml

Document Version Independent Id

b282844b-aed0-a026-8f29-be15019ab711

Article author

@dotnet-bot

adamgf1 avatar Nov 26 '24 11:11 adamgf1

@adamgf1 thanks for filing the issue. Are you interested in submitting a PR to fix it?

tarekgh avatar Mar 10 '25 19:03 tarekgh

Hi @tarekgh, I can do that, as long as you don't mind me not being able to give an ETA for the change. (I'll have to get up to speed with the contributor guide for the first time, and work on the change outside of company time.)

I suppose that shouldn't really matter as this point has been unmentioned in the documentation for a few years now, so if that all sounds ok to you then yes, I'll raise a PR for this "at some point". (I'll most likely raise the PR from my personal account, not this one, just FYI.)

adamgf1 avatar Mar 15 '25 06:03 adamgf1

@adamgf1, thanks for your willingness to help! Yes, feel free to do it whenever it suits you. Let me know if you need any guidance or help here.

tarekgh avatar Mar 15 '25 20:03 tarekgh

I was finally going to take a look at doing this, but I see that @oii-nasif has actually already raised a PR for this (presumably because I took so long) 😅

Thanks @oii-nasif for doing that.

adamgf1 avatar Nov 19 '25 12:11 adamgf1