C# TimeZoneInfo IsDaylightSavingTime(DateTimeOffset)
Description
TimeZoneInfo IsDaylightSavingTime(DateTimeOffset)
indicates
whether a specified date and time falls in the range of daylight saving time
for the time zone of the current TimeZoneInfo object.
Syntax
TimeZoneInfo.IsDaylightSavingTime(DateTimeOffset)
has the following syntax.
public bool IsDaylightSavingTime(
DateTimeOffset dateTimeOffset
)
Parameters
TimeZoneInfo.IsDaylightSavingTime(DateTimeOffset)
has the following parameters.
dateTimeOffset
- A date and time value.
Returns
TimeZoneInfo.IsDaylightSavingTime(DateTimeOffset)
method returns true if the dateTimeOffset parameter is a daylight saving time; otherwise,
false.
Example
using System;//from www . ja v a2s .c om
public class MainClass
{
public static void Main(String[] argv)
{
DateTimeOffset unclearDate = DateTimeOffset.Now;
Console.WriteLine("In the {0}, {1} is {2}ambiguous.",
TimeZoneInfo.Local.DisplayName,
unclearDate,
TimeZoneInfo.Local.IsAmbiguousTime(unclearDate) ? "" : "not ");
// Test if time is DST.
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);
}
}
The code above generates the following result.