Whether the specified date and time is within a daylight saving time period.
using System;
using System.Globalization;
class DaylightTimeDemo
{
static void Main( )
{
const string headFmt = "{0,-22}{1,-10}{2,-10}{3,-10}{4}";
TimeZone localZone = TimeZone.CurrentTimeZone;
DateTime localTime = new DateTime( 2001, 1, 1 );
Console.WriteLine(localZone.StandardName );
DaylightTime daylight2001 = localZone.GetDaylightChanges( 2001 );
DaylightTime daylight2002 = localZone.GetDaylightChanges( 2002 );
DateTime utcTime = localZone.ToUniversalTime( localTime );
Console.WriteLine(localTime);
Console.WriteLine(TimeZone.IsDaylightSavingTime(localTime, daylight2001 ));
Console.WriteLine(TimeZone.IsDaylightSavingTime(localTime, daylight2002 ));
Console.WriteLine(localZone.IsDaylightSavingTime( localTime ));
Console.WriteLine(utcTime );
}
}
Related examples in the same category