Get possible dates and times that an ambiguous date and time(DateTime) can be mapped to in CSharp
Description
The following code shows how to get possible dates and times that an ambiguous date and time(DateTime) can be mapped to.
Example
//w w w . j av a 2s . com
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);
}
}
}