Plunging into .NET Development

Weblog Pieter Gheysens
Microsoft .NET Development - C# - Enterprise Library - Visual Studio 2005 Team System - Compuware DevPartner - ...
 


Tuesday, July 24

How to find switch-dates for daylight saving time?

After my previous post about the daylight saving time, someone asked me how he could dynamically retrieve the switch-dates for the daylight saving time in .NET ...

class Program

{

    static void Main(string[] args)

    {

        for (int i = 2007; i < 2010; i++)

        {

            DaylightTime daylightTime = TimeZone.CurrentTimeZone.GetDaylightChanges(i);

            Console.WriteLine("year : " + i.ToString());

            Console.WriteLine("- switch winter/summer : " + daylightTime.Start.ToString());

            Console.WriteLine("- switch summer/winter : " + daylightTime.End.ToString());

            Console.WriteLine("");

        }

 

        Console.ReadLine();

    }

}


Labels:

0 Comments:

Post a Comment

<< Home