Check if a date and time(DateTimeOffset) is ambiguous and can be mapped to two or more Coordinated Universal Time (UTC) times in CSharp
Description
The following code shows how to check if a date and time(DateTimeOffset) is ambiguous and can be mapped to two or more Coordinated Universal Time (UTC) times.
Example
using System;//from w w w. ja va 2 s . co m
public class MainClass
{
public static void Main(String[] argv)
{
DateTimeOffset baseTime = DateTimeOffset.Now;
DateTimeOffset newTime;
// Get Pacific Standard Time zone
TimeZoneInfo pstZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");
newTime = baseTime.AddMinutes(13);
Console.WriteLine("{0} is ambiguous: {1}", newTime, pstZone.IsAmbiguousTime(newTime));
}
}
The code above generates the following result.