C# TimeZoneInfo GetAmbiguousTimeOffsets(DateTime)
Description
TimeZoneInfo GetAmbiguousTimeOffsets(DateTime)
returns
information about the possible dates and times that an ambiguous date and
time can be mapped to.
Syntax
TimeZoneInfo.GetAmbiguousTimeOffsets(DateTime)
has the following syntax.
public TimeSpan[] GetAmbiguousTimeOffsets(
DateTime dateTime
)
Parameters
TimeZoneInfo.GetAmbiguousTimeOffsets(DateTime)
has the following parameters.
dateTime
- A date and time.
Returns
TimeZoneInfo.GetAmbiguousTimeOffsets(DateTime)
method returns
Example
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.
/*w w w . j ava2 s . co m*/
using System;
public class MainClass{
public static void Main(String[] argv){
ShowPossibleUtcTimes(new DateTime(2007, 11, 4, 1, 0, 0),
TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"));
}
private static void ShowPossibleUtcTimes(DateTime ambiguousTime, TimeZoneInfo timeZone)
{
// Determine if time is ambiguous in target time zone
if (! timeZone.IsAmbiguousTime(ambiguousTime))
{
Console.WriteLine("{0} is not ambiguous in time zone {1}.",
ambiguousTime,
timeZone.DisplayName);
}
}
}
The code above generates the following result.