DateTime.IsDaylightSavingTime DateTime.IsDaylightSavingTime DateTime.IsDaylightSavingTime DateTime.IsDaylightSavingTime Method


指示此 DateTime 实例是否在当前时区的夏时制范围内。Indicates whether this instance of DateTime is within the daylight saving time range for the current time zone.

 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. 对于观察夏令时的时区, 可以通过检索System.TimeZoneInfo.AdjustmentRule由时区的TimeZoneInfo.GetAdjustmentRules属性返回的数组来确定何时从夏令时转换到夏令时。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.