-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
As announced here: https://devblogs.microsoft.com/dotnet/date-time-and-time-zone-enhancements-in-net-6/
starting with .NET 6 TimeZoneInfo.FindSystemTimeZoneById should now support IANA timezone ids. That works just fine on Windows 10/10 & Windows Server 2022. It does not work on Windows Server 2016 & 2019 thought. Those are versions user by Azure App Services today. So, this functionality simple does not work on Azure.
Reproduction Steps
System.Console.WriteLine("{0}", System.TimeZoneInfo.FindSystemTimeZoneById("Europe/Copenhagen").Id);
Expected behavior
IANA timezone is resolved no matter what OS the code is run on.
Actual behavior
It is not resolved.
Regression?
Technically, it's not a regression. But, TimeZoneConverter library which was recommended to use before seems to be struggling to find a new maintainer: https://github.com/mattjohnsonpint/TimeZoneConverter/issues/105 which means it may not have regular updates in the future.
Known Workarounds
Add this to a project file helps:
<ItemGroup>
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2" />
</ItemGroup>This, however, has to be done to every single project which is tedious, time-consuming and error-prone.
Moreover, if we have a test DLL which uses TimeZoneInfo.FindSystemTimeZoneById, this workaround does not work (it only applies to EXEs).
Configuration
No response
Other information
No response