I\'m using NodaTime because of its nice support for zoneinfo data, however I have a case where I need to convert the DateTimeZone
into TimeZoneInfo
for
You can use TimeZoneConverter library by Matt Johnson.
ZoneId used by NodeTime TzdbZoneLocation is IANA time zone, so you can get TimeZoneInfo like this:
string windowsTimeZoneName = TZConvert.IanaToWindows(tzdbZoneLocation.ZoneId);
var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(windowsTimeZoneName);
Don't forget to wrap it with try-catch with some kind of fallback just in case.
Also look at original Matt Johnson solution for converting between IANA time zone and Windows time zone.