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.​DateTimeZoneCache
Assembly: NodaTime
Inheritance: object → DateTimeZoneCache
Implemented Interfaces
Provides an implementation of <see cref="T:NodaTime.IDateTimeZoneProvider" /> that caches results from an <see cref="T:NodaTime.TimeZones.IDateTimeZoneSource" /> .
Remarks
The process of loading or creating time zones may be an expensive operation. This class implements an
unlimited-size non-expiring cache over a time zone source, and adapts an implementation of the
<c>IDateTimeZoneSource</c> interface to an <c>IDateTimeZoneProvider</c> .
Properties
public
string
VersionId
Gets the version ID of this provider. This is simply the <see cref="P:NodaTime.TimeZones.IDateTimeZoneSource.VersionId" /> returned by
the underlying source.
public
System.​Collections.​ObjectModel.​ReadOnlyCollection<​string>
Ids
Gets the list of valid time zone ids advertised by this provider.
Remarks <para>
This list will be sorted in ordinal lexicographic order. It cannot be modified by callers, and
must not be modified by the provider either: client code can safely treat it as thread-safe
and deeply immutable.
</para> <para>
In addition to the list returned here, providers always support the fixed-offset timezones with IDs "UTC"
and "UTC+/-Offset". These may or may not be included explicitly in this list.
</para>
public
DateTimeZone
Item
Methods
public
DateTimeZone
GetSystemDefault​()
Gets the time zone from this provider that matches the system default time zone, if a matching time zone is
available.
Returns The provider-specific representation of the system default time zone.
Remarks
<para>
Callers should be aware that this method will throw <see cref="T:NodaTime.TimeZones.DateTimeZoneNotFoundException" /> if no matching
time zone is found. For the built-in Noda Time providers, this is unlikely to occur in practice (assuming
the system is using a standard Windows time zone), but can occur even then, if no mapping is found. The TZDB
source contains mappings for almost all Windows system time zones, but a few (such as "Mid-Atlantic Standard Time")
are unmappable.
</para> <para>
If it is necessary to handle this case, callers can construct a
<see cref="T:NodaTime.TimeZones.BclDateTimeZone" /> via <see cref="M:NodaTime.TimeZones.BclDateTimeZone.ForSystemDefault" />, which returns a
<see cref="T:NodaTime.DateTimeZone" /> that wraps the system local <see cref="T:System.TimeZoneInfo" />, and which always
succeeds.
Note that <c>BclDateTimeZone</c> may not be available in all versions of Noda Time 1.x and 2.x; see
the class documentation for more details.
</para>
public
DateTimeZone
GetZoneOrNull​(string id)
Returns the time zone for the given ID, if it's available.
Returns The <see cref="T:NodaTime.DateTimeZone" /> for the given ID or null if the provider does not support
the given ID.
id
The time zone ID to find.
Remarks
<para>
Note that this may 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>
The fixed-offset timezones with IDs "UTC" and "UTC+/-Offset" are always available.
</para>
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