Export (0) Print
Expand All

TimeZoneInfo.TransitionTime.CreateFloatingDateRule Method

Defines a time change that uses a floating-date rule.

Namespace:  System
Assembly:  System.Core (in System.Core.dll)

'Declaration
Public Shared Function CreateFloatingDateRule ( _
	timeOfDay As DateTime, _
	month As Integer, _
	week As Integer, _
	dayOfWeek As DayOfWeek _
) As TimeZoneInfo..::.TransitionTime
'Usage
Dim timeOfDay As DateTime 
Dim month As Integer 
Dim week As Integer 
Dim dayOfWeek As DayOfWeek 
Dim returnValue As TimeZoneInfo..::.TransitionTime 

returnValue = TimeZoneInfo..::.TransitionTime.CreateFloatingDateRule(timeOfDay, _
	month, week, dayOfWeek)

Parameters

timeOfDay
Type: System.DateTime

The time at which the time change occurs.

month
Type: System.Int32

The month in which the time change occurs.

week
Type: System.Int32

The week of the month in which the time change occurs.

dayOfWeek
Type: System.DayOfWeek

The day of the week on which the time change occurs.

Return Value

Type: System.TimeZoneInfo.TransitionTime
A TimeZoneInfo.TransitionTime object that contains data about the time change.

ExceptionCondition
ArgumentException

The timeOfDay parameter has a non-default date component.

-or-

The timeOfDay parameter does not represent a whole number of milliseconds.

-or-

The timeOfDay parameter's Kind property is not DateTimeKind.Unspecified.

ArgumentOutOfRangeException

month is less than 1 or greater than 12.

-or-

week is less than 1 or greater than 5.

-or-

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.

The following table indicates how the parameters of the CreateFloatingDateRule method correspond to the properties of the TimeZoneInfo.TransitionTime object.

CreateFloatingDateRule parameter

TransitionTime property

timeOfDay

TimeOfDay

month

Month

week

Week

dayOfWeek

DayOfWeek

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())

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5

Community Additions

ADD
Show:
© 2014 Microsoft