Class TZConvert
- Namespace
- TimeZoneConverter
- Assembly
- Ecng.Common.dll
Converts time zone identifiers from various sources.
public static class TZConvert
- Inheritance
-
TZConvert
- Inherited Members
Properties
KnownIanaTimeZoneNames
Gets a collection of all IANA time zone names known to this library.
public static ICollection<string> KnownIanaTimeZoneNames { get; }
Property Value
KnownRailsTimeZoneNames
Gets a collection of all Rails time zone names known to this library.
public static ICollection<string> KnownRailsTimeZoneNames { get; }
Property Value
KnownWindowsTimeZoneIds
Gets a collection of all Windows time zone IDs known to this library.
public static ICollection<string> KnownWindowsTimeZoneIds { get; }
Property Value
Methods
GetTimeZoneInfo(string)
Retrieves a TimeZoneInfo object given a valid Windows or IANA time zone identifier, regardless of which platform the application is running on.
public static TimeZoneInfo GetTimeZoneInfo(string windowsOrIanaTimeZoneId)
Parameters
windowsOrIanaTimeZoneId
stringA valid Windows or IANA time zone identifier.
Returns
- TimeZoneInfo
A TimeZoneInfo object.
IanaToRails(string)
Converts an IANA time zone name to one or more equivalent Rails time zone names.
public static IList<string> IanaToRails(string ianaTimeZoneName)
Parameters
ianaTimeZoneName
stringThe IANA time zone name to convert.
Returns
Exceptions
- InvalidTimeZoneException
Thrown if the input string was not recognized or has no equivalent Rails zone.
IanaToWindows(string)
Converts an IANA time zone name to the equivalent Windows time zone ID.
public static string IanaToWindows(string ianaTimeZoneName)
Parameters
ianaTimeZoneName
stringThe IANA time zone name to convert.
Returns
- string
A Windows time zone ID.
Exceptions
- InvalidTimeZoneException
Thrown if the input string was not recognized or has no equivalent Windows zone.
RailsToIana(string)
Converts a Rails time zone name to an equivalent IANA time zone name.
public static string RailsToIana(string railsTimeZoneName)
Parameters
railsTimeZoneName
stringThe Rails time zone name to convert.
Returns
- string
An IANA time zone name.
Exceptions
- InvalidTimeZoneException
Thrown if the input string was not recognized or has no equivalent IANA zone.
RailsToWindows(string)
Converts a Rails time zone name to an equivalent Windows time zone ID.
public static string RailsToWindows(string railsTimeZoneName)
Parameters
railsTimeZoneName
stringThe Rails time zone name to convert.
Returns
- string
A Windows time zone ID.
Exceptions
- InvalidTimeZoneException
Thrown if the input string was not recognized or has no equivalent Windows zone.
TryGetTimeZoneInfo(string, out TimeZoneInfo)
Attempts to retrieve a TimeZoneInfo object given a valid Windows or IANA time zone identifier, regardless of which platform the application is running on.
public static bool TryGetTimeZoneInfo(string windowsOrIanaTimeZoneId, out TimeZoneInfo timeZoneInfo)
Parameters
windowsOrIanaTimeZoneId
stringA valid Windows or IANA time zone identifier.
timeZoneInfo
TimeZoneInfoA TimeZoneInfo object.
Returns
- bool
true
if successful,false
otherwise.
TryIanaToRails(string, out IList<string>)
Attempts to convert an IANA time zone name to one or more equivalent Rails time zone names.
public static bool TryIanaToRails(string ianaTimeZoneName, out IList<string> railsTimeZoneNames)
Parameters
ianaTimeZoneName
stringThe IANA time zone name to convert.
railsTimeZoneNames
IList<string>One or more equivalent Rails time zone names.
Returns
- bool
true
if successful,false
otherwise.
TryIanaToWindows(string, out string)
Attempts to convert an IANA time zone name to the equivalent Windows time zone ID.
public static bool TryIanaToWindows(string ianaTimeZoneName, out string windowsTimeZoneId)
Parameters
ianaTimeZoneName
stringThe IANA time zone name to convert.
windowsTimeZoneId
stringA Windows time zone ID.
Returns
- bool
true
if successful,false
otherwise.
TryRailsToIana(string, out string)
Attempts to convert a Rails time zone name to an equivalent IANA time zone name.
public static bool TryRailsToIana(string railsTimeZoneName, out string ianaTimeZoneName)
Parameters
railsTimeZoneName
stringThe Rails time zone name to convert.
ianaTimeZoneName
stringAn IANA time zone name.
Returns
- bool
true
if successful,false
otherwise.
TryRailsToWindows(string, out string)
Attempts to convert a Rails time zone name to an equivalent Windows time zone ID.
public static bool TryRailsToWindows(string railsTimeZoneName, out string windowsTimeZoneId)
Parameters
railsTimeZoneName
stringThe Rails time zone name to convert.
windowsTimeZoneId
stringA Windows time zone ID.
Returns
- bool
true
if successful,false
otherwise.
TryWindowsToIana(string, string, out string)
Attempts to convert a Windows time zone ID to an equivalent IANA time zone name.
public static bool TryWindowsToIana(string windowsTimeZoneId, string territoryCode, out string ianaTimeZoneName)
Parameters
windowsTimeZoneId
stringThe Windows time zone ID to convert.
territoryCode
stringAn optional two-letter ISO Country/Region code, used to get a a specific mapping. Defaults to "001" if not specified, which means to get the "golden zone" - the one that is most prevalent.
ianaTimeZoneName
stringAn IANA time zone name.
Returns
- bool
true
if successful,false
otherwise.
TryWindowsToIana(string, out string)
Attempts to convert a Windows time zone ID to an equivalent IANA time zone name. Uses the "golden zone" - the one that is the most prevalent.
public static bool TryWindowsToIana(string windowsTimeZoneId, out string ianaTimeZoneName)
Parameters
windowsTimeZoneId
stringThe Windows time zone ID to convert.
ianaTimeZoneName
stringAn IANA time zone name.
Returns
- bool
true
if successful,false
otherwise.
TryWindowsToRails(string, out IList<string>)
Attempts to convert a Windows time zone ID to one ore more equivalent Rails time zone names. Uses the "golden zone" - the one that is the most prevalent.
public static bool TryWindowsToRails(string windowsTimeZoneId, out IList<string> railsTimeZoneNames)
Parameters
windowsTimeZoneId
stringThe Windows time zone ID to convert.
railsTimeZoneNames
IList<string>One or more equivalent Rails time zone names.
Returns
- bool
true
if successful,false
otherwise.
TryWindowsToRails(string, string, out IList<string>)
Attempts to convert a Windows time zone ID to one ore more equivalent Rails time zone names.
public static bool TryWindowsToRails(string windowsTimeZoneId, string territoryCode, out IList<string> railsTimeZoneNames)
Parameters
windowsTimeZoneId
stringThe Windows time zone ID to convert.
territoryCode
stringAn optional two-letter ISO Country/Region code, used to get a a specific mapping. Defaults to "001" if not specified, which means to get the "golden zone" - the one that is most prevalent.
railsTimeZoneNames
IList<string>One or more equivalent Rails time zone names.
Returns
- bool
true
if successful,false
otherwise.
WindowsToIana(string, string)
Converts a Windows time zone ID to an equivalent IANA time zone name.
public static string WindowsToIana(string windowsTimeZoneId, string territoryCode = "001")
Parameters
windowsTimeZoneId
stringThe Windows time zone ID to convert.
territoryCode
stringAn optional two-letter ISO Country/Region code, used to get a a specific mapping. Defaults to "001" if not specified, which means to get the "golden zone" - the one that is most prevalent.
Returns
- string
An IANA time zone name.
Exceptions
- InvalidTimeZoneException
Thrown if the input string was not recognized or has no equivalent IANA zone.
WindowsToRails(string, string)
Converts a Windows time zone ID to one ore more equivalent Rails time zone names.
public static IList<string> WindowsToRails(string windowsTimeZoneId, string territoryCode = "001")
Parameters
windowsTimeZoneId
stringThe Windows time zone ID to convert.
territoryCode
stringAn optional two-letter ISO Country/Region code, used to get a a specific mapping. Defaults to "001" if not specified, which means to get the "golden zone" - the one that is most prevalent.
Returns
Exceptions
- InvalidTimeZoneException
Thrown if the input string was not recognized or has no equivalent Rails zone.