TimeZone.IsDaylightSavingTime Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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. |
- Source:
- TimeZone.cs
- Source:
- TimeZone.cs
- Source:
- TimeZone.cs
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
Parameters
- time
- DateTime
A date and time.
Returns
true
if time
is in a daylight saving time period; otherwise, false
.
Remarks
The year to which the daylight saving time period applies is derived from the time
parameter.
Because 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. 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. Whenever possible, use the TimeZoneInfo.IsDaylightSavingTime method.
See also
Applies to
.NET 9 和其他版本
产品 | 版本 |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
- Source:
- TimeZone.cs
- Source:
- TimeZone.cs
- Source:
- TimeZone.cs
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
Parameters
- time
- DateTime
A date and time.
- daylightTimes
- DaylightTime
A daylight saving time period.
Returns
true
if time
is in daylightTimes
; otherwise, false
.
Exceptions
daylightTimes
is null
.
Remarks
The TimeZoneInfo.IsDaylightSavingTime method provides the same functionality as this overload of the IsDaylightSavingTime method. Whenever possible, use the TimeZoneInfo.IsDaylightSavingTime method.
See also
Applies to
.NET 9 和其他版本
产品 | 版本 |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |