TimeZoneInfo.TransitionTime.Week Property
Gets the week of the month in which a time change occurs.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
The value of the Week property is used only for time changes with floating-date rules. Valid values can range from 1 to 5.
The Month property defines the month in which the time change occurs. The Week property determines the week on which the transition occurs. The DayOfWeek property defines the day of the week on which the transition occurs. The value of the Week property is determined as shown in the following table.
If the Week property value is | The transition occurs on |
|---|---|
1 | |
2 | |
3 | |
4 | |
5 |
For example, if a transition occurs on the first Sunday of March, the value of the Week property is 1. If it occurs on the last Sunday of October, the value of the Week property is 5.
The following example enumerates the time zones found on the local computer and displays transition time information for all floating-date transitions. The time information includes the week of the month in which the time change occurs. 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 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
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.