Check if date and time(DateTime) 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 date and time(DateTime) is ambiguous and can be mapped to two or more Coordinated Universal Time (UTC) times.

Example


using System;/*from   w ww . j  a v a 2s. c  o  m*/
public class MainClass{
  public static void Main(String[] argv){  
    DateTime baseTime = new DateTime(2014, 11, 4, 0, 59, 00, DateTimeKind.Unspecified);
    DateTime 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