Q:

C# program to check whether a date and time in a particular time zone is ambiguous (TimeZoneInfo.IsAmbiguousTime() Method)

belongs to collection: C# TimeZoneInfo Class Programs

0

Syntax:

    bool TimeZoneInfo.IsAmbiguousTime (DateTime date_time);

Parameter(s):

  • date_time: The date time value to be checked whether it is ambiguous or not.

Return value:

This method returns a boolean value if the given time is ambiguous in a particular time zone then it returns true otherwise it returns false.

Exception(s):

  • System.ArgumentException
  •  

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

The source code to check whether a date and time in a particular time zone is ambiguous is given below. The given program is compiled and executed successfully.

using System;
using System.Globalization;
using System.Collections.ObjectModel;

class TimeZoneInfoDemo
{
    //Entry point of Program
    static public void Main()
    {
        DateTime ambiguousTime;

        TimeZoneInfo timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
        TimeZoneInfo timeZone2 = TimeZoneInfo.FindSystemTimeZoneById("UTC");

        ambiguousTime = new DateTime(2007, 11, 4, 1, 0, 0);

        if (timeZone1.IsAmbiguousTime(ambiguousTime))
            Console.WriteLine("Time is ambiguous");
        else
            Console.WriteLine("Time is not ambiguous");

        if (timeZone2.IsAmbiguousTime(ambiguousTime))
            Console.WriteLine("Time is ambiguous");
        else
            Console.WriteLine("Time is not ambiguous");
    }
}

Output:

Time is ambiguous
Time is not ambiguous
Press any key to continue . . .

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# TimeZoneInfo Class Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program to get the ambiguous time offsets (Time... >>
<< C# program to calculate the offset between the tim...