Class TimeZoneInfo
- Namespace
- Geotab.Checkmate.ObjectModel
- Assembly
- Geotab.Checkmate.ObjectModel.dll
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
stringThe id.
offsetFromUtc
TimeSpanThe offset from UTC.
isDaylightSavingTimeSupported
boolIf true, this Timezone supports daylight saving time.
Properties
Id
Gets or sets the Olson Timezone identifier.
public string? Id { get; set; }
Property Value
IsDaylightSavingTimeSupported
Gets or sets a value indicating whether the Timezone supports daylight saving time.
public bool? IsDaylightSavingTimeSupported { get; set; }
Property Value
OffsetFromUtc
Gets or sets the offset of the Timezone from UTC.
public TimeSpan? OffsetFromUtc { get; set; }
Property Value
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
stringThe timezone identifier.
Returns
GetDateTimeFormatByTimeZone(string)
Gets the date time format used by default for different Timezones.
public static string GetDateTimeFormatByTimeZone(string id)
Parameters
id
stringThe timezone identifier.
Returns
GetFuelEconomyUnitByTimeZone(string)
Gets the default fuel economy unit for a Timezone.
public static FuelEconomyUnit GetFuelEconomyUnitByTimeZone(string id)
Parameters
id
stringThe timezone identifier.
Returns
GetIsMetricByTimeZone(string?)
Gets whether the country is metric by timezone.
public static bool GetIsMetricByTimeZone(string? id)
Parameters
id
stringThe 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
stringThe olsen identifier.
Returns
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
stringThe Timezone Id.
Returns
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
stringA 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
stringAn 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()
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
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.