TimeZoneInfo.AdjustmentRule TimeZoneInfo.AdjustmentRule TimeZoneInfo.AdjustmentRule TimeZoneInfo.AdjustmentRule Class

Definice

Poskytuje informace o úpravě časového pásma, jako je například přechod do a z letního času.Provides information about a time zone adjustment, such as the transition to and from daylight saving time.

public: ref class TimeZoneInfo::AdjustmentRule sealed : IEquatable<TimeZoneInfo::AdjustmentRule ^>, System::Runtime::Serialization::IDeserializationCallback, System::Runtime::Serialization::ISerializable
[System.Serializable]
public sealed class TimeZoneInfo.AdjustmentRule : IEquatable<TimeZoneInfo.AdjustmentRule>, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
type TimeZoneInfo.AdjustmentRule = class
    interface IEquatable<TimeZoneInfo.AdjustmentRule>
    interface ISerializable
    interface IDeserializationCallback
Public NotInheritable Class TimeZoneInfo.AdjustmentRule
Implements IDeserializationCallback, IEquatable(Of TimeZoneInfo.AdjustmentRule), ISerializable
Dědičnost
TimeZoneInfo.AdjustmentRuleTimeZoneInfo.AdjustmentRuleTimeZoneInfo.AdjustmentRuleTimeZoneInfo.AdjustmentRule
Atributy
Implementuje

Příklady

Následující příklad načte všechna časová pásma definovaná v místním systému a zobrazí kompletní informace o jejich pravidlech úprav.The following example retrieves all time zones defined on the local system and displays complete information about their adjustment rules.

private enum WeekOfMonth 
{
   First = 1,
   Second = 2,
   Third = 3,
   Fourth = 4,
   Last = 5,
}

private static void ShowStartAndEndDates()
{
   // Get all time zones from system
   ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
   string[] monthNames = CultureInfo.CurrentCulture.DateTimeFormat.MonthNames;
   // Get each time zone
   foreach (TimeZoneInfo timeZone in timeZones)
   {
      TimeZoneInfo.AdjustmentRule[] adjustments = timeZone.GetAdjustmentRules();
      // Display message for time zones with no adjustments
      if (adjustments.Length == 0)
      {
         Console.WriteLine("{0} has no adjustment rules", timeZone.StandardName);
      }   
      else
      {
         // Handle time zones with 1 or 2+ adjustments differently
         bool showCount = false;
         int ctr = 0;
         string spacer = "";
         
         Console.WriteLine("{0} Adjustment rules", timeZone.StandardName);
         if (adjustments.Length > 1)
         {
            showCount = true;
            spacer = "   ";
         }   
         // Iterate adjustment rules
         foreach (TimeZoneInfo.AdjustmentRule adjustment in adjustments)
         {
            if (showCount)
            { 
               Console.WriteLine("   Adjustment rule #{0}", ctr+1);
               ctr++;
            }
            // Display general adjustment information
            Console.WriteLine("{0}   Start Date: {1:D}", spacer, adjustment.DateStart);
            Console.WriteLine("{0}   End Date: {1:D}", spacer, adjustment.DateEnd);
            Console.WriteLine("{0}   Time Change: {1}:{2:00} hours", spacer, 
                              adjustment.DaylightDelta.Hours, adjustment.DaylightDelta.Minutes);
            // Get transition start information
            TimeZoneInfo.TransitionTime transitionStart = adjustment.DaylightTransitionStart;
            Console.Write("{0}   Annual Start: ", spacer);
            if (transitionStart.IsFixedDateRule)
            {
               Console.WriteLine("On {0} {1} at {2:t}", 
                                 monthNames[transitionStart.Month - 1], 
                                 transitionStart.Day, 
                                 transitionStart.TimeOfDay);
            }
            else
            {
               Console.WriteLine("The {0} {1} of {2} at {3:t}", 
                                 ((WeekOfMonth)transitionStart.Week).ToString(), 
                                 transitionStart.DayOfWeek.ToString(), 
                                 monthNames[transitionStart.Month - 1], 
                                 transitionStart.TimeOfDay);
            }
            // Get transition end information
            TimeZoneInfo.TransitionTime transitionEnd = adjustment.DaylightTransitionEnd;
            Console.Write("{0}   Annual End: ", spacer);
            if (transitionEnd.IsFixedDateRule)
            {
               Console.WriteLine("On {0} {1} at {2:t}", 
                                 monthNames[transitionEnd.Month - 1], 
                                 transitionEnd.Day, 
                                 transitionEnd.TimeOfDay);
            }
            else
            {
               Console.WriteLine("The {0} {1} of {2} at {3:t}", 
                                 ((WeekOfMonth)transitionEnd.Week).ToString(), 
                                 transitionEnd.DayOfWeek.ToString(), 
                                 monthNames[transitionEnd.Month - 1], 
                                 transitionEnd.TimeOfDay);
            }
         }
      }   
      Console.WriteLine();
   } 
}
Private Enum WeekOfMonth As Integer
   First = 1
   Second = 2
   Third = 3
   Fourth = 4
   Last = 5
End Enum

Private Sub ShowStartAndEndDates()
   ' Get all time zones from system
   Dim timeZones As ReadOnlyCollection(Of TimeZoneInfo) = TimeZoneInfo.GetSystemTimeZones()
   ' Get each time zone
   For Each timeZone As TimeZoneInfo In timeZones
      Dim adjustments() As TimeZoneInfo.AdjustmentRule = timeZone.GetAdjustmentRules()
      ' Display message for time zones with no adjustments
      If adjustments.Length = 0 Then
         Console.WriteLine("{0} has no adjustment rules", timeZone.StandardName)
      Else
         ' Handle time zones with 1 or 2+ adjustments differently
         Dim showCount As Boolean = False
         Dim ctr As Integer = 0
         Dim spacer As String = ""
         
         Console.WriteLine("{0} Adjustment rules", timeZone.StandardName)
         If adjustments.Length > 1 Then showCount = True : spacer = "   "  
         ' Iterate adjustment rules
         For Each adjustment As TimeZoneInfo.AdjustmentRule in adjustments
            If showCount Then 
               Console.WriteLine("   Adjustment rule #{0}", ctr+1)
               ctr += 1
            End If
            ' Display general adjustment information
            Console.WriteLine("{0}   Start Date: {1:D}", spacer, adjustment.DateStart)
            Console.WriteLine("{0}   End Date: {1:D}", spacer, adjustment.DateEnd)
            Console.WriteLine("{0}   Time Change: {1}:{2:00} hours", spacer, _
                              adjustment.DaylightDelta.Hours, adjustment.DaylightDelta.Minutes)
            ' Get transition start information
            Dim transitionStart As TimeZoneInfo.TransitionTime = adjustment.DaylightTransitionStart
            Console.Write("{0}   Annual Start: ", spacer)
            If transitionStart.IsFixedDateRule Then
               Console.WriteLine("On {0} {1} at {2:t}", _
                                 MonthName(transitionStart.Month), _
                                 transitionStart.Day, _
                                 transitionStart.TimeOfDay)
            Else
               Console.WriteLine("The {0} {1} of {2} at {3:t}", _
                                 CType(transitionStart.Week, WeekOfMonth).ToString(), _
                                 transitionStart.DayOfWeek.ToString(), _
                                 MonthName(transitionStart.Month), _
                                 transitionStart.TimeOfDay)
            End If
            ' Get transition end information
            Dim transitionEnd As TimeZoneInfo.TransitionTime = adjustment.DaylightTransitionEnd
                              
            Console.Write("{0}   Annual End: ", spacer)
            If transitionEnd.IsFixedDateRule Then
               Console.WriteLine("On {0} {1} at {2:t}", _
                                 MonthName(transitionEnd.Month), _
                                 transitionEnd.Day, _
                                 transitionEnd.TimeOfDay)
            Else
               Console.WriteLine("The {0} {1} of {2} at {3:t}", _
                                 CType(transitionEnd.Week, WeekOfMonth).ToString(), _
                                 transitionEnd.DayOfWeek.ToString(), _
                                 MonthName(transitionEnd.Month), _
                                 transitionEnd.TimeOfDay)
            End If
         Next
      End If   
      Console.WriteLine()
   Next 
End Sub

Následuje malá část výstupu, která je generována v příkladu.The following is a small portion of the output that is generated by the example. Přesný výstup se bude lišit v závislosti na operačním systému a datu, kdy je tento příklad spuštěn.The exact output will vary depending on the operating system and the date on which the example is run.

Morocco Standard Time Adjustment rules  
   Adjustment rule #1  
      Start Date: Tuesday, January 01, 2008  
      End Date: Wednesday, December 31, 2008  
      Time Change: 1:00 hours  
      Annual Start: The Last Saturday of May at 11:59 PM  
      Annual End: The Last Sunday of August at 11:59 PM  
   Adjustment rule #2  
      Start Date: Thursday, January 01, 2009  
      End Date: Thursday, December 31, 2009  
      Time Change: 1:00 hours  
      Annual Start: The Last Sunday of May at 11:59 PM  
      Annual End: The Third Thursday of August at 11:59 PM  

Coordinated Universal Time has no adjustment rules  

GMT Standard Time Adjustment rules  
   Start Date: Monday, January 01, 0001  
   End Date: Friday, December 31, 9999  
   Time Change: 1:00 hours  
   Annual Start: The Last Sunday of March at 1:00 AM  
   Annual End: The Last Sunday of October at 2:00 AM  

Greenwich Standard Time has no adjustment rules  

W. Europe Standard Time Adjustment rules  
   Start Date: Monday, January 01, 0001  
   End Date: Friday, December 31, 9999  
   Time Change: 1:00 hours  
   Annual Start: The Last Sunday of March at 2:00 AM  
   Annual End: The Last Sunday of October at 3:00 AM  

Central Europe Standard Time Adjustment rules  
   Start Date: Monday, January 01, 0001  
   End Date: Friday, December 31, 9999  
   Time Change: 1:00 hours  
   Annual Start: The Last Sunday of March at 2:00 AM  
   Annual End: The Last Sunday of October at 3:00 AM  

Romance Standard Time Adjustment rules  
   Start Date: Monday, January 01, 0001  
   End Date: Friday, December 31, 9999  
   Time Change: 1:00 hours  
   Annual Start: The Last Sunday of March at 2:00 AM  
   Annual End: The Last Sunday of October at 3:00 AM  

Central European Standard Time Adjustment rules  
   Start Date: Monday, January 01, 0001  
   End Date: Friday, December 31, 9999  
   Time Change: 1:00 hours  
   Annual Start: The Last Sunday of March at 2:00 AM  
   Annual End: The Last Sunday of October at 3:00 AM  

W. Central Africa Standard Time has no adjustment rules  

Poznámky

TimeZoneInfo.AdjustmentRule Třída definuje efektivní počáteční a koncové datum konkrétního časového přechodu do a z letního času, v uvedeném pořadí, a také jeho rozdíl (přesnou částku, o kterou úprava způsobí změnu standardní doby časového pásma).The TimeZoneInfo.AdjustmentRule class defines the effective start and end dates of a particular time change to and from daylight saving time, respectively, as well as its delta (the exact amount by which the adjustment causes the time zone's standard time to change). Kromě toho dvě vlastnosti vracejí TimeZoneInfo.TransitionTime objekty, které definují, kdy dojde ke každému přechodu do a ze standardního času.In addition, two properties return TimeZoneInfo.TransitionTime objects that define when each transition to and from standard time occurs.

Poznámka

Instance TimeZoneInfo.AdjustmentRule třídy je neměnná.An instance of the TimeZoneInfo.AdjustmentRule class is immutable. Po vytvoření objektu nelze jeho hodnoty upravit.Once an object has been created, its values cannot be modified.

Chcete-li TimeZoneInfo.AdjustmentRule vytvořit objekt, static zavolejte metoduShared (v Visual Basic TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule ).To create a TimeZoneInfo.AdjustmentRule object, call the static (Shared in Visual Basic) TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule method. Pak můžete dodat pole TimeZoneInfo.AdjustmentRule objektů dvěma přetížením TimeZoneInfo.CreateCustomTimeZone metody.You can then supply an array of TimeZoneInfo.AdjustmentRule objects to two of the overloads of the TimeZoneInfo.CreateCustomTimeZone method. Chcete-li načíst pravidla úprav určitého časového pásma, zavolejte svou TimeZoneInfo.GetAdjustmentRules metodu, která vrátí TimeZoneInfo.AdjustmentRule pole objektů.To retrieve the adjustment rules of a particular time zone, call its TimeZoneInfo.GetAdjustmentRules method, which returns an array of TimeZoneInfo.AdjustmentRule objects.

Vlastnosti

DateEnd DateEnd DateEnd DateEnd

Získá datum, kdy pravidlo úpravy přestane platit.Gets the date when the adjustment rule ceases to be in effect.

DateStart DateStart DateStart DateStart

Získá datum, kdy se uplatní pravidlo úpravy.Gets the date when the adjustment rule takes effect.

DaylightDelta DaylightDelta DaylightDelta DaylightDelta

Získá množství času, které je nutné k vytvoření letního času v časovém pásmu.Gets the amount of time that is required to form the time zone's daylight saving time. Tato doba se přidá do posunu časového pásma od koordinovaného světového času (UTC).This amount of time is added to the time zone's offset from Coordinated Universal Time (UTC).

DaylightTransitionEnd DaylightTransitionEnd DaylightTransitionEnd DaylightTransitionEnd

Získá informace o ročním přechodu z letního času zpět na běžný čas.Gets information about the annual transition from daylight saving time back to standard time.

DaylightTransitionStart DaylightTransitionStart DaylightTransitionStart DaylightTransitionStart

Získá informace o ročním přechodu ze standardního času na letní čas.Gets information about the annual transition from standard time to daylight saving time.

Metody

CreateAdjustmentRule(DateTime, DateTime, TimeSpan, TimeZoneInfo+TransitionTime, TimeZoneInfo+TransitionTime) CreateAdjustmentRule(DateTime, DateTime, TimeSpan, TimeZoneInfo+TransitionTime, TimeZoneInfo+TransitionTime) CreateAdjustmentRule(DateTime, DateTime, TimeSpan, TimeZoneInfo+TransitionTime, TimeZoneInfo+TransitionTime) CreateAdjustmentRule(DateTime, DateTime, TimeSpan, TimeZoneInfo+TransitionTime, TimeZoneInfo+TransitionTime)

Vytvoří nové pravidlo úpravy pro konkrétní časové pásmo.Creates a new adjustment rule for a particular time zone.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Určuje, zda se zadaný objekt rovná aktuálnímu objektu.Determines whether the specified object is equal to the current object.

(Inherited from Object)
Equals(TimeZoneInfo+AdjustmentRule) Equals(TimeZoneInfo+AdjustmentRule) Equals(TimeZoneInfo+AdjustmentRule) Equals(TimeZoneInfo+AdjustmentRule)

Určuje, zda je TimeZoneInfo.AdjustmentRule aktuální objekt roven druhému TimeZoneInfo.AdjustmentRule objektu.Determines whether the current TimeZoneInfo.AdjustmentRule object is equal to a second TimeZoneInfo.AdjustmentRule object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Slouží jako funkce hash pro algoritmy hash a datové struktury, jako jsou tabulky hash.Serves as a hash function for hashing algorithms and data structures such as hash tables.

GetType() GetType() GetType() GetType()

Získá Type aktuální instance.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Vytvoří Mělkou kopii aktuální Object.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Vrací řetězec, který představuje aktuální objekt.Returns a string that represents the current object.

(Inherited from Object)

Explicitní implementace rozhraní

IDeserializationCallback.OnDeserialization(Object) IDeserializationCallback.OnDeserialization(Object) IDeserializationCallback.OnDeserialization(Object) IDeserializationCallback.OnDeserialization(Object)

Spustí se po dokončení deserializace TimeZoneInfo.AdjustmentRule objektu.Runs when the deserialization of a TimeZoneInfo.AdjustmentRule object is completed.

ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext)

Naplní SerializationInfo objekt daty, která jsou potřebná k serializaci tohoto objektu.Populates a SerializationInfo object with the data that is required to serialize this object.

Platí pro

Viz také