TimeZoneInfo.SupportsDaylightSavingTime Property

July 28, 2014

Gets a value indicating whether the time zone has any daylight saving time rules.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public bool SupportsDaylightSavingTime { get; }

Property Value

Type: System.Boolean
true if the time zone supports daylight saving time; otherwise, false.

On Windows systems, the value of the SupportsDaylightSavingTime property for the local time zone returned by the TimeZoneInfo.Local property reflects the setting of the Control Panel Date and Time application's checkbox that defines whether the system automatically adjusts for daylight saving time. If it is unchecked, or if no checkbox is displayed for a time zone, the value of this property is false.

Version Notes

XNA Framework

 When this property is used in the XNA Framework, it throws a NotSupportedException exception.

The following example determines whether the local time zone supports daylight saving time and, if it does, determines whether a particular date and time is ambiguous or invalid. If the time is not ambiguous or invalid, the example displays it and converts it to Coordinated Universal Time (UTC). The output is generated by a system in the U.S. Pacific Standard Time zone.


using System;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      string[] dateStrings = {"1/1/2009 12:00 AM", "6/15/2008 3:00 PM", 
                              "3/9/2008 2:30 AM", "3/9/2008 3:00 AM", 
                              "11/2/2008 1:30 AM", "11/2/2008 2:20 AM"};
      foreach (string dateString in dateStrings)
      {
         DateTime date;
         if (DateTime.TryParse(dateString, out date))
         {
            if (TimeZoneInfo.Local.SupportsDaylightSavingTime)
            {
               if (TimeZoneInfo.Local.IsAmbiguousTime(date))
                  outputBlock.Text += string.Format("{0} is ambiguous in the {1} zone.\n", 
                                                    date, TimeZoneInfo.Local.StandardName);
               else if (TimeZoneInfo.Local.IsInvalidTime(date))
                  outputBlock.Text += string.Format("{0} is invalid in the {1} zone.\n", 
                                                    date, TimeZoneInfo.Local.StandardName);
               else if (TimeZoneInfo.Local.IsDaylightSavingTime(date))
                  outputBlock.Text += string.Format("{0} {1} is {2} UTC.\n", 
                                                    date, TimeZoneInfo.Local.DaylightName,
                                                    date.ToUniversalTime());                  
               else
                  outputBlock.Text += string.Format("{0} {1} is {2} UTC.\n", 
                                                    date, TimeZoneInfo.Local.StandardName,
                                                    date.ToUniversalTime());                  
            }
            else
            {
               outputBlock.Text += string.Format("{0} {1} is {2} UTC.\n", 
                                                 date, TimeZoneInfo.Local.StandardName,
                                                 date.ToUniversalTime());                  
            }
         }
         outputBlock.Text += "\n";         
      }                           
   }
}
// The example displays the following output:
//    1/1/2009 12:00:00 AM Pacific Standard TIme is 1/1/2009 8:00:00 AM UTC.
//    
//    6/15/2008 3:00:00 PM Pacific Daylight Time is 6/15/2008 10:00:00 PM UTC.
//    
//    3/9/2008 2:30:00 AM is invalid in the Pacific Standard Time zone.
//    
//    3/9/2008 3:00:00 AM Pacific Daylight Time is 3/9/2008 10:00:00 AM UTC.
//    
//    11/2/2008 1:30:00 AM is ambiguous in the Pacific Standard Time zone.
//    
//    11/2/2008 2:20:00 AM Pacific Standard TIme is 11/2/2008 10:20:00 AM UTC.


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft