Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TimeZoneInfo::GetAmbiguousTimeOffsets Method (DateTime)

 

Returns information about the possible dates and times that an ambiguous date and time can be mapped to.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public:
array<TimeSpan>^ GetAmbiguousTimeOffsets(
	DateTime dateTime
)

Parameters

dateTime
Type: System::DateTime

A date and time.

Return Value

Type: array<System::TimeSpan>^

An array of objects that represents possible Coordinated Universal Time (UTC) offsets that a particular date and time can be mapped to.

Exception Condition
ArgumentException

dateTime is not an ambiguous time.

The precise behavior of this method depends on the relationship between the Kind property and the TimeZoneInfo object, as the following table shows.

TimeZoneInfo object type

Kind property value

Behavior

TimeZoneInfo::Local

DateTimeKind::Local or DateTimeKind::Unspecified

Returns ambiguous time offsets for dateTime.

TimeZoneInfo::Local

DateTimeKind::Utc

Converts dateTime to the local time, and then returns ambiguous time offsets for that time.

TimeZoneInfo::Utc

Any value.

Throws an ArgumentException.

Any other time zone.

Local or DateTimeKind::Utc

Converts dateTime to the specified time zone, and then determines whether that time is ambiguous.

Any other time zone.

DateTimeKind::Unspecified

Determines whether dateTime is ambiguous in the specified time zone.

The order of TimeSpan objects in the array returned by this method is undefined. However, you can determine which element represents an offset from the time zone's standard time by comparing its value with the time zone's BaseUtcOffset property. To map an ambiguous time to a time zone's standard time, see How to: Resolve Ambiguous Times.

Notes to Callers:

On Windows XP systems, this method applies only the current adjustment rule when determining whether dateTime is ambiguous if the current instance is TimeZoneInfo::Local. As a result, the method may not accurately report ambiguous time offsets for periods before the current adjustment rule came into effect. For more information, see the Notes for Callers section in the Local property.

The following example defines a method named ShowPossibleUtcTimes that uses the GetAmbiguousTimeOffsets(DateTime) method to map an ambiguous time to its possible corresponding Coordinated Universal Time (UTC) times.

No code example is currently available or this language may not be supported.

The method can then be called using code such as the following:

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.5
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2017 Microsoft