Puerto Rico and several other countries do not have a daylight savings time. I don't see a way to specify whether or not a given country/locale supports daylight savings time using the TimeZoneInfo class.
DateTime dt = DateTime.UtcNow;
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Atlantic Standard Time");
if (tz.IsDaylightSavingTime(dt))
Console.WriteLine("Daylight Savings");
About the only thing I can think of is to allow the user to specify both the Time Zone and also whether to adjust for Daylight Savings, and then use TimeZoneInfo.GetUtcOffset instead of the more direct TimeZoneInfo.ConvertTimeFromUtc method.
if (tz.IsDaylightSavingTime(dt) && !supportsDaylightSaving)
{
var utcOffset = new DateTimeOffset(dt, TimeSpan.Zero).AddHours(-1);
var dt3 = utcOffset.ToOffset(tz.GetUtcOffset(utcOffset)).DateTime;
Console.WriteLine(dt3);
}
Any other approaches to consider? Anything bad about the above approach?