Class BclDateTimeZoneSource
Provides an implementation of IDateTimeZoneSource that loads data from the BCL
System.TimeZoneInfo class.
Since 1.0.x
Availability net45
Inheritance
Object
BclDateTimeZoneSource
Implements
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
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").
This class is not available in the .NET Standard 1.3 version.
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 net45
Declaration
public BclDateTimeZoneSource()
Properties
VersionId
Returns an appropriate version ID for diagnostic purposes, which must not be null.
Since 1.0.x
Availability net45
Declaration
public string VersionId { get; }
Property Value
Type | Description |
---|---|
String | An appropriate version ID for diagnostic purposes. (The value returned is never null.) |
Remarks
This source returns a string such as "TimeZoneInfo: 3.5.0.0" corresponding to the version of the assembly
containing System.TimeZoneInfo.
Methods
ForId(String)
Creates a new instance of BclDateTimeZone from the System.TimeZoneInfo with the given
ID. The ID must be a known system time zone ID.
Since 1.0.x
Availability net45
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 (The value returned is never null.) |
Exceptions
Type | Condition |
---|---|
ArgumentException | The given zone doesn't exist. |
ArgumentNullException | id is null. |
GetIds()
Returns the IDs of all system time zones.
Since 1.0.x
Availability net45
Declaration
public IEnumerable<string> GetIds()
Returns
Type | Description |
---|---|
IEnumerable<String> | The IDs available from this source. (The value returned is never null.) |
GetSystemDefaultId()
Returns this source's ID for the system default time zone.
Since 2.0.x
Availability net45
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. (The value returned is never null.) |
Explicit Interface Implementations
IDateTimeZoneSource.ForId(String)
Creates a new instance of BclDateTimeZone from the System.TimeZoneInfo with the given
ID. The ID must be a known system time zone ID.
Since 1.0.x
Availability net45
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).
Exceptions
Type | Condition |
---|---|
ArgumentNullException | id is null. |