Class FakeDateTimeZoneSource
Implements
Inherited Members
Namespace: NodaTime.Testing.TimeZones
Assembly: NodaTime.Testing.dll
Syntax
public sealed class FakeDateTimeZoneSource : IDateTimeZoneSource
Properties
VersionId
Declaration
public string VersionId { get; }
Property Value
Type | Description |
---|---|
string | An appropriate version ID for diagnostic purposes. |
Remarks
Methods
ForId(string)
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
Type | Description |
---|---|
DateTimeZone | The DateTimeZone for the given ID. |
Remarks
Note that this is permitted to return a DateTimeZone that has a different ID to that requested, if the ID provided is an alias.
Note also that this method is not required to return the same DateTimeZone instance for successive requests for the same ID; however, all instances returned for a given ID must compare as equal.
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 GetIds(). (These IDs will not be requested by DateTimeZoneCache, but any users calling into the source directly may care.)
The source need not attempt to cache time zones; caching is typically provided by DateTimeZoneCache.
Exceptions
Type | Condition |
---|---|
ArgumentException | id is not supported by this source. |
GetIds()
Declaration
public IEnumerable<string> GetIds()
Returns
Type | Description |
---|---|
IEnumerable<string> | The IDs available from this source. |
Remarks
Every value in this enumeration must return a valid time zone from ForId(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.
The source is not required to provide the IDs in any particular order, although they should be distinct.
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.
GetSystemDefaultId()
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. |
ToProvider()
Declaration
public IDateTimeZoneProvider ToProvider()
Returns
Type | Description |
---|---|
IDateTimeZoneProvider | A provider backed by this source. |