TimeZoneInfo.TransitionTime.Week TimeZoneInfo.TransitionTime.Week TimeZoneInfo.TransitionTime.Week TimeZoneInfo.TransitionTime.Week Property

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 enumera i fusi orari disponibili nel computer locale e visualizza le informazioni sul tempo di transizione per tutte le transizioni 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 include la settimana del mese in cui avviene la modifica dell'ora.The time information includes the week of the month in which the time change occurs. L'esempio definisce anche un WeekOfMonth enumerazione per visualizzare una stringa che rappresenta il valore ordinale del Week 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 utilizzata solo per le modifiche di tempo con le regole data mobile.The value of the Week property is used only for time changes with floating-date rules. I valori validi vanno da 1 a 5.Valid values can range from 1 to 5.

Il Month proprietà definisce il mese in cui avviene la modifica dell'ora.The Month property defines the month in which the time change occurs. Il Week proprietà determina il giorno della settimana in cui si verifica la transizione.The Week property determines the week on which the transition occurs. Il DayOfWeek proprietà consente di definire 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 determinata come descritto nella tabella seguente.The value of the Week property is determined as shown in the following table.

Se il valore della proprietà settimanaIf the Week property value is Si verifica la transizione inThe transition occurs on
11 La prima occorrenza del DayOfWeek valore Month.The first occurrence of the DayOfWeek value in Month.
22 La seconda occorrenza della DayOfWeek valore Month.The second occurrence of the DayOfWeek value in Month.
33 La terza occorrenza del DayOfWeek valore Month.The third occurrence of the DayOfWeek value in Month.
44 La quarta occorrenza del DayOfWeek valore Month.The fourth occurrence of the DayOfWeek value in Month.
55 Ultima occorrenza del DayOfWeek valore Month.The last occurrence of the DayOfWeek value in Month.

Ad esempio, se si verifica la prima domenica del mese di marzo, il valore di una transizione di 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 del mese 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