Class ZoneSource
The time zone data that Zones() and ZonedDateTimes() draw from: which zones exist, and when each one's offset changes. It should be the data the code under test uses, so that a drawn wall-clock time is skipped or repeated for that code too.
public sealed class ZoneSource
- Inheritance
-
ZoneSource
- Inherited Members
Remarks
Host, the default, is this system's zones as TimeZoneInfo sees them; Bundled is the IANA database compiled into the engine, the same on every machine; FromTimeZones(params TimeZoneInfo[]) and CreateBuilder() make a source from zones of your own. Use one for a generator with Source(ZoneSource) or Source(ZoneSource), or for every generator built from then on with SetDefault(ZoneSource).
A draw yields a TimeZoneInfo, so only names that have one are drawn: the object a zone was added from (FromTimeZones(params TimeZoneInfo[]), AddTimeZone(TimeZoneInfo)), or else the zone this system has under that name. For a zone added from a TimeZoneInfo, which includes every zone of Host, a zoned date-time whose offset the object does not agree with is rejected rather than drawn. For a zone added any other way nothing compares the source's data with this system's zone of the same name: the drawn ZonedDateTime reports the source's reading.
Properties
Bundled
The IANA time zone database compiled into the engine, the same on every machine. A name of it that this system has no TimeZoneInfo for is not drawn, and nothing checks that this system's zones agree with it.
public static ZoneSource Bundled { get; }
Property Value
Default
The source a generator uses unless it is given one: Host until SetDefault(ZoneSource) says otherwise.
public static ZoneSource Default { get; }
Property Value
Host
This system's time zones, as TimeZoneInfo reports them: every name of the IANA database that TryFindSystemTimeZoneById(string, out TimeZoneInfo) finds, each with the offsets that TimeZoneInfo gives for it. The default.
public static ZoneSource Host { get; }
Property Value
Names
Every name the source knows, sorted, links and legacy names included, whether or not this system has a TimeZoneInfo for it.
public IReadOnlyList<string> Names { get; }
Property Value
Version
Which release of its database the source holds, such as 2025b: the engine's for
Bundled, what Version(string) recorded for a built
source, and otherwise empty.
public string Version { get; }
Property Value
Methods
CreateBuilder()
A builder for a source of zones given as TZif files, TimeZoneInfo objects, oracles and links.
public static ZoneSourceBuilder CreateBuilder()
Returns
FromTimeZones(IEnumerable<TimeZoneInfo>)
A source of exactly zones, each drawn under its Id and behaving as the object does.
public static ZoneSource FromTimeZones(IEnumerable<TimeZoneInfo> zones)
Parameters
zonesIEnumerable<TimeZoneInfo>The zones.
Returns
FromTimeZones(params TimeZoneInfo[])
A source of exactly zones, each drawn under its Id and behaving as the object does.
public static ZoneSource FromTimeZones(params TimeZoneInfo[] zones)
Parameters
zonesTimeZoneInfo[]The zones.
Returns
SetDefault(ZoneSource)
Make source the default for the whole process. A generator reads the
default when it is created, so those that already exist keep the source they have.
public static ZoneSource SetDefault(ZoneSource source)
Parameters
sourceZoneSourceThe new default.
Returns
- ZoneSource
The previous default, to restore afterwards.