C# Program to Get the DayLight Saving Information
Posted by Superadmin on August 11 2022 08:46:40

C# Program to Get the DayLight Saving Information

 

This is a C# Program to get the daylight saving information.

Problem Description

This C# Program Gets the DayLight Saving Information.

Problem Solution

Here the information about the current year’s daylight saving changes is obtained.

Program/Source Code

Here is source code of the C# Program to Get the DayLight Saving Information. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Get the DayLight Saving Information
 */
using System;
using System.Globalization;
class Program
{
    static void Main()
    {
        TimeZone z = TimeZone.CurrentTimeZone;
        DaylightTime t = z.GetDaylightChanges(DateTime.Today.Year);
        Console.WriteLine("Start Time: {0}", t.Start);
        Console.WriteLine("Delta Time: {0}", t.Delta);
        Console.WriteLine("End Time: {0}", t.End);
        Console.ReadLine();
    }
}
Program Explanation

This C# program is used to get the DayLight saving information. The GetDaylightChanges() function indicates whether a specified date and time falls in the range of daylight saving time for the time zone of the current TimeZoneInfo object. Then the information about the current year’s daylight saving changes is obtained.

 
Runtime Test Cases
 
Start Time: 1/1/0001 12:00:00 AM
Delta Time: 00:00:00
End Time: 1/1/0001 12:00:00 AM