xxxxxxxxxx
static string GetWindowsTimeZoneId(TimeZoneInfo tzi)
{
if (!tzi.HasIanaId)
return tzi.Id; // no conversion necessary
if (TimeZoneInfo.TryConvertIanaIdToWindowsId(tzi.Id, out string winId))
return winId; // use the converted ID
throw new TimeZoneNotFoundException($"No Windows time zone found for "{tzi.Id}".");
}
xxxxxxxxxx
using System;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}