@@ -2434,12 +2434,31 @@ public static IEnumerable<object[]> SystemTimeZonesTestData()
24342434 }
24352435 }
24362436
2437+ // In recent Linux distros like Ubuntu 24.04, removed the legacy Time Zone names and not mapping it any more. User can still have a way to install it if they need to.
2438+ // UCT is one of the legacy aliases for UTC which we use here to detect if the legacy names is support at the runtime.
2439+ // https://discourse.ubuntu.com/t/ubuntu-24-04-lts-noble-numbat-release-notes/39890#p-99950-tzdata-package-split
2440+ private static bool SupportLegacyTimeZoneNames { get ; } = IsSupportedLegacyTimeZones ( ) ;
2441+ private static bool IsSupportedLegacyTimeZones ( )
2442+ {
2443+ try
2444+ {
2445+ TimeZoneInfo . FindSystemTimeZoneById ( "UCT" ) ;
2446+ }
2447+ catch ( TimeZoneNotFoundException )
2448+ {
2449+ return false ;
2450+ }
2451+
2452+ return true ;
2453+ }
2454+
24372455 [ GeneratedRegex ( @"^(?:[A-Z][A-Za-z]+|[+-]\d{2}|[+-]\d{4})$" ) ]
24382456 private static partial Regex IanaAbbreviationRegex { get ; }
24392457
24402458 // UTC aliases per https://github.com/unicode-org/cldr/blob/master/common/bcp47/timezone.xml
24412459 // (This list is not likely to change.)
2442- private static readonly string [ ] s_UtcAliases = new [ ] {
2460+ private static readonly string [ ] s_UtcAliases = SupportLegacyTimeZoneNames ?
2461+ [
24432462 "Etc/UTC" ,
24442463 "Etc/UCT" ,
24452464 "Etc/Universal" ,
@@ -2448,7 +2467,13 @@ public static IEnumerable<object[]> SystemTimeZonesTestData()
24482467 "UTC" ,
24492468 "Universal" ,
24502469 "Zulu"
2451- } ;
2470+ ] : [
2471+ "Etc/UTC" ,
2472+ "Etc/UCT" ,
2473+ "Etc/Universal" ,
2474+ "Etc/Zulu" ,
2475+ "UTC"
2476+ ] ;
24522477
24532478 // On Android GMT, GMT+0, and GMT-0 are values
24542479 private static readonly string [ ] s_GMTAliases = new [ ] {
@@ -2849,22 +2874,31 @@ public static void EnsureUtcObjectSingleton()
28492874 Assert . True ( ReferenceEquals ( tz , TimeZoneInfo . Utc ) ) ;
28502875 }
28512876
2877+ public static IEnumerable < object [ ] > AlternativeName_TestData ( )
2878+ {
2879+ yield return new object [ ] { "Pacific Standard Time" , "America/Los_Angeles" } ;
2880+ yield return new object [ ] { "AUS Eastern Standard Time" , "Australia/Sydney" } ;
2881+ yield return new object [ ] { "GMT Standard Time" , "Europe/London" } ;
2882+ yield return new object [ ] { "Tonga Standard Time" , "Pacific/Tongatapu" } ;
2883+ yield return new object [ ] { "W. Australia Standard Time" , "Australia/Perth" } ;
2884+ yield return new object [ ] { "E. South America Standard Time" , "America/Sao_Paulo" } ;
2885+ yield return new object [ ] { "E. Africa Standard Time" , "Africa/Nairobi" } ;
2886+ yield return new object [ ] { "W. Europe Standard Time" , "Europe/Berlin" } ;
2887+ yield return new object [ ] { "Russian Standard Time" , "Europe/Moscow" } ;
2888+ yield return new object [ ] { "Libya Standard Time" , "Africa/Tripoli" } ;
2889+ yield return new object [ ] { "South Africa Standard Time" , "Africa/Johannesburg" } ;
2890+ yield return new object [ ] { "Morocco Standard Time" , "Africa/Casablanca" } ;
2891+ yield return new object [ ] { "Newfoundland Standard Time" , "America/St_Johns" } ;
2892+ yield return new object [ ] { "Iran Standard Time" , "Asia/Tehran" } ;
2893+
2894+ if ( SupportLegacyTimeZoneNames )
2895+ {
2896+ yield return new object [ ] { "Argentina Standard Time" , "America/Argentina/Catamarca" } ;
2897+ }
2898+ }
2899+
28522900 [ ConditionalTheory ( typeof ( PlatformDetection ) , nameof ( PlatformDetection . IsNotBrowser ) ) ]
2853- [ InlineData ( "Pacific Standard Time" , "America/Los_Angeles" ) ]
2854- [ InlineData ( "AUS Eastern Standard Time" , "Australia/Sydney" ) ]
2855- [ InlineData ( "GMT Standard Time" , "Europe/London" ) ]
2856- [ InlineData ( "Tonga Standard Time" , "Pacific/Tongatapu" ) ]
2857- [ InlineData ( "W. Australia Standard Time" , "Australia/Perth" ) ]
2858- [ InlineData ( "E. South America Standard Time" , "America/Sao_Paulo" ) ]
2859- [ InlineData ( "E. Africa Standard Time" , "Africa/Nairobi" ) ]
2860- [ InlineData ( "W. Europe Standard Time" , "Europe/Berlin" ) ]
2861- [ InlineData ( "Russian Standard Time" , "Europe/Moscow" ) ]
2862- [ InlineData ( "Libya Standard Time" , "Africa/Tripoli" ) ]
2863- [ InlineData ( "South Africa Standard Time" , "Africa/Johannesburg" ) ]
2864- [ InlineData ( "Morocco Standard Time" , "Africa/Casablanca" ) ]
2865- [ InlineData ( "Argentina Standard Time" , "America/Argentina/Catamarca" ) ]
2866- [ InlineData ( "Newfoundland Standard Time" , "America/St_Johns" ) ]
2867- [ InlineData ( "Iran Standard Time" , "Asia/Tehran" ) ]
2901+ [ MemberData ( nameof ( AlternativeName_TestData ) ) ]
28682902 public static void UsingAlternativeTimeZoneIdsTest ( string windowsId , string ianaId )
28692903 {
28702904 if ( PlatformDetection . ICUVersion . Major >= 52 && ! PlatformDetection . IsiOS && ! PlatformDetection . IstvOS )
0 commit comments