Noda Time
Show / Hide Table of Contents

Class BclDateTimeZone

Representation of a time zone converted from a TimeZoneInfo from the Base Class Library.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Inheritance
object
DateTimeZone
BclDateTimeZone
Inherited Members
DateTimeZone.Utc
DateTimeZone.ForOffset(Offset)
DateTimeZone.Id
DateTimeZone.MinOffset
DateTimeZone.MaxOffset
DateTimeZone.GetUtcOffset(Instant)
DateTimeZone.MapLocal(LocalDateTime)
DateTimeZone.AtStartOfDay(LocalDate)
DateTimeZone.ResolveLocal(LocalDateTime, ZoneLocalMappingResolver)
DateTimeZone.AtStrictly(LocalDateTime)
DateTimeZone.AtLeniently(LocalDateTime)
DateTimeZone.ToString()
DateTimeZone.GetZoneIntervals(Instant, Instant)
DateTimeZone.GetZoneIntervals(Interval)
DateTimeZone.GetZoneIntervals(Interval, ZoneEqualityComparer.Options)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
Namespace: NodaTime.TimeZones
Assembly: NodaTime.dll
Syntax
public sealed class BclDateTimeZone : DateTimeZone
Remarks

Two instances of this class are deemed equal if and only if they refer to the exact same TimeZoneInfo object.

This implementation does not always give the same results as TimeZoneInfo, in that it doesn't replicate the bugs in the BCL interpretation of the data. These bugs are described in a blog post, but we're not expecting them to be fixed any time soon. Being bug-for-bug compatible would not only be tricky, but would be painful if the BCL were ever to be fixed. As far as we are aware, there are only discrepancies around new year where the zone changes from observing one rule to observing another.

As of version 3.0, a new "incompatible but doing the right thing" category of differences has been implemented, for time zones which have a transition at 24:00. The Windows time zone data represents this as a transition at 23:59:59.999, and that's faithfully represented by TimeZoneInfo (and BclDateTimeZone in version 2.x). As of 3.0, this is spotted and converted to a midnight-on-the-following-day transition.

Properties

DisplayName

Gets the display name associated with the time zone, as provided by the Base Class Library.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public string DisplayName { get; }
Property Value
Type Description
string The display name associated with the time zone, as provided by the Base Class Library.

OriginalZone

Gets the original TimeZoneInfo from which this was created.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public TimeZoneInfo OriginalZone { get; }
Property Value
Type Description
TimeZoneInfo The original TimeZoneInfo from which this was created.

Methods

ForSystemDefault()

Returns a time zone converted from the BCL representation of the system local time zone.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static BclDateTimeZone ForSystemDefault()
Returns
Type Description
BclDateTimeZone A BclDateTimeZone wrapping the "local" (system) time zone as returned by Local.
Remarks

This method is approximately equivalent to calling GetSystemDefault() with an implementation that wraps BclDateTimeZoneSource (e.g. Bcl), with the exception that it will succeed even if the current local time zone was not one of the set of system time zones captured when the source was created (which, while highly unlikely, might occur either because the local time zone is not a system time zone, or because the system time zones have themselves changed).

This method will retain a reference to the returned BclDateTimeZone, and will attempt to return it if called repeatedly (assuming that the local time zone has not changed) rather than creating a new instance, though this behaviour is not guaranteed.

Exceptions
Type Condition
InvalidOperationException The system does not provide a time zone.

FromTimeZoneInfo(TimeZoneInfo)

Creates a new BclDateTimeZone from a TimeZoneInfo from the Base Class Library.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static BclDateTimeZone FromTimeZoneInfo(TimeZoneInfo bclZone)
Parameters
Type Name Description
TimeZoneInfo bclZone The original time zone to take information from.
Returns
Type Description
BclDateTimeZone A BclDateTimeZone wrapping the given TimeZoneInfo.

GetZoneInterval(Instant)

Gets the zone interval for the given instant; the range of time around the instant in which the same Offset applies (with the same split between standard time and daylight saving time, and with the same offset).
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public override ZoneInterval GetZoneInterval(Instant instant)
Parameters
Type Name Description
Instant instant The Instant to query.
Returns
Type Description
ZoneInterval The defined ZoneInterval.
Overrides
DateTimeZone.GetZoneInterval(Instant)
Remarks
This will always return a valid zone interval, as time zones cover the whole of time.
See Also
GetZoneIntervals(Interval)
In this article
Back to top Generated by DocFX