Class TzdbDateTimeZoneSource
Provides an implementation of
IDateTimeZoneSource that loads data originating from the
tz database (also known as the IANA Time Zone database, or zoneinfo
or Olson database).
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Inheritance
TzdbDateTimeZoneSource
Assembly: NodaTime.dll
Syntax
public sealed class TzdbDateTimeZoneSource : IDateTimeZoneSource
Properties
Aliases
Gets a lookup from canonical time zone ID (e.g. "Europe/London") to a group of aliases for that time zone
(e.g. {"Europe/Belfast", "Europe/Guernsey", "Europe/Jersey", "Europe/Isle_of_Man", "GB", "GB-Eire"}).
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public ILookup<string, string> Aliases { get; }
Property Value
CanonicalIdMap
Returns a read-only map from time zone ID to the canonical ID. For example, the key "Europe/Jersey"
would be associated with the value "Europe/London".
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public IDictionary<string, string> CanonicalIdMap { get; }
Property Value
Default
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static TzdbDateTimeZoneSource Default { get; }
Property Value
TzdbToWindowsIds
Returns a dictionary mapping TZDB IDs to Windows IDs.
Since 3.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public IReadOnlyDictionary<string, string> TzdbToWindowsIds { get; }
Property Value
TzdbVersion
Gets just the TZDB version (e.g. "2013a") of the source data.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public string TzdbVersion { get; }
Property Value
Type |
Description |
string |
The TZDB version (e.g. "2013a") of the source data. |
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. |
WindowsMapping
Gets the Windows time zone mapping information provided in the CLDR
supplemental "windowsZones.xml" file.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public WindowsZones WindowsMapping { get; }
Property Value
Type |
Description |
WindowsZones |
The Windows time zone mapping information provided in the CLDR
supplemental "windowsZones.xml" file. |
WindowsToTzdbIds
Returns a dictionary mapping Windows IDs to canonical TZDB IDs, using the
primary mapping in each
MapZone.
Since 3.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public IReadOnlyDictionary<string, string> WindowsToTzdbIds { get; }
Property Value
Zone1970Locations
Gets a read-only list of "zone 1970" locations known to this source, or null if the original source data
does not include zone locations.
Since 2.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public IList<TzdbZone1970Location>? Zone1970Locations { get; }
Property Value
ZoneLocations
Gets a read-only list of zone locations known to this source, or null if the original source data
does not include zone locations.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public IList<TzdbZoneLocation>? ZoneLocations { get; }
Property Value
Methods
ForId(string)
Returns the time zone definition associated with the given ID.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public DateTimeZone ForId(string id)
Parameters
Type |
Name |
Description |
string |
id |
The ID of the time zone to return. This must be one of the IDs
returned by GetIds(). |
Returns
Exceptions
FromStream(Stream)
Creates an instance from a stream in the custom Noda Time format. The stream must be readable.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public static TzdbDateTimeZoneSource FromStream(Stream stream)
Parameters
Type |
Name |
Description |
Stream |
stream |
The stream containing time zone data |
Returns
Exceptions
GetIds()
Returns an unordered enumeration of the IDs available from this source.
Since 1.0.x
Availability net6.0, net8.0, netstandard2.0
Declaration
public IEnumerable<string> GetIds()
Returns
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. |
Validate()
Validates that the data within this source is consistent with itself.
Since 1.1.x
Availability net6.0, net8.0, netstandard2.0
Declaration
Exceptions
Implements