TimeZoneInfo.TransitionTime.Week Proprietà

Definizione

Ottiene la settimana del mese in cui avviene una modifica dell'ora.Gets the week of the month in which a time change occurs.

public:
 property int Week { int get(); };
public int Week { get; }
member this.Week : int
Public ReadOnly Property Week As Integer

Valore della proprietà

Settimana del mese in cui avviene la modifica dell'ora.The week of the month in which the time change occurs.

Esempi

Nell'esempio seguente vengono enumerati i fusi orari trovati nel computer locale e vengono visualizzate le informazioni sulla fase di transizione per tutte le transizioni a data mobile.The following example enumerates the time zones found on the local computer and displays transition time information for all floating-date transitions. Le informazioni sull'ora includono la settimana del mese in cui si verifica il cambiamento di ora.The time information includes the week of the month in which the time change occurs. Nell'esempio viene inoltre definita WeekOfMonth un'enumerazione per visualizzare una stringa che rappresenta il valore ordinale Week della proprietà anziché un numero intero.The example also defines a WeekOfMonth enumeration to display a string that represents the ordinal value of the Week property rather than an integer.

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

private void GetFloatingTransitionTimes()
{
   ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
   foreach (TimeZoneInfo zone in timeZones)
   {
      TimeZoneInfo.AdjustmentRule[] adjustmentRules = zone.GetAdjustmentRules();
      DateTimeFormatInfo dateInfo = CultureInfo.CurrentCulture.DateTimeFormat;
      foreach (TimeZoneInfo.AdjustmentRule adjustmentRule in adjustmentRules)
      {
         TimeZoneInfo.TransitionTime daylightStart = adjustmentRule.DaylightTransitionStart;
         if (! daylightStart.IsFixedDateRule)
            Console.WriteLine("{0}, {1:d}-{2:d}: Begins at {3:t} on the {4} {5} of {6}.", 
                              zone.StandardName, 
                              adjustmentRule.DateStart, 
                              adjustmentRule.DateEnd,                                 
                              daylightStart.TimeOfDay, 
                              ((WeekOfMonth)daylightStart.Week).ToString(),  
                              daylightStart.DayOfWeek.ToString(),
                              dateInfo.GetMonthName(daylightStart.Month));

         TimeZoneInfo.TransitionTime daylightEnd = adjustmentRule.DaylightTransitionEnd;
         if (! daylightEnd.IsFixedDateRule)
            Console.WriteLine("{0}, {1:d}-{2:d}: Ends at {3:t} on the {4} {5} of {6}.", 
                              zone.StandardName, 
                              adjustmentRule.DateStart, 
                              adjustmentRule.DateEnd,                                 
                              daylightEnd.TimeOfDay, 
                              ((WeekOfMonth)daylightEnd.Week).ToString(),  
                              daylightEnd.DayOfWeek.ToString(), 
                              dateInfo.GetMonthName(daylightEnd.Month));
      }
   }   
}
Private Enum WeekOfMonth As Integer
   First = 1
   Second = 2
   Third = 3
   Fourth = 4
   Last = 5 
End Enum

Private Sub GetFloatingTransitionTimes()
   Dim timeZones As ReadOnlyCollection(Of TimeZoneInfo) = TimeZoneInfo.GetSystemTimeZones()
   For Each zone As TimeZoneInfo In timeZones
      Dim adjustmentRules() As TimeZoneInfo.AdjustmentRule = zone.GetAdjustmentRules()
      For Each adjustmentRule As TimeZoneInfo.AdjustmentRule in adjustmentRules
         Dim daylightStart As TimeZoneInfo.TransitionTime = adjustmentRule.DaylightTransitionStart
         If Not daylightStart.IsFixedDateRule Then
            Console.WriteLine("{0}, {1:d}-{2:d}: Begins at {3:t} on the {4} {5} of {6}.", _
                              zone.StandardName, _
                              adjustmentRule.DateStart, _
                              adjustmentRule.DateEnd, _                                 
                              daylightStart.TimeOfDay, _
                              CType(daylightStart.Week, WeekOfMonth).ToString(), _ 
                              daylightStart.DayOfWeek.ToString(), _
                              MonthName(daylightStart.Month))
         End If
         Dim daylightEnd As TimeZoneInfo.TransitionTime = adjustmentRule.DaylightTransitionEnd
         If Not daylightEnd.IsFixedDateRule Then
            Console.WriteLine("{0}, {1:d}-{2:d}: Ends at {3:t} on the {4} {5} of {6}.", _
                              zone.StandardName, _
                              adjustmentRule.DateStart, _
                              adjustmentRule.DateEnd, _                                 
                              daylightEnd.TimeOfDay, _
                              CType(daylightEnd.Week, WeekOfMonth).ToString(), _ 
                              daylightEnd.DayOfWeek.ToString(), _
                              MonthName(daylightEnd.Month))
         End If   
      Next
   Next   
End Sub

Commenti

Il valore della Week proprietà viene utilizzato solo per le modifiche temporali con le regole a data mobile.The value of the Week property is used only for time changes with floating-date rules. I valori validi possono essere compresi tra 1 e 5.Valid values can range from 1 to 5.

La Month proprietà definisce il mese in cui si verifica la modifica dell'ora.The Month property defines the month in which the time change occurs. La Week proprietà determina la settimana in cui si verifica la transizione.The Week property determines the week on which the transition occurs. La DayOfWeek proprietà definisce il giorno della settimana in cui si verifica la transizione.The DayOfWeek property defines the day of the week on which the transition occurs. Il valore della Week proprietà viene determinato come illustrato nella tabella seguente.The value of the Week property is determined as shown in the following table.

Se il valore della proprietà Week èIf the Week property value is La transizione si verifica inThe transition occurs on
11 Prima occorrenza del DayOfWeek valore in Month.The first occurrence of the DayOfWeek value in Month.
22 Seconda occorrenza del DayOfWeek valore in Month.The second occurrence of the DayOfWeek value in Month.
33 Terza occorrenza del DayOfWeek valore in Month.The third occurrence of the DayOfWeek value in Month.
44 Quarta occorrenza del DayOfWeek valore in Month.The fourth occurrence of the DayOfWeek value in Month.
55 Ultima occorrenza del DayOfWeek valore in Month.The last occurrence of the DayOfWeek value in Month.

Se, ad esempio, si verifica una transizione nella prima domenica di marzo, il valore della Week proprietà è 1.For example, if a transition occurs on the first Sunday of March, the value of the Week property is 1. Se si verifica l'ultima domenica di marzo, il valore della Week proprietà è 5.If it occurs on the last Sunday of March, the value of the Week property is 5.

Si applica a

Vedi anche