TimeZone.IsDaylightSavingTime 方法

定義

傳回數值,指示指定的日期和時間是否在日光節約時期之內。Returns a value indicating whether a specified date and time is within a daylight saving time period.

多載

IsDaylightSavingTime(DateTime)

傳回數值,指示指定的日期和時間是否在日光節約時期之內。Returns a value indicating whether the specified date and time is within a daylight saving time period.

IsDaylightSavingTime(DateTime, DaylightTime)

傳回數值,指示指定的日期和時間是否在指定的日光節約時期之內。Returns a value indicating whether the specified date and time is within the specified daylight saving time period.

IsDaylightSavingTime(DateTime)

傳回數值,指示指定的日期和時間是否在日光節約時期之內。Returns a value indicating whether the specified date and time is within a daylight saving time period.

public:
 virtual bool IsDaylightSavingTime(DateTime time);
public virtual bool IsDaylightSavingTime (DateTime time);
abstract member IsDaylightSavingTime : DateTime -> bool
override this.IsDaylightSavingTime : DateTime -> bool
Public Overridable Function IsDaylightSavingTime (time As DateTime) As Boolean

參數

time
DateTime

日期和時間。A date and time.

傳回

如果 time 在日光節約時期內,則為 true,否則為 falsetrue if time is in a daylight saving time period; otherwise, false.

備註

日光節約時間期間所套用的年份是從time參數衍生而來。The year to which the daylight saving time period applies is derived from the time parameter.

因為類別支援單一日光節約時間調整規則IsDaylightSavingTime(DateTime) , 所以方法會將目前的調整規則套用至任何日期, 而不論調整規則是否在該日期生效。 TimeZoneBecause the TimeZone class supports a single daylight saving time adjustment rule, the IsDaylightSavingTime(DateTime) method applies the current adjustment rule to any date, regardless of whether the adjustment rule was in effect on that date. 假設作業系統本身有正確的歷史日光節約時間資料, 則使用TimeZoneInfo.IsDaylightSavingTime方法可提供更精確的結果。Assuming that the operating system itself has accurate historic daylight saving time data, a more accurate result is available by using the TimeZoneInfo.IsDaylightSavingTime method. 如果可能, 請使用TimeZoneInfo.IsDaylightSavingTime方法。Whenever possible, use the TimeZoneInfo.IsDaylightSavingTime method.

另請參閱

IsDaylightSavingTime(DateTime, DaylightTime)

傳回數值,指示指定的日期和時間是否在指定的日光節約時期之內。Returns a value indicating whether the specified date and time is within the specified daylight saving time period.

public:
 static bool IsDaylightSavingTime(DateTime time, System::Globalization::DaylightTime ^ daylightTimes);
public static bool IsDaylightSavingTime (DateTime time, System.Globalization.DaylightTime daylightTimes);
static member IsDaylightSavingTime : DateTime * System.Globalization.DaylightTime -> bool
Public Shared Function IsDaylightSavingTime (time As DateTime, daylightTimes As DaylightTime) As Boolean

參數

time
DateTime

日期和時間。A date and time.

daylightTimes
DaylightTime

日光節約時期。A daylight saving time period.

傳回

如果 time 是在 daylightTimes 中,則為 true,否則為 falsetrue if time is in daylightTimes; otherwise, false.

例外狀況

daylightTimesnulldaylightTimes is null.

備註

方法提供的功能與IsDaylightSavingTime方法的這個多載相同。 TimeZoneInfo.IsDaylightSavingTimeThe TimeZoneInfo.IsDaylightSavingTime method provides the same functionality as this overload of the IsDaylightSavingTime method. 如果可能, 請使用TimeZoneInfo.IsDaylightSavingTime方法。Whenever possible, use the TimeZoneInfo.IsDaylightSavingTime method.

另請參閱

適用於