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.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var