TimeZoneInfo.TransitionTime.CreateFloatingDateRule Method (DateTime, Int32, Int32, DayOfWeek)
Defines a time change that uses a floating-date rule (that is, a time change that occurs on a specific day of a specific week of a specific month).
Assembly: mscorlib (in mscorlib.dll)
Public Shared Function CreateFloatingDateRule ( timeOfDay As Date, month As Integer, week As Integer, dayOfWeek As DayOfWeek ) As TimeZoneInfo.TransitionTime
The time at which the time change occurs. This parameter corresponds to the TimeOfDay property. For details, see Remarks.
The month in which the time change occurs. This parameter corresponds to the Month property.
The week of the month in which the time change occurs. Its value can range from 1 to 5, with 5 representing the last week of the month. This parameter corresponds to the Week property.
Return ValueType: System.TimeZoneInfo.TransitionTime
Data about the time change.
month is less than 1 or greater than 12.
week is less than 1 or greater than 5.
The dayOfWeek parameter is not a member of the DayOfWeek enumeration.
This method creates a floating-date rule (that is, a time change that occurs on a specific day of a specific week of a specific month). For example, a time change that occurs on the last Sunday of October follows a floating-date rule.
For transitions from standard time to daylight saving time, the timeOfDay argument represents the time of the transition in the time zone's standard time. For transitions from daylight saving time to standard time, it represents the time of the transition in the time zone's daylight saving time. Note that this is a DateTime value whose year, month, and date values must all equal 1.
The following example creates time zone transitions for an imaginary time zone by using both a fixed-date rule and a floating-date rule. The floating-date rule defines a time zone adjustment that starts at 2:00 A.M. on the last Sunday of March and ends at 3:00 A.M. on the fourth Sunday in October for the years 1956 onward.
' Declare necessary TimeZoneInfo.AdjustmentRule objects for time zone Dim imaginaryTZ As TimeZoneInfo Dim delta As New TimeSpan(1, 0, 0) Dim adjustment As TimeZoneInfo.AdjustmentRule Dim adjustmentList As New List(Of TimeZoneInfo.AdjustmentRule) ' Declare transition time variables to hold transition time information Dim transitionRuleStart, transitionRuleEnd As TimeZoneInfo.TransitionTime ' Define a fictitious new time zone consisting of fixed and floating adjustment rules ' Define fixed rule (for 1900-1955) transitionRuleStart = TimeZoneInfo.TransitionTime.CreateFixedDateRule(#2:00:00AM#, 3, 15) transitionRuleEnd = TimeZoneInfo.TransitionTime.CreateFixedDateRule(#3:00:00AM#, 11, 15) adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(#1/1/1900#, #12/31/1955#, delta, _ transitionRuleStart, transitionRuleEnd) adjustmentList.Add(adjustment) ' Define floating rule (for 1956- ) transitionRuleStart = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(#02:00:00AM#, 3, 5, DayOfWeek.Sunday) transitionRuleEnd = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(#03:00:00AM#, 10, 4, DayOfWeek.Sunday) adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(#01/01/1956#, Date.MaxValue.Date, delta, transitionRuleStart, transitionRuleEnd) adjustmentList.Add(adjustment) ' Create fictitious time zone imaginaryTZ = TimeZoneInfo.CreateCustomTimeZone("Fictitious Standard Time", New TimeSpan(-9, 0, 0), _ "(GMT-09:00) Fictitious Time", "Fictitious Standard Time", _ "Fictitious Daylight Time", adjustmentList.ToArray())
Available since 3.5