Table of Contents

Class TimeZoneInfo

Namespace
Geotab.Checkmate.ObjectModel
Assembly
Geotab.Checkmate.ObjectModel.dll

true Information about an Olson Timezone.

public class TimeZoneInfo
Inheritance
TimeZoneInfo
Inherited Members

Remarks

Check https://www.iana.org/time-zones -> Data Only Distribution (ctrl+f for geographic capitals) for Olson zone name

Constructors

TimeZoneInfo()

Initializes a new instance of the TimeZoneInfo class.Initializes a new instance of the TimeZoneInfo class.

public TimeZoneInfo()

TimeZoneInfo(string, in TimeSpan, bool)

Initializes a new instance of the TimeZoneInfo class.Initializes a new instance of the TimeZoneInfo class.

public TimeZoneInfo(string id, in TimeSpan offsetFromUtc, bool isDaylightSavingTimeSupported)

Parameters

id string

The id.

offsetFromUtc TimeSpan

The offset from UTC.

isDaylightSavingTimeSupported bool

If true, this Timezone supports daylight saving time.

Properties

Id

Gets or sets the Olson Timezone identifier.

public string? Id { get; set; }

Property Value

string

string

IsDaylightSavingTimeSupported

Gets or sets a value indicating whether the Timezone supports daylight saving time.

public bool? IsDaylightSavingTimeSupported { get; set; }

Property Value

bool?

bool

OffsetFromUtc

Gets or sets the offset of the Timezone from UTC.

public TimeSpan? OffsetFromUtc { get; set; }

Property Value

TimeSpan?

TimeSpan

OlsonWindowsTimes

Gets Timezone Id's mapped from Olson Timezone (key) to Windows Timezone (value). Note: there is not a 1:1 mapping. List generated by TRUNK/Odds/TimeZoneMapper. XML file from http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml.

public static Dictionary<string, string>? OlsonWindowsTimes { get; }

Property Value

Dictionary<string, string>

Timezone Id's mapped from Olson Timezone (key) to Windows Timezone (value). Note: there is not a 1:1 mapping. List generated by TRUNK/Odds/TimeZoneMapper. XML file from http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml.

Methods

GetContinentByTimeZone(string?)

Gets the continent of the Timezone.

public static Continent? GetContinentByTimeZone(string? id)

Parameters

id string

The timezone identifier.

Returns

Continent?

Continent

GetDateTimeFormatByTimeZone(string)

Gets the date time format used by default for different Timezones.

public static string GetDateTimeFormatByTimeZone(string id)

Parameters

id string

The timezone identifier.

Returns

string

string

GetFuelEconomyUnitByTimeZone(string)

Gets the default fuel economy unit for a Timezone.

public static FuelEconomyUnit GetFuelEconomyUnitByTimeZone(string id)

Parameters

id string

The timezone identifier.

Returns

FuelEconomyUnit

FuelEconomyUnit

GetIsMetricByTimeZone(string?)

Gets whether the country is metric by timezone.

public static bool GetIsMetricByTimeZone(string? id)

Parameters

id string

The timezone identifier.

Returns

bool

Nullable<T> where T is. bool

InfoFromOlsenId(string)

Get a TimeZoneInfo from an olsen id.

public static TimeZoneInfo InfoFromOlsenId(string olsenId)

Parameters

olsenId string

The olsen identifier.

Returns

TimeZoneInfo

TimeZoneInfo

Exceptions

ArgumentNullException

olsenId cannot be null.

IsOlson(string?)

Checks if the id is an Olson Timezone ID.

public static bool IsOlson(string? id)

Parameters

id string

The Timezone Id.

Returns

bool

bool

MachineToOlson(string)

Converts a machine's Timezone ID (Windows or Linux) to a Olson Timezone ID. This is a no-op on linux.

public static string MachineToOlson(string machineId)

Parameters

machineId string

A Machine Timezone ID.

Returns

string

A Olson Timezone id. See: http://www.unicode.org/cldr/charts/latest/supplemental/zone_tzid.html or: http://www.unicode.org/cldr/charts/dev/supplemental/zone_tzid.html.

OlsonToMachine(string)

Converts an Olson Timezone id to the windows equivalent timezone, or if on linux just returns the same Olson Timezone id.

public static string OlsonToMachine(string olsonId)

Parameters

olsonId string

An Olson Timezone ID.

Returns

string

A Olson Timezone ID. See: http://www.unicode.org/cldr/charts/latest/supplemental/zone_tzid.html or: http://www.unicode.org/cldr/charts/dev/supplemental/zone_tzid.html.

ToString()

false To string method.

public override string ToString()

Returns

string

The Olson Timezone Id.

TryParseOlsonTimeZoneId(string)

Gets the TimeZoneInfo for the specified Timezone ID.

public static TimeZoneInfo? TryParseOlsonTimeZoneId(string timeZoneId)

Parameters

timeZoneId string

A string containing the Timezone id to convert.

Returns

TimeZoneInfo

the TimeZoneInfo associated with the specified timeZoneId, if the conversion succeeded, or null if the conversion failed. The conversion fails if the TimeZoneId is not a valid Timezone id.