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);
       }
    }
  
}




















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