TimeZoneInfo.AdjustmentRule.DateStart Eigenschaft

Definition

Ruft das Datum ab, zu dem die Anpassungsregel wirksam wird.Gets the date when the adjustment rule takes effect.

public:
 property DateTime DateStart { DateTime get(); };
public DateTime DateStart { get; }
member this.DateStart : DateTime
Public ReadOnly Property DateStart As DateTime

Eigenschaftswert

Ein DateTime-Wert, der angibt, wann die Anpassungsregel wirksam wird.A DateTime value that indicates when the adjustment rule takes effect.

Beispiele

Im folgenden Beispiel werden Informationen zu allen Zeitzonen angezeigt, die in der Systemregistrierung des lokalen Computers definiert sind, einschließlich der Start-und Enddaten der Anpassungsregeln.The following example displays information about all of the time zones defined in the local computer's system registry, including the starting and ending dates of their adjustment rules.

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

public class Example
{
   public static void Main()
   {
      ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
      DateTimeFormatInfo dateInfo = CultureInfo.CurrentCulture.DateTimeFormat;
      
      foreach (var zone in timeZones)
      {
         Console.WriteLine("{0} transition time information:", zone.StandardName);
         Console.WriteLine("   Time zone information: ");
         Console.WriteLine("      Base UTC Offset: {0}", zone.BaseUtcOffset);
         Console.WriteLine("      Supports DST: {0}", zone.SupportsDaylightSavingTime);

         TimeZoneInfo.AdjustmentRule[] adjustmentRules= zone.GetAdjustmentRules();
         
         // Indicate that time zone has no adjustment rules
         if (adjustmentRules.Length == 0) {
            Console.WriteLine("      No adjustment rules defined.");
         }   
         else {
            Console.WriteLine("      Adjustment Rules: {0}", adjustmentRules.Length);
            // Iterate adjustment rules       
            foreach (var adjustmentRule in adjustmentRules) {
               Console.WriteLine("   Adjustment rule from {0:d} to {1:d}:", 
                                 adjustmentRule.DateStart, 
                                 adjustmentRule.DateEnd);                                 
               Console.WriteLine("      Delta: {0}", adjustmentRule.DaylightDelta);
               // Get start of transition
               TimeZoneInfo.TransitionTime daylightStart = adjustmentRule.DaylightTransitionStart;
               // Display information on floating date rule
               if (! daylightStart.IsFixedDateRule)
                  Console.WriteLine("      Begins at {0:t} on the {1} {2} of {3}", 
                                 daylightStart.TimeOfDay, 
                                 (WeekOfMonth) daylightStart.Week,  
                                 daylightStart.DayOfWeek, 
                                 dateInfo.GetMonthName(daylightStart.Month));
               // Display information on fixed date rule 
               else
                  Console.WriteLine("      Begins at {0:t} on {1} {2}", 
                                    daylightStart.TimeOfDay, 
                                    dateInfo.GetMonthName(daylightStart.Month), 
                                    daylightStart.Day);
               
               // Get end of transition.
              TimeZoneInfo.TransitionTime daylightEnd = adjustmentRule.DaylightTransitionEnd;
               // Display information on floating date rule.
               if (!daylightEnd.IsFixedDateRule) 
                  Console.WriteLine("      Ends at {0:t} on the {1} {2} of {3}", 
                                 daylightEnd.TimeOfDay, 
                                 (WeekOfMonth) daylightEnd.Week,  
                                 daylightEnd.DayOfWeek, 
                                 dateInfo.GetMonthName(daylightEnd.Month));
               // Display information on fixed date rule.
               else
                  Console.WriteLine("      Ends at {0:t} on {1} {2}", 
                                    daylightEnd.TimeOfDay, 
                                    dateInfo.GetMonthName(daylightEnd.Month), 
                                    daylightEnd.Day);
            }
         }   
      }   
   }

   private enum WeekOfMonth 
   {
      First = 1,
      Second = 2,
      Third = 3,
      Fourth = 4,
      Last = 5,
   }
}
// A portion of the output from the example might appear as follows:
//       Tonga Standard Time transition time information:
//          Time zone information:
//             Base UTC Offset: 13:00:00
//             Supports DST: False
//             No adjustment rules defined.
//       Samoa Standard Time transition time information:
//          Time zone information:
//             Base UTC Offset: 13:00:00
//             Supports DST: True
//             Adjustment Rules: 4
//          Adjustment rule from 1/1/0001 to 12/31/2009:
//             Delta: 00:00:00
//             Begins at 12:00 AM on January 1
//             Ends at 12:00 AM on January 1
//          Adjustment rule from 1/1/2010 to 12/31/2010:
//             Delta: 01:00:00
//             Begins at 11:59 PM on the Last Saturday of September
//             Ends at 12:00 AM on the First Friday of January
//          Adjustment rule from 1/1/2011 to 12/31/2011:
//             Delta: 01:00:00
//             Begins at 3:00 AM on the Fourth Saturday of September
//             Ends at 4:00 AM on the First Saturday of April
//          Adjustment rule from 1/1/2012 to 12/31/9999:
//             Delta: 01:00:00
//             Begins at 12:00 AM on the Last Sunday of September
//             Ends at 1:00 AM on the First Sunday of April
//       Line Islands Standard Time transition time information:
//          Time zone information:
//             Base UTC Offset: 14:00:00
//             Supports DST: False
//             No adjustment rules defined.
Imports System.Collections.ObjectModel
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim timeZones As ReadOnlyCollection(Of TimeZoneInfo) = TimeZoneInfo.GetSystemTimeZones()
      Dim dateInfo As DateTimeFormatInfo = CultureInfo.CurrentCulture.DateTimeFormat
      
      For Each zone In timeZones
         Console.WriteLine("{0} transition time information:", zone.StandardName)
         Console.WriteLine("   Time zone information: ")
         Console.WriteLine("      Base UTC Offset: {0}", zone.BaseUtcOffset)
         Console.WriteLine("      Supports DST: {0}", zone.SupportsDaylightSavingTime)

         Dim adjustmentRules() As TimeZoneInfo.AdjustmentRule = zone.GetAdjustmentRules()
         
         ' Indicate that time zone has no adjustment rules
         If adjustmentRules.Length = 0 Then
            Console.WriteLine("      No adjustment rules defined.")
         Else
            Console.WriteLine("      Adjustment Rules: {0}", adjustmentRules.Length)
            ' Iterate adjustment rules       
            For Each adjustmentRule In adjustmentRules
               Console.WriteLine("   Adjustment rule from {0:d} to {1:d}:", 
                                 adjustmentRule.DateStart, 
                                 adjustmentRule.DateEnd)                                 
               Console.WriteLine("      Delta: {0}", adjustmentRule.DaylightDelta)
               ' Get start of transition
               Dim daylightStart As TimeZoneInfo.TransitionTime = adjustmentRule.DaylightTransitionStart
               ' Display information on floating date rule
               If Not daylightStart.IsFixedDateRule Then
                  Console.WriteLine("      Begins at {0:t} on the {1} {2} of {3}", 
                                 daylightStart.TimeOfDay, 
                                 CType(daylightStart.Week, WeekOfMonth),  
                                 daylightStart.DayOfWeek, 
                                 dateInfo.GetMonthName(daylightStart.Month))
               ' Display information on fixed date rule 
               Else
                  Console.WriteLine("      Begins at {0:t} on {1} {2}", 
                                    daylightStart.TimeOfDay, 
                                    dateInfo.GetMonthName(daylightStart.Month), 
                                    daylightStart.Day)
               End If
               
               ' Get end of transition.
               Dim daylightEnd As TimeZoneInfo.TransitionTime = adjustmentRule.DaylightTransitionEnd
               ' Display information on floating date rule.
               If Not daylightEnd.IsFixedDateRule Then 
                  Console.WriteLine("      Ends at {0:t} on the {1} {2} of {3}", 
                                 daylightEnd.TimeOfDay, 
                                 CType(daylightEnd.Week, WeekOfMonth),  
                                 daylightEnd.DayOfWeek, 
                                 dateInfo.GetMonthName(daylightEnd.Month))
               ' Display information on fixed date rule.
               Else
                  Console.WriteLine("      Ends at {0:t} on {1} {2}", 
                                    daylightEnd.TimeOfDay, 
                                    dateInfo.GetMonthName(daylightEnd.Month), 
                                    daylightEnd.Day)
               End If
            Next
         End If   
      Next   
   End Sub

   Private Enum WeekOfMonth As Integer
      First = 1
      Second = 2
      Third = 3
      Fourth = 4
      Last = 5
   End Enum
End Module
' A portion of the output from the example might appear as follows:
'       Tonga Standard Time transition time information:
'          Time zone information:
'             Base UTC Offset: 13:00:00
'             Supports DST: False
'             No adjustment rules defined.
'       Samoa Standard Time transition time information:
'          Time zone information:
'             Base UTC Offset: 13:00:00
'             Supports DST: True
'             Adjustment Rules: 4
'          Adjustment rule from 1/1/0001 to 12/31/2009:
'             Delta: 00:00:00
'             Begins at 12:00 AM on January 1
'             Ends at 12:00 AM on January 1
'          Adjustment rule from 1/1/2010 to 12/31/2010:
'             Delta: 01:00:00
'             Begins at 11:59 PM on the Last Saturday of September
'             Ends at 12:00 AM on the First Friday of January
'          Adjustment rule from 1/1/2011 to 12/31/2011:
'             Delta: 01:00:00
'             Begins at 3:00 AM on the Fourth Saturday of September
'             Ends at 4:00 AM on the First Saturday of April
'          Adjustment rule from 1/1/2012 to 12/31/9999:
'             Delta: 01:00:00
'             Begins at 12:00 AM on the Last Sunday of September
'             Ends at 1:00 AM on the First Sunday of April
'       Line Islands Standard Time transition time information:
'          Time zone information:
'             Base UTC Offset: 14:00:00
'             Supports DST: False
'             No adjustment rules defined.

Hinweise

Der Wert DateStart der-Eigenschaft ist ein Datumswert ohne Zeitkomponente.The value of the DateStart property is a date value without a time component. Er definiert das Datum, an dem eine bestimmte Anpassungs Regel wirksam wird.It defines the date on which a particular adjustment rule goes into effect. Dies ist das Datum, an dem eine Reihe von Übergängen (die in der Regel durch einen Übergang zur Sommerzeit und einen Übergang zurück zur Standardzeit definiert werden) wirksam werden.This is the date in which a set of transitions (which typically are defined by one transition to daylight savings time and one transition back to standard time) go into effect. Beispielsweise kann eine Anpassungs Regel ab dem 1. Januar 2017 wirksam werden, die einen Übergang zur Sommerzeit am zweiten Sonntag im März und für einen Übergang zurück zur Standardzeit am ersten Sonntag im November bereitstellt.For example, an adjustment rule might go into effect on January 1, 2017, that provides for a transition to daylight savings time on the second Sunday of March and for a transition back to standard time on the first Sunday of November. Beachten Sie, dass das Startdatum der Anpassungs Regel nicht an das Datum des ersten Übergangs gebunden ist.Note that the starting date of the adjustment rule is not tied to the date of the first transition.

Sie können der DateTime.MinValue.Date -Eigenschaft DateEnd zuweisen, wenn Sie eine benutzerdefinierte Anpassungs Regel für die Verwendung in einer Zeit Zonen fähigen Anwendung erstellen, die nicht mit historischen Zeitzoneninformationen arbeiten muss.You can assign DateTime.MinValue.Date to the DateEnd property when you create a custom adjustment rule for use in a time zone-aware application that does not have to work with historic time zone information.

Wichtig

Sofern es keinen überzeugenden Grund dafür gibt, sollten Sie das Startdatum der Anpassungs Regel so definieren, dass es innerhalb des Zeitintervalls auftritt, in dem die Zeitzone die Normalzeit beachtet.Unless there is a compelling reason to do otherwise, you should define the adjustment rule's start date to occur within the time interval during which the time zone observes standard time. Sofern es keinen überzeugenden Grund gibt, sollten Sie das Startdatum der Anpassungs Regel nicht so definieren, dass es innerhalb des Zeitintervalls auftritt, in dem die Zeitzone die Sommerzeit beobachtet.Unless there is a compelling reason to do so, you should not define the adjustment rule's start date to occur within the time interval during which the time zone observes daylight saving time. Wenn z. b. der Übergang einer Zeitzone von Sommerzeit am dritten Sonntag im März stattfindet und der Übergang zur Sommerzeit am ersten Sonntag im Oktober stattfindet, sollte das effektive Startdatum der Anpassungs Regel nicht der 1. Januar eines bestimmten Jahr, da dieses Datum innerhalb des Zeitraums der Sommerzeit liegt.For example, if a time zone's transition from daylight saving time occurs on the third Sunday of March and its transition to daylight saving time occurs on the first Sunday of October, the effective start date of the adjustment rule should not be January 1 of a particular year, since that date occurs within the period of daylight saving time.

Standardmäßig definiert die Registrierung in Windows XP für jede Zeitzone eine einzelne Anpassungs Regel, deren Startdatum Montag, 01. Januar 0001 (der DateTime.MinValue.DateWert von) ist.By default, the registry in Windows XP defines a single adjustment rule whose start date is Monday, January 01, 0001 (the value of DateTime.MinValue.Date), for each time zone. Für Zeitzonen in der USA definiert die Registrierung in Windows Vista zwei Anpassungsregeln:For time zones in the United States, the registry in Windows Vista defines two adjustment rules:

  • Montag, 01. Januar 0001, bis Sonntag, 31. Dezember 2006.Monday, January 01, 0001, to Sunday, December 31, 2006.

  • Montag, 01. Januar 2007, bis Freitag, 31. Dezember 9999.Monday, January 01, 2007, to Friday, December 31, 9999.

Dies bedeutet, dass Zeit Zonen Anpassungsregeln, die in der Registrierung gespeichert sind, für die Durchführung aktueller Zeit Zonen bezogener Vorgänge nützlich sind. Sie können jedoch nicht zuverlässig zum Abrufen von Verlaufs Zeitzoneninformationen verwendet werden.This means that, although time zone adjustment rules stored in the registry are useful for performing current time zone-related operations, they cannot be reliably used for retrieving historical time zone information. Informationen zum Definieren einer benutzerdefinierten Zeitzone mit mehreren Anpassungsregeln, die in einer historischen Zeit Zonen fähigen Anwendung verwendet werden können, finden Sie unter Gewusst wie: Erstellen von Zeitzonen mit Anpassungsregeln.For information about defining a custom time zone with multiple adjustment rules that can be used in a historical time zone-aware application, see How to: Create Time Zones with Adjustment Rules.

Gilt für: