Class BclDateTimeZoneSource
Provides an implementation of IDateTimeZoneSource that loads data from the BCL
TimeZoneInfo class.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Implements
Inherited Members
Namespace: NodaTime.TimeZones
Assembly: NodaTime.dll
Syntax
public sealed class BclDateTimeZoneSource : IDateTimeZoneSource
Remarks
All calls to ForId(string) return instances of BclDateTimeZone, including for fixed-offset IDs (i.e. "UTC" and "UTC+/-Offset").
In Noda Time 1.x and 2.x, this class is only available on the .NET Framework builds of Noda Time, and not the PCL (Noda Time 1.x) or .NET Standard 1.3 (Noda Time 2.x) builds.
Constructors
BclDateTimeZoneSource()
Constructs a new instance. This is rarely useful in application code, as this class has no state of its own.
Most application code should use Bcl.
Since 2.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public BclDateTimeZoneSource()
Properties
VersionId
Returns an appropriate version ID for diagnostic purposes, which must not be null.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public string VersionId { get; }
Property Value
Type | Description |
---|---|
string | An appropriate version ID for diagnostic purposes. |
Remarks
This doesn't have any specific format; it's solely for diagnostic purposes.
The included sources return strings of the format "source identifier: source version" indicating where the
information comes from and which version of the source information has been loaded.
Methods
ForId(string)
Creates a new instance of BclDateTimeZone from the TimeZoneInfo with the given
ID. The ID must be a known system time zone ID.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public BclDateTimeZone ForId(string id)
Parameters
Type | Name | Description |
---|---|---|
string | id | The ID of the system time zone to convert |
Returns
Type | Description |
---|---|
BclDateTimeZone | The Noda Time representation of the given BCL time zone |
Exceptions
Type | Condition |
---|---|
ArgumentException | The given zone doesn't exist. |
GetIds()
Returns the IDs of all system time zones.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public IEnumerable<string> GetIds()
Returns
Type | Description |
---|---|
IEnumerable<string> | The IDs available from this source. |
GetSystemDefaultId()
Returns this source's ID for the system default time zone.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public string? GetSystemDefaultId()
Returns
Type | Description |
---|---|
string | The ID for the system default time zone for this source, or null if the system default time zone has no mapping in this source. |
Explicit Interface Implementations
IDateTimeZoneSource.ForId(string)
Creates a new instance of BclDateTimeZone from the TimeZoneInfo with the given
ID. The ID must be a known system time zone ID.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
DateTimeZone IDateTimeZoneSource.ForId(string id)
Parameters
Type | Name | Description |
---|---|---|
string | id |
Returns
Type | Description |
---|---|
DateTimeZone |
Remarks
This method explicitly implements ForId(string) by delegating to the
ForId(string) method which has a return type of BclDateTimeZone, ensuring that all
zones returned by this implementation are instances of BclDateTimeZone (rather than the built-in
fixed offset zones).