For example, when I try to do the following.
TimeZoneInfo.FindSystemTimeZoneById(\"Central European Standard Time\")
I get the error, that
Working of off the previous answer, we can avoid the expensive try/catch by checking which OS we're running on:
using System;
using System.Runtime.InteropServices;
TimeZoneInfo easternStandardTime;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
easternStandardTime = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
easternStandardTime = TimeZoneInfo.FindSystemTimeZoneById("America/New_York");
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
throw new NotImplementedException("I don't know how to do a lookup on a Mac.");
}