Skip to content

Conversation

@tarekgh
Copy link
Member

@tarekgh tarekgh commented Aug 7, 2024

Backport of #106038 to release/8.0-dtaging

/cc @tarekgh

Customer Impact

Creating a TimeZoneInfo object using Windows zone Id e.g. Eastern Standard Time when running on non-Windows OS e.g. Linux, the created Zone object will report wrong standard, daylight, and display zone names.
This is a regression occurred in .NET 8.0 and reported by the user through the issue dotnet/docs#41830.

Details

In .NET 8.0 we have done some optimization work to delay initializing the time zone names (Standard, Daylight, and Display names). The reason is the names initialization is extremely expensive especially on non-Windows OS's because we do some heuristics and call ICU to extract such names. Unintentionally doing lazy initialization names on non-Windows OS's caused a problem with the time zones created using Windows Ids e.g. Eastern Standard Time. The reason is to get the correct names of the time zone you need to call ICU using the IANA ids e.g. America/New_York which not done with the lazy initialization. The fix here is to ensure using the IANA ids on non-Windows OS's when requesting the names from ICU.

The repro of the issue, on Linux use code like:

TimeZoneInfo timeZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
Console.WriteLine($"{zoneName}: {timeZone.Id} ... {timeZone.StandardName} ... {timeZone.DaylightName} ");

This code will display names like GMT which are wrong as expected to show something like Eastern Standard Time: Eastern Standard Time ... Eastern Standard Time ... Eastern Daylight Time.

Testing

Passed the regression tests and added more tests to cover the failing cases.

Risk

Low, this change is targeting only the broken case when creating a TimeZoneInfo object using Windows zone Id while ensuring picking up the right Id when trying to retrieve the zone names.

IMPORTANT: If this backport is for a servicing release, please verify that:

  • The PR target branch is release/X.0-staging, not release/X.0.
  • If the change touches code that ships in a NuGet package, you have added the necessary package authoring and gotten it explicitly reviewed.

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-datetime
See info in area-owners.md if you want to be subscribed.

@tarekgh tarekgh added this to the 8.0.x milestone Aug 7, 2024
@tarekgh tarekgh added the Servicing-consider Issue for next servicing release review label Aug 7, 2024
@tarekgh tarekgh requested a review from mdh1418 August 7, 2024 00:39
@tarekgh
Copy link
Member Author

tarekgh commented Aug 7, 2024

CC @ericstj @artl93

@leecow leecow added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Aug 8, 2024
@leecow leecow modified the milestones: 8.0.x, 8.0.9 Aug 8, 2024
@tarekgh tarekgh merged commit 5807052 into dotnet:release/8.0-staging Aug 8, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Sep 8, 2024
@rbhanda rbhanda modified the milestones: 8.0.9, 8.0.10 Oct 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.DateTime Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants