TimeZoneFactory Class

Creates IdtTimeZone classes as required by the running application.

Definition

Namespace: InnerDrive.TimeZones
Assembly: InnerDrive.TimeZones (in InnerDrive.TimeZones.dll) Version: 5.3.9728.0
C#
public sealed class TimeZoneFactory : ITimeZoneFactory
Inheritance
Object    TimeZoneFactory
Implements
ITimeZoneFactory

Remarks

The TimeZoneFactory expects two configuration settings, plus the CLDR-related settings below if a ICldrFileReader is supplied to the constructor:
KeyDescription
timeZoneSettings:DefaultTimeZoneHomeZoneThe IANA identifier of your default time zone. Note that this time zone must be defined in the data that you read into the class.
timeZoneSettings:throwOnLoadFailure(Optional; default true) Throws an InvalidTimeZoneException if there is an error parsing time zone data
timeZoneSettings:cldrFolderRequired by LocalCldrFileReader: the folder containing staged CLDR data (metaZones.json plus one subfolder per staged locale).
timeZoneSettings:cldrLocalesRequired by LocalCldrFileReader: a comma-delimited list of locale folder names to stage from cldrFolder (e.g. en,es,fr-CA).
timeZoneSettings:cldrDefaultLocale(Optional; default en) The locale a requested culture falls back to when neither it, nor any culture in its Parent chain, matches a staged locale.
timeZoneSettings:cldrBlobNameRequired by AzureCldrFileReader in InnerDrive.Azure: the blob container holding the same metaZones.json / {locale}/timeZoneNames.json layout as LocalCldrFileReader.
timeZoneSettings:throwOnCldrLoadFailure(Optional; default false) Throws if CLDR data cannot be loaded or parsed, rather than tracing the failure and continuing with CLDR names unavailable — missing or invalid CLDR data never prevents zone resolution unless this is set.
timeZoneSettings:commonZonesComma-delimited TZDB zone IDs returned by ListCommonLocalizedNamesAsync(CultureInfo, TimeZoneNameStyle, CancellationToken), in the order given. There is no built-in default — an unset key means that method returns nothing, so document this prominently for operators. See the sample below for a representative ~30-zone starting list.
timeZoneSettings:searchMinimumLength(Optional; default 3) The minimum number of text elements a trimmed SearchLocalizedNamesAsync(String, CultureInfo, TimeZoneNameStyle, Int32, CancellationToken) query must have before it is searched. Lower this for CJK-heavy user bases, where a complete query can be one or two characters.
timeZoneSettings:searchIndexLifetimeSeconds(Optional; default 3600) How long a SearchLocalizedNamesAsync(String, CultureInfo, TimeZoneNameStyle, Int32, CancellationToken) per-locale index is used before it is rebuilt, bounding how stale a UTC offset or standard/daylight name can be across a DST transition.

Here is a typical configuration section in appSettings.json, including CLDR support and a representative common-zones starting list an operator can paste and edit:

{ "timeZoneSettings": { "defaultTimeZoneHomeZone": "America/Chicago", "throwOnLoadFailure": "false", "cldrFolder": "C:\\CldrData", "cldrLocales": "en,es,fr-CA,es,de,ja,zh", "cldrDefaultLocale": "en", "commonZones": "Pacific/Honolulu,America/Anchorage,America/Los_Angeles,America/Denver,America/Chicago,America/New_York,America/Sao_Paulo,Atlantic/Azores,Europe/London,Europe/Paris,Europe/Berlin,Europe/Athens,Europe/Moscow,Asia/Dubai,Asia/Karachi,Asia/Kolkata,Asia/Dhaka,Asia/Bangkok,Asia/Shanghai,Asia/Tokyo,Asia/Seoul,Australia/Perth,Australia/Sydney,Pacific/Auckland" } }

Constructors

TimeZoneFactory Creates a new instance of TimeZoneFactory.

Properties

CldrInitialized Indicates whether CLDR data loaded successfully
Count Gets the number of time zone rules currently loaded in the TimeZoneFactory.
Initialized Gets or sets an indication of whether the TimeZoneFactory has been initialized.
ThrowOnFailure If True (default), causes the class to throw an exception if the data cannot be parsed.
ZoneNames Gets the list of zone names that the TimeZoneFactory has knowledge of.

Methods

Clear Clears the cache of all time zone information.
Contains Gets an indication of whether the TimeZoneFactory contains a specific IdtTimeZone.
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
FindAsync Gets a IdtTimeZone from the cache.
GetDefaultTimeZoneAsync Gets the default time zone for the application
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
InitializeAsync Initializes the factory
ListCommonLocalizedNamesAsync Lists the curated set of "most common" time zones for the application's user base, with each zone's localized display name and current UTC offset.
ListLocalizedNamesAsync Lists every canonical zone the factory knows about, with each zone's localized display name and current UTC offset.
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
SearchLocalizedNamesAsync Performs a progressive (type-ahead) search for zones whose localized display name, exemplar city, or TZDB ID matches query.
ToStringReturns a string that represents the current object.
(Inherited from Object)

Fields

CldrDefaultLocaleSettingKey Gets the name of the application setting containing the configured default locale (e.g. "en") used when a requested culture, and its Parent chain, does not match a staged CLDR locale. Optional; defaults to "en".
CommonZonesSettingKey Gets the name of the application setting containing the comma-delimited list of TZDB zone IDs returned by ListCommonLocalizedNamesAsync(CultureInfo, TimeZoneNameStyle, CancellationToken). Optional; there is no built-in default, so an unset key returns an empty list.
DefaultTimeZoneNameSettingKey Gets the name of the application setting containing the name of the default time zone to use in the application.
DummyChangeRuleName Gets the symbol indicating that a TimeChangeRule is not required to determine how a TimeZoneRule works for a particular date range.
SearchIndexLifetimeSecondsSettingKey Gets the name of the application setting containing the number of seconds a SearchLocalizedNamesAsync(String, CultureInfo, TimeZoneNameStyle, Int32, CancellationToken) index is used before it is rebuilt. Optional; defaults to 3600.
SearchMinimumLengthSettingKey Gets the name of the application setting containing the minimum number of text elements a trimmed SearchLocalizedNamesAsync(String, CultureInfo, TimeZoneNameStyle, Int32, CancellationToken) query must have before it is searched. Optional; defaults to 3.
ThrowOnCldrLoadFailureSettingKey Gets the name of the application setting containing an indication of whether a failure to load or parse CLDR data should throw, rather than being traced and treated as CLDR simply being unavailable. Optional; defaults to false.
ThrowOnFailureSettingKey Gets the name of the application setting containing an indication of the default ThrowOnFailure behavior.

See Also