runtime icon indicating copy to clipboard operation
runtime copied to clipboard

FindSystemTimeZoneById doesn't support "Eastern Standard Time" on Ubuntu

Open LexVocoder opened this issue 9 years ago • 1 comments

Method: System.TimeZoneInfo.FindSystemTimeZoneById

According to Time Zone IDs (Compact 2013), this method would accept "Eastern Standard Time" as a parameter. However, on Ubuntu 16.04, this fails with System.TimeZoneNotFoundException: The time zone ID 'Eastern Standard Time' was not found on the local computer. ---> System.IO.FileNotFoundException: Could not find file '/usr/share/zoneinfo/Eastern Standard Time'.

Workaround:

Try the Time Zone ID. If that fails, look up by TZ database value:

            TimeZoneInfo easternTime;
            try {
                 easternTime = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
            }
            catch (Exception ex)
            {
                 easternTime = TimeZoneInfo.FindSystemTimeZoneById("US/Eastern");
            }

dotnet --info output:

dotnet --info .NET Command Line Tools (1.0.1)

Product Information: Version: 1.0.1 Commit SHA-1 hash: 005db40

Runtime Environment: OS Name: ubuntu OS Version: 16.04 OS Platform: Linux RID: ubuntu.16.04-x64 Base Path: /usr/share/dotnet/sdk/1.0.1

LexVocoder avatar Mar 08 '17 19:03 LexVocoder

Issue moved to dotnet/corefx dotnet/coreclr#16871 via ZenHub

gkhanna79 avatar Mar 08 '17 21:03 gkhanna79