Defines a time change that uses a floating-date rule.
Assembly: mscorlib (in mscorlib.dll)
public static TimeZoneInfo..::..TransitionTime CreateFloatingDateRule( DateTime timeOfDay, int month, int week, DayOfWeek dayOfWeek )
- Type: System.DateTime
The time at which the time change occurs.
- Type: System.Int32
The month in which the time change occurs.
- Type: System.Int32
The week of the month in which the time change occurs.
- Type: System.DayOfWeek
The day of the week on which the time change occurs.
Return ValueType: System.TimeZoneInfo.TransitionTime
Data about the time change.
The timeOfDay parameter has a non-default date component.
The timeOfDay parameter does not represent a whole number of milliseconds.
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.
The following table indicates how the parameters of the method correspond to the properties of the TimeZoneInfo.TransitionTime object.
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 TimeZoneInfo imaginaryTZ; TimeSpan delta = new TimeSpan(1, 0, 0); TimeZoneInfo.AdjustmentRule adjustment; List<TimeZoneInfo.AdjustmentRule> adjustmentList = new List<TimeZoneInfo.AdjustmentRule>(); // Declare transition time variables to hold transition time information TimeZoneInfo.TransitionTime transitionRuleStart, transitionRuleEnd; // Define a fictitious new time zone consisting of fixed and floating adjustment rules // Define fixed rule (for 1900-1955) transitionRuleStart = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, 2, 0, 0), 3, 15); transitionRuleEnd = TimeZoneInfo.TransitionTime.CreateFixedDateRule(new DateTime(1, 1, 1, 3, 0, 0), 11, 15); adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(1900, 1, 1), new DateTime(1955, 12, 31), delta, transitionRuleStart, transitionRuleEnd); adjustmentList.Add(adjustment); // Define floating rule (for 1956- ) transitionRuleStart = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 2, 0, 0), 3, 5, DayOfWeek.Sunday); transitionRuleEnd = TimeZoneInfo.TransitionTime.CreateFloatingDateRule(new DateTime(1, 1, 1, 3, 0, 0), 10, 4, DayOfWeek.Sunday); adjustment = TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule(new DateTime(1956, 1, 1), DateTime.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 SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.