TimeZoneInfo.TransitionTime.CreateFloatingDateRule(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).

public:
 static TimeZoneInfo::TransitionTime CreateFloatingDateRule(DateTime timeOfDay, int month, int week, DayOfWeek dayOfWeek);
public static TimeZoneInfo.TransitionTime CreateFloatingDateRule (DateTime timeOfDay, int month, int week, DayOfWeek dayOfWeek);
static member CreateFloatingDateRule : DateTime * int * int * DayOfWeek -> TimeZoneInfo.TransitionTime

パラメーター

timeOfDay
DateTime

時間変更が発生する時刻。The time at which the time change occurs. このパラメーターは TimeOfDay プロパティに対応しています。This parameter corresponds to the TimeOfDay property.

month
Int32

時間変更が発生する月。The month in which the time change occurs. このパラメーターは Month プロパティに対応しています。This parameter corresponds to the Month property.

week
Int32

時間変更が発生する月の週。The week of the month in which the time change occurs. 値の範囲は 1 から 5 で、5 はその月の最終週を表します。Its value can range from 1 to 5, with 5 representing the last week of the month. このパラメーターは Week プロパティに対応しています。This parameter corresponds to the Week property.

dayOfWeek
DayOfWeek

時間変更が発生する曜日。The day of the week on which the time change occurs. このパラメーターは DayOfWeek プロパティに対応しています。This parameter corresponds to the DayOfWeek property.

戻り値

時間変更に関するデータ。Data about the time change.

例外

timeOfDay パラメーターに既定値ではない日付部分が入っています。The timeOfDay parameter has a non-default date component.

または-or- timeOfDay パラメーターが、整数のミリ秒数を表していません。The timeOfDay parameter does not represent a whole number of milliseconds.

または-or- timeOfDay パラメーターの Kind プロパティは Unspecified ではありません。The timeOfDay parameter's Kind property is not Unspecified.

month が 1 未満であるか、または 12 を超えています。month is less than 1 or greater than 12.

または-or- week が 1 より小さいか、5 を超えています。week is less than 1 or greater than 5.

または-or- dayOfWeek パラメーターが DayOfWeek 列挙体のメンバーではありません。The dayOfWeek parameter is not a member of the DayOfWeek enumeration.

次の例では、固定日付ルールと浮動日付ルールの両方を使用して、虚数部のタイムゾーンの遷移を作成します。The following example creates time zone transitions for an imaginary time zone by using both a fixed-date rule and a floating-date rule. この浮動小数点ルールでは、午前2:00 に開始するタイムゾーンの調整を定義します。The floating-date rule defines a time zone adjustment that starts at 2:00 A.M. 3月の最後の日曜日に、は午前5時3:00 に終了します。on the last Sunday of March and ends at 3:00 A.M. 10月の4番目の日曜日に、1956年前に。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());
' 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())

注釈

このメソッドは、浮動小数点ルール (特定の月の特定の週の特定の曜日に発生する時間変更) を作成します。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). たとえば、10月の最後の日曜日に発生する時間の変更は、浮動小数点の規則に従います。For example, a time change that occurs on the last Sunday of October follows a floating-date rule.

標準時から夏時間への移行の場合、timeOfDay 引数はタイムゾーンの標準時の遷移時間を表します。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. これは、年、月、および日付の値がすべて1である必要がある DateTime 値であることに注意してください。Note that this is a DateTime value whose year, month, and date values must all equal 1.

適用対象