Class BclDateTimeZoneSource
An IDateTimeZoneSource implementation which uses TimeZoneInfo from
.NET 3.5 and later.
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").
Properties
VersionId
Returns version information corresponding to the version of the assembly
containing TimeZoneInfo.
Declaration
public string VersionId { get; }
Property Value
Type | Description |
---|---|
String |
Remarks
All calls to ForId(String) return instances of BclDateTimeZone, including for fixed-offset IDs
(i.e. "UTC" and "UTC+/-Offset").
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.
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 Windows system time zone |
Remarks
All calls to ForId(String) return instances of BclDateTimeZone, including for fixed-offset IDs
(i.e. "UTC" and "UTC+/-Offset").
Exceptions
Type | Condition |
---|---|
ArgumentException | The given zone doesn't exist |
GetIds()
Returns the IDs of all system time zones.
Declaration
public IEnumerable<string> GetIds()
Returns
Type | Description |
---|---|
IEnumerable<String> |
Remarks
All calls to ForId(String) return instances of BclDateTimeZone, including for fixed-offset IDs
(i.e. "UTC" and "UTC+/-Offset").
MapTimeZoneId(TimeZoneInfo)
Maps the BCL ID to "our" ID as an identity projection.
Declaration
public string MapTimeZoneId(TimeZoneInfo timeZone)
Parameters
Type | Name | Description |
---|---|---|
TimeZoneInfo | timeZone |
Returns
Type | Description |
---|---|
String |
Remarks
All calls to ForId(String) return instances of BclDateTimeZone, including for fixed-offset IDs
(i.e. "UTC" and "UTC+/-Offset").
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.
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).