The IsDaylightSavingTime and GetUtcOffset methods work as follows:
using System;
using System.Text;
class Sample
{
public static void Main()
{
TimeZone zone = TimeZone.CurrentTimeZone;
DateTime dt1 = new DateTime(2008, 1, 1);
DateTime dt2 = new DateTime(2008, 6, 1);
Console.WriteLine(zone.IsDaylightSavingTime(dt1));
Console.WriteLine(zone.IsDaylightSavingTime(dt2));
}
}
The output:
False
True
GetDaylightChanges method returns specific daylight saving time information for a given year:
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
TimeZone zone = TimeZone.CurrentTimeZone;
DaylightTime day = zone.GetDaylightChanges(2008);
Console.WriteLine(day.Start);
Console.WriteLine(day.End);
Console.WriteLine(day.Delta);
}
}
The output:
3/9/2008 2:00:00 AM
11/2/2008 2:00:00 AM
01:00:00
TimeZoneInfo IsDaylightSavingTime method accepts either a DateTime or a DateTimeOffset
using System;
using System.Text;
using System.Globalization;
class Sample
{
public static void Main()
{
TimeZoneInfo zone = TimeZoneInfo.Local;
DateTime dt1 = new DateTime(2008, 1, 1);
Console.WriteLine(zone.IsDaylightSavingTime(dt1));
DateTime dt = new DateTime(2008, 1, 1);
Console.WriteLine(zone.IsDaylightSavingTime(dt));
}
}
The output:
False
False