DateTime.IsDaylightSavingTime 方法

定義

指出這個 DateTime 執行個體是否在目前時區的日光節約時間範圍內。Indicates whether this instance of DateTime is within the daylight saving time range for the current time zone.

public:
 bool IsDaylightSavingTime();
public bool IsDaylightSavingTime ();
member this.IsDaylightSavingTime : unit -> bool
Public Function IsDaylightSavingTime () As Boolean

傳回

true 屬性的值為 KindLocal,且這個 Unspecified 執行個體的值位於當地時區的日光節約時間範圍內時為 DateTime;當 falseKind 時為 Utctrue if the value of the Kind property is Local or Unspecified and the value of this instance of DateTime is within the daylight saving time range for the local time zone; false if Kind is Utc.

備註

這個方法會判斷目前的 DateTime 值是否落在當地時區的日光節約時間範圍內(由 TimeZoneInfo.Local 屬性傳回)。This method determines whether the current DateTime value falls within the daylight saving time range of the local time zone, which is returned by the TimeZoneInfo.Local property. 您可以藉由抓取 TimeZoneInfo.SupportsDaylightSavingTime 屬性的值,判斷時區是否支援日光節約時間。You can determine whether a time zone supports daylight saving time by retrieving the value of its TimeZoneInfo.SupportsDaylightSavingTime property. 對於觀察日光節約時間的時區,您可以藉由抓取時區的 TimeZoneInfo.GetAdjustmentRules 屬性所傳回的 System.TimeZoneInfo.AdjustmentRule 陣列,判斷何時轉換到日光節約時間。For time zones that observe daylight saving time, you can determine when the transition to and from daylight saving time occurs by retrieving the System.TimeZoneInfo.AdjustmentRule array returned by the time zone's TimeZoneInfo.GetAdjustmentRules property.

如果目前 DateTime 值代表當地時區中的不明確或無效時間,則方法會傳回 falseIf the current DateTime value represents either an ambiguous or an invalid time in the local time zone, the method returns false.

Windows XPWindows XP 系統上,IsDaylightSavingTime 方法在判斷目前的實例是否為日光節約時間時,只會辨識目前的調整規則。On Windows XPWindows XP systems, the IsDaylightSavingTime method recognizes only the current adjustment rule when determining whether the current instance is a daylight saving time. 因此,此方法可能無法正確地報告目前的實例是否為目前調整規則生效之前的日光節約時間。As a result, the method may not accurately report whether the current instance is a daylight saving time for periods before the current adjustment rule came into effect.

適用於

另請參閱