TZConvert

Ecng.Common.TimeZoneConverter

Converts time zone identifiers from various sources.

属性

KnownIanaTimeZoneNames
public static ICollection<string> KnownIanaTimeZoneNames { get; }
value = TZConvert.KnownIanaTimeZoneNames

Gets a collection of all IANA time zone names known to this library.

KnownRailsTimeZoneNames
public static ICollection<string> KnownRailsTimeZoneNames { get; }
value = TZConvert.KnownRailsTimeZoneNames

Gets a collection of all Rails time zone names known to this library.

KnownWindowsTimeZoneIds
public static ICollection<string> KnownWindowsTimeZoneIds { get; }
value = TZConvert.KnownWindowsTimeZoneIds

Gets a collection of all Windows time zone IDs known to this library.

方法

GetTimeZoneInfo
public static TimeZoneInfo GetTimeZoneInfo(string windowsOrIanaTimeZoneId)
result = TZConvert.GetTimeZoneInfo(windowsOrIanaTimeZoneId)

Retrieves a TimeZoneInfo object given a valid Windows or IANA time zone identifier, regardless of which platform the application is running on.

windowsOrIanaTimeZoneId
A valid Windows or IANA time zone identifier.

返回值: A TimeZoneInfo object.

IanaToRails
public static IList<string> IanaToRails(string ianaTimeZoneName)
result = TZConvert.IanaToRails(ianaTimeZoneName)

Converts an IANA time zone name to one or more equivalent Rails time zone names.

ianaTimeZoneName
The IANA time zone name to convert.

返回值: One or more equivalent Rails time zone names.

IanaToWindows
public static string IanaToWindows(string ianaTimeZoneName)
result = TZConvert.IanaToWindows(ianaTimeZoneName)

Converts an IANA time zone name to the equivalent Windows time zone ID.

ianaTimeZoneName
The IANA time zone name to convert.

返回值: A Windows time zone ID.

RailsToIana
public static string RailsToIana(string railsTimeZoneName)
result = TZConvert.RailsToIana(railsTimeZoneName)

Converts a Rails time zone name to an equivalent IANA time zone name.

railsTimeZoneName
The Rails time zone name to convert.

返回值: An IANA time zone name.

RailsToWindows
public static string RailsToWindows(string railsTimeZoneName)
result = TZConvert.RailsToWindows(railsTimeZoneName)

Converts a Rails time zone name to an equivalent Windows time zone ID.

railsTimeZoneName
The Rails time zone name to convert.

返回值: A Windows time zone ID.

TryGetTimeZoneInfo
public static bool TryGetTimeZoneInfo(string windowsOrIanaTimeZoneId, TimeZoneInfo timeZoneInfo)
result = TZConvert.TryGetTimeZoneInfo(windowsOrIanaTimeZoneId, 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.

windowsOrIanaTimeZoneId
A valid Windows or IANA time zone identifier.
timeZoneInfo
A TimeZoneInfo object.

返回值: true if successful, false otherwise.

TryIanaToRails
public static bool TryIanaToRails(string ianaTimeZoneName, IList<string> railsTimeZoneNames)
result = TZConvert.TryIanaToRails(ianaTimeZoneName, railsTimeZoneNames)

Attempts to convert an IANA time zone name to one or more equivalent Rails time zone names.

ianaTimeZoneName
The IANA time zone name to convert.
railsTimeZoneNames
One or more equivalent Rails time zone names.

返回值: true if successful, false otherwise.

TryIanaToWindows
public static bool TryIanaToWindows(string ianaTimeZoneName, string windowsTimeZoneId)
result = TZConvert.TryIanaToWindows(ianaTimeZoneName, windowsTimeZoneId)

Attempts to convert an IANA time zone name to the equivalent Windows time zone ID.

ianaTimeZoneName
The IANA time zone name to convert.
windowsTimeZoneId
A Windows time zone ID.

返回值: true if successful, false otherwise.

TryRailsToIana
public static bool TryRailsToIana(string railsTimeZoneName, string ianaTimeZoneName)
result = TZConvert.TryRailsToIana(railsTimeZoneName, ianaTimeZoneName)

Attempts to convert a Rails time zone name to an equivalent IANA time zone name.

railsTimeZoneName
The Rails time zone name to convert.
ianaTimeZoneName
An IANA time zone name.

返回值: true if successful, false otherwise.

TryRailsToWindows
public static bool TryRailsToWindows(string railsTimeZoneName, string windowsTimeZoneId)
result = TZConvert.TryRailsToWindows(railsTimeZoneName, windowsTimeZoneId)

Attempts to convert a Rails time zone name to an equivalent Windows time zone ID.

railsTimeZoneName
The Rails time zone name to convert.
windowsTimeZoneId
A Windows time zone ID.

返回值: true if successful, false otherwise.

TryWindowsToIana
public static bool TryWindowsToIana(string windowsTimeZoneId, string ianaTimeZoneName)
result = TZConvert.TryWindowsToIana(windowsTimeZoneId, ianaTimeZoneName)

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.

windowsTimeZoneId
The Windows time zone ID to convert.
ianaTimeZoneName
An IANA time zone name.

返回值: true if successful, false otherwise.

TryWindowsToIana
public static bool TryWindowsToIana(string windowsTimeZoneId, string territoryCode, string ianaTimeZoneName)
result = TZConvert.TryWindowsToIana(windowsTimeZoneId, territoryCode, ianaTimeZoneName)

Attempts to convert a Windows time zone ID to an equivalent IANA time zone name.

windowsTimeZoneId
The Windows time zone ID to convert.
territoryCode
An 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
An IANA time zone name.

返回值: true if successful, false otherwise.

TryWindowsToRails
public static bool TryWindowsToRails(string windowsTimeZoneId, IList<string> railsTimeZoneNames)
result = TZConvert.TryWindowsToRails(windowsTimeZoneId, railsTimeZoneNames)

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.

windowsTimeZoneId
The Windows time zone ID to convert.
railsTimeZoneNames
One or more equivalent Rails time zone names.

返回值: true if successful, false otherwise.

TryWindowsToRails
public static bool TryWindowsToRails(string windowsTimeZoneId, string territoryCode, IList<string> railsTimeZoneNames)
result = TZConvert.TryWindowsToRails(windowsTimeZoneId, territoryCode, railsTimeZoneNames)

Attempts to convert a Windows time zone ID to one ore more equivalent Rails time zone names.

windowsTimeZoneId
The Windows time zone ID to convert.
territoryCode
An 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
One or more equivalent Rails time zone names.

返回值: true if successful, false otherwise.

WindowsToIana
public static string WindowsToIana(string windowsTimeZoneId, string territoryCode)
result = TZConvert.WindowsToIana(windowsTimeZoneId, territoryCode)

Converts a Windows time zone ID to an equivalent IANA time zone name.

windowsTimeZoneId
The Windows time zone ID to convert.
territoryCode
An 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.

返回值: An IANA time zone name.

WindowsToRails
public static IList<string> WindowsToRails(string windowsTimeZoneId, string territoryCode)
result = TZConvert.WindowsToRails(windowsTimeZoneId, territoryCode)

Converts a Windows time zone ID to one ore more equivalent Rails time zone names.

windowsTimeZoneId
The Windows time zone ID to convert.
territoryCode
An 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.

返回值: One or more equivalent Rails time zone names.