Whether a date and time falls in the range of daylight saving time
using System;
public class Example
{
public static void Main()
{
DateTime unclearDate = new DateTime(2010, 5, 4, 1, 30, 0);
Console.WriteLine("In the {0}, {1} is {2}ambiguous.",
TimeZoneInfo.Local.DisplayName,
unclearDate,
TimeZoneInfo.Local.IsAmbiguousTime(unclearDate) ? "" : "not ");
Console.WriteLine("In the {0}, {1} is {2}daylight saving time.",
TimeZoneInfo.Local.DisplayName,
unclearDate,
TimeZoneInfo.Local.IsDaylightSavingTime(unclearDate) ? "" : "not ");
if (TimeZoneInfo.Local.IsAmbiguousTime(unclearDate) || TimeZoneInfo.Local.IsDaylightSavingTime(unclearDate))
Console.WriteLine("{0} may be daylight saving time in {1}.", unclearDate, TimeZoneInfo.Local.DisplayName);
}
}
Related examples in the same category