C# - TimeZoneInfo.SupportsDaylightSavingTime Property with Example

In this tutorial, we will learn about the C# TimeZoneInfo.SupportsDaylightSavingTime property with its definition, usage, syntax, and example. By Nidhi Last updated : March 31, 2023

TimeZoneInfo.SupportsDaylightSavingTime Property

The TimeZoneInfo.SupportsDaylightSavingTime property is used to check whether the time zone has any daylight-saving time rules or not.

Syntax

bool TimeZoneInfo.SupportsDaylightSavingTime

Parameter(s)

  • None

Return Value

It returns a boolean value that denotes available time zones are daylight-saving time rules or not. If the time zone supports daylight time, then it returns true otherwise it returns false.

C# Example of TimeZoneInfo.SupportsDaylightSavingTime Property

The source code to demonstrate the example for TimeZoneInfo.SupportsDaylightSavingTime Property is given below. The given program is compiled and executed successfully.

using System;
using System.Globalization;
using System.Collections.ObjectModel;

class TimeZoneInfoDemo {
  //Entry point of Program
  static public void Main() {
    ReadOnlyCollection < TimeZoneInfo > timeZones;

    timeZones = TimeZoneInfo.GetSystemTimeZones();

    Console.WriteLine("Supported daylight saving time:");
    foreach(TimeZoneInfo timeZone in timeZones) {
      if (!timeZone.SupportsDaylightSavingTime)
        Console.WriteLine("\t" + timeZone.DisplayName);
    }
  }
}

Output

Supported daylight saving time:
        (UTC-12:00) International Date Line West
        (UTC-11:00) Midway Island, Samoa
        (UTC-10:00) Hawaii
        (UTC-07:00) Arizona
        (UTC-06:00) Central America
        (UTC-06:00) Saskatchewan
        (UTC-05:00) Bogota, Lima, Quito
        (UTC-05:00) Indiana (East)
        (UTC-04:30) Caracas
        (UTC-04:00) Georgetown, La Paz, San Juan
        (UTC-03:00) Cayenne
        (UTC-01:00) Cape Verde Is.
        (UTC) Coordinated Universal Time
        (UTC) Monrovia, Reykjavik
        (UTC+01:00) West Central Africa
        (UTC+02:00) Harare, Pretoria
        (UTC+03:00) Kuwait, Riyadh
        (UTC+03:00) Nairobi
        (UTC+03:00) Tbilisi
        (UTC+04:00) Abu Dhabi, Muscat
        (UTC+04:30) Kabul
        (UTC+05:00) Tashkent
        (UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi
        (UTC+05:30) Sri Jayawardenepura
        (UTC+05:45) Kathmandu
        (UTC+06:00) Astana, Dhaka
        (UTC+06:30) Yangon (Rangoon)
        (UTC+07:00) Bangkok, Hanoi, Jakarta
        (UTC+08:00) Beijing, Chongqing, Hong Kong, Urumqi
        (UTC+08:00) Kuala Lumpur, Singapore
        (UTC+08:00) Taipei
        (UTC+09:00) Osaka, Sapporo, Tokyo
        (UTC+09:00) Seoul
        (UTC+09:30) Darwin
        (UTC+10:00) Brisbane
        (UTC+10:00) Guam, Port Moresby
        (UTC+11:00) Magadan, Solomon Is., New Caledonia
        (UTC+12:00) Fiji, Marshall Is.
        (UTC+13:00) Nuku'alofa
Press any key to continue . . .

C# TimeZoneInfo Class Programs »





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.