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
windowsOrIanaTimeZoneIdstringA 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
ianaTimeZoneNamestringThe 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
ianaTimeZoneNamestringThe 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
railsTimeZoneNamestringThe 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
railsTimeZoneNamestringThe 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
windowsOrIanaTimeZoneIdstringA valid Windows or IANA time zone identifier.
timeZoneInfoTimeZoneInfoA TimeZoneInfo object.
Returns
- bool
trueif successful,falseotherwise.
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
ianaTimeZoneNamestringThe IANA time zone name to convert.
railsTimeZoneNamesIList<string>One or more equivalent Rails time zone names.
Returns
- bool
trueif successful,falseotherwise.
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
ianaTimeZoneNamestringThe IANA time zone name to convert.
windowsTimeZoneIdstringA Windows time zone ID.
Returns
- bool
trueif successful,falseotherwise.
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
railsTimeZoneNamestringThe Rails time zone name to convert.
ianaTimeZoneNamestringAn IANA time zone name.
Returns
- bool
trueif successful,falseotherwise.
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
railsTimeZoneNamestringThe Rails time zone name to convert.
windowsTimeZoneIdstringA Windows time zone ID.
Returns
- bool
trueif successful,falseotherwise.
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
windowsTimeZoneIdstringThe Windows time zone ID to convert.
territoryCodestringAn 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.
ianaTimeZoneNamestringAn IANA time zone name.
Returns
- bool
trueif successful,falseotherwise.
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
windowsTimeZoneIdstringThe Windows time zone ID to convert.
ianaTimeZoneNamestringAn IANA time zone name.
Returns
- bool
trueif successful,falseotherwise.
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
windowsTimeZoneIdstringThe Windows time zone ID to convert.
railsTimeZoneNamesIList<string>One or more equivalent Rails time zone names.
Returns
- bool
trueif successful,falseotherwise.
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
windowsTimeZoneIdstringThe Windows time zone ID to convert.
territoryCodestringAn 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.
railsTimeZoneNamesIList<string>One or more equivalent Rails time zone names.
Returns
- bool
trueif successful,falseotherwise.
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
windowsTimeZoneIdstringThe Windows time zone ID to convert.
territoryCodestringAn 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
windowsTimeZoneIdstringThe Windows time zone ID to convert.
territoryCodestringAn 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.