Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class NodaTime.​TimeZones.​TzdbDateTimeZoneSource
Assembly: NodaTime
Inheritance: object → TzdbDateTimeZoneSource
Implemented Interfaces
Provides an implementation of <see cref="T:NodaTime.TimeZones.IDateTimeZoneSource" /> that loads data originating from the <a href="https://www.iana.org/time-zones">tz database</a> (also known as the IANA Time Zone database, or zoneinfo or Olson database).
Remarks
All calls to <see cref="M:NodaTime.TimeZones.TzdbDateTimeZoneSource.ForId(System.String)" /> for fixed-offset IDs advertised by the source (i.e. "UTC" and "UTC+/-Offset")
will return zones equal to those returned by <see cref="M:NodaTime.DateTimeZone.ForOffset(NodaTime.Offset)" /> .
Properties
public static
TzdbDateTimeZoneSource
Default
Gets the <see cref="T:NodaTime.TimeZones.TzdbDateTimeZoneSource" /> initialised from resources within the NodaTime assembly.
public
System.​Linq.​ILookup<​string, string>
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"}).
Remarks The group of values for a key never contains the canonical ID, only aliases. Any time zone
ID which is itself an alias or has no aliases linking to it will not be present in the lookup.
The aliases within a group are returned in alphabetical (ordinal) order.
public
System.​Collections.​Generic.​IDictionary<​string, string>
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".
Remarks <para>This map contains an entry for every ID returned by <see cref="M:NodaTime.TimeZones.TzdbDateTimeZoneSource.GetIds" />, where
canonical IDs map to themselves.</para> <para>The returned map is read-only; any attempts to call a mutating method will throw
<see cref="T:System.NotSupportedException" />.</para>
public
System.​Collections.​Generic.​IList<​TzdbZoneLocation>
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.
Remarks Every zone location's time zone ID is guaranteed to be valid within this source (assuming the source
has been validated).
public
System.​Collections.​Generic.​IList<​TzdbZone1970Location>
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.
Remarks <p>
This location data differs from <see cref="P:NodaTime.TimeZones.TzdbDateTimeZoneSource.ZoneLocations" /> in two important respects:
<ul><li>Where multiple similar zones exist but only differ in transitions before 1970,
this location data chooses one zone to be the canonical "post 1970" zone.
</li><li>
This location data can represent multiple ISO-3166 country codes in a single entry. For example,
the entry corresponding to "Europe/London" includes country codes GB, GG, JE and IM (Britain,
Guernsey, Jersey and the Isle of Man, respectively).
</li></ul></p> <p>
Every zone location's time zone ID is guaranteed to be valid within this source (assuming the source
has been validated).
</p>
public
string
VersionId
Returns an appropriate version ID for diagnostic purposes, which must not be null.
Remarks <para>
This source returns a string such as "TZDB: 2013b (mapping: 8274)" corresponding to the versions of the tz
database and the CLDR Windows zones mapping file.
</para> <para>
Note that there is no need to parse this string to extract any of the above information, as it is available
directly from the <see cref="P:NodaTime.TimeZones.TzdbDateTimeZoneSource.TzdbVersion" /> and <see cref="P:NodaTime.TimeZones.Cldr.WindowsZones.Version" /> properties.
</para>
public
string
TzdbVersion
Gets just the TZDB version (e.g. "2013a") of the source data.
public
WindowsZones
WindowsMapping
Gets the Windows time zone mapping information provided in the CLDR
supplemental "windowsZones.xml" file.
public
System.​Collections.​Generic.​IReadOnlyDictionary<​string, string>
TzdbToWindowsIds
Returns a dictionary mapping TZDB IDs to Windows IDs.
Remarks <para>
Where a TZDB alias isn't present directly in the Windows mapping, but its canonical ID is,
the dictionary will contain an entry for the alias as well. For example, the TZDB ID
"Africa/Asmara" is an alias for "Africa/Nairobi", which has a Windows ID of "E. Africa Standard Time".
"Africa/Asmara" doesn't appear in the Windows mapping directly, but it will still be present in the
returned dictionary.
</para> <para>
Where a TZDB canonical ID isn't present in the Windows mapping, but an alias is, the dictionary
will contain an entry for the canonical ID as well. For example, the Windows mapping uses the
TZDB ID "Asia/Calcutta" for "India Standard Time". This is an alias for "Asia/Kolkata" in TZDB,
so the returned dictionary will have an entry mapping "Asia/Kolkata" to "Asia/Calcutta".
If multiple aliases for the same canonical ID have entries in the Windows mapping with different
Windows IDs, the alias that is earliest in lexicographical ordering determines the value for the entry.
</para> <para>
If a canonical ID is not present in the mapping, nor any of its aliases, it will not be present in
the returned dictionary.
</para>
public
System.​Collections.​Generic.​IReadOnlyDictionary<​string, string>
WindowsToTzdbIds
Returns a dictionary mapping Windows IDs to canonical TZDB IDs, using the
primary mapping in each <see cref="T:NodaTime.TimeZones.Cldr.MapZone" /> .
Remarks Sometimes the Windows mapping contains values which are not canonical TZDB IDs.
Every value in the returned dictionary is a canonical ID. For example, the Windows
mapping contains as "Asia/Calcutta" for the Windows ID "India Standard Time", but
"Asia/Calcutta" is an alias for "Asia/Kolkata". The entry for "India Standard Time"
in the returned dictionary therefore has "Asia/Kolkata" as the value.
Methods
public static
TzdbDateTimeZoneSource
FromStream​(System.​IO.​Stream stream)
Creates an instance from a stream in the custom Noda Time format. The stream must be readable.
Returns A <c>TzdbDateTimeZoneSource</c> providing information from the given stream.
stream
The stream containing time zone data
Remarks
<para>
The stream is not closed by this method, but will be read from
without rewinding. A successful call will read the stream to the end.
</para> <para>
See the user guide for instructions on how to generate an updated time zone database file from a copy of the
(textual) tz database.
</para>
public
DateTimeZone
ForId​(string id)
Returns the time zone definition associated with the given ID.
Returns The <see cref="T:NodaTime.DateTimeZone" /> for the given ID.
id
The ID of the time zone to return. This must be one of the IDs
returned by <see cref="M:NodaTime.TimeZones.IDateTimeZoneSource.GetIds" /> .
Remarks
<para>
Note that this is permitted to return a <see cref="T:NodaTime.DateTimeZone" /> that has a different ID to that
requested, if the ID provided is an alias.
</para> <para>
Note also that this method is not required to return the same <see cref="T:NodaTime.DateTimeZone" /> instance for
successive requests for the same ID; however, all instances returned for a given ID must compare as equal.
</para> <para>
It is advised that sources should document their behaviour regarding any fixed-offset timezones
(i.e. "UTC" and "UTC+/-Offset") that are included in the list returned by <see cref="M:NodaTime.TimeZones.IDateTimeZoneSource.GetIds" />.
(These IDs will not be requested by <see cref="T:NodaTime.TimeZones.DateTimeZoneCache" />, but any users calling
into the source directly may care.)
</para> <para>
The source need not attempt to cache time zones; caching is typically provided by
<see cref="T:NodaTime.TimeZones.DateTimeZoneCache" />.
</para>
public
System.​Collections.​Generic.​IEnumerable<​string>
GetIds​()
Returns an unordered enumeration of the IDs available from this source.
Returns The IDs available from this source.
Remarks
<para>
Every value in this enumeration must return a valid time zone from <see cref="M:NodaTime.TimeZones.IDateTimeZoneSource.ForId(System.String)" /> for the life of the source.
The enumeration may be empty, but must not be null, and must not contain any elements which are null. It
should not contain duplicates: this is not enforced, and while it may not have a significant impact on
clients in some cases, it is generally unfriendly. The built-in implementations never return duplicates.
</para> <para>
The source is not required to provide the IDs in any particular order, although they should be distinct.
</para> <para>
Note that this list may optionally contain any of the fixed-offset timezones (with IDs "UTC" and
"UTC+/-Offset"), but there is no requirement they be included.
</para>
public
string
GetSystemDefaultId​()
Returns this source's ID for the system default time zone.
Returns 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.
public
void
Validate​()
Validates that the data within this source is consistent with itself.
Remarks
Source data is not validated automatically when it's loaded, but any source
loaded from data produced by <c>NodaTime.TzdbCompiler</c> (including the data shipped with Noda Time)
will already have been validated via this method when it was originally produced. This method should
only normally be called explicitly if you have data from a source you're unsure of.
public
bool
Equals​(object obj)
Inherited from object
protected
void
Finalize​()
Inherited from object
public
int
GetHashCode​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object
public
string
ToString​()
Inherited from object