public void TestUpperLongitudeLimit()
        {
            GoogleTimeZone googleTimeZone = new GoogleTimeZone("AIzaSyCVGJtR2LgD5arGM_61hToUE2iNlb_VBfc");
            DateTime       dt             = DateTime.Now;
            GeoLocation    location       = new GeoLocation() //Fiji Island
            {
                Latitude  = -17.847737,
                Longitude = 177.904347
            };
            GoogleTimeZoneResult result = googleTimeZone.GetTimeZoneByLocation(dt, location);

            Assert.IsTrue(result != null, "Request Succeded with longitude of 180");

            location.Longitude = 179; //Somewhere in the ocean
            try
            {
                result = null;
                result = googleTimeZone.GetTimeZoneByLocation(dt, location);
            }
            catch (Exception e)
            {
                Assert.IsTrue(result == null, "Getting no result");
            }

            location.Longitude = 181;  //Out of scope
            try
            {
                result = null;
                result = googleTimeZone.GetTimeZoneByLocation(dt, location);
            }
            catch (Exception e)
            {
                Assert.IsTrue(result == null, "Bad Exception errors");
            }
        }
Example #2
0
        public void TestGetTimeZoneByAddress()
        {
            GoogleTimeZone googleTimeZone = new GoogleTimeZone("AIzaSyCVGJtR2LgD5arGM_61hToUE2iNlb_VBfc");

            DateTime dt = DateTime.Now;

            string address = "Quebec, Canada";

            GoogleTimeZoneResult result = googleTimeZone.GetTimeZoneByAddress(dt, address);

            Assert.IsTrue(result != null);

            Console.WriteLine("DateTime on the server : " + dt);
            Console.WriteLine("Server time in particular to : " + address);
            Console.WriteLine("TimeZone Id : " + result.TimeZoneId);
            Console.WriteLine("TimeZone Name : " + result.TimeZoneName);
            Console.WriteLine("Converted DateTime : " + result.DateTime);
        }
Example #3
0
        static void Main(string[] args)
        {
            GoogleTimeZone googleTimeZone = new GoogleTimeZone("AIzaSyCNijWGcrNwwlGAl2zUUsoo_Qb2C1Sx0vk");


            DateTime    dt       = DateTime.Now;
            string      address  = "Quebec, Canada";
            GeoLocation location = new GeoLocation()
            {
                Latitude  = 6.9216318,
                Longitude = 79.8212827
            };
            GeoLocation location2 = new GeoLocation()
            {
                Latitude  = -19.613200,
                Longitude = 133.641453
            };


            GoogleTimeZoneResult result = googleTimeZone.GetTimeZoneByAddress(dt, address);

            //Console.WriteLine("DateTime on the server : " + dt);
            //Console.WriteLine("Server time in particular to : " + address);
            //Console.WriteLine("TimeZone Id : " + result.TimeZoneId);
            //Console.WriteLine("TimeZone Name : " + result.TimeZoneName);
            //Console.WriteLine("Converted DateTime : " + result.DateTime);

            //result = googleTimeZone.GetTimeZoneByLocation(dt, location);
            //Console.WriteLine("DateTime on the server : " + dt);
            //Console.WriteLine("Server time in particular to : " + location.Latitude + "," + location.Longitude);
            //Console.WriteLine("TimeZone Id : " + result.TimeZoneId);
            //Console.WriteLine("TimeZone Name : " + result.TimeZoneName);
            //Console.WriteLine("Converted DateTime : " + result.DateTime);

            result = googleTimeZone.GetTimeZoneByLocation(dt, location2);
            Console.WriteLine("DateTime on the server : " + dt);
            Console.WriteLine("Server time in particular to : " + location2.Latitude + "," + location2.Longitude);
            Console.WriteLine("TimeZone Id : " + result.TimeZoneId);
            Console.WriteLine("TimeZone Name : " + result.TimeZoneName);
            Console.WriteLine("Converted DateTime : " + result.DateTime);

            Console.ReadKey();
        }
Example #4
0
        public void TestGetTimeZoneByLocation()
        {
            GoogleTimeZone googleTimeZone = new GoogleTimeZone("AIzaSyCVGJtR2LgD5arGM_61hToUE2iNlb_VBfc");

            DateTime dt = DateTime.Now;

            GeoLocation location = new GeoLocation();

            location.Latitude  = 6.9216318;
            location.Longitude = 79.8212827;

            GoogleTimeZoneResult result = googleTimeZone.GetTimeZoneByLocation(dt, location);

            Assert.IsTrue(result != null);
            Console.WriteLine("DateTime on the server : " + dt);
            Console.WriteLine("Server time in particular to : " + location.Latitude + "," + location.Longitude);
            Console.WriteLine("TimeZone Id : " + result.TimeZoneId);
            Console.WriteLine("TimeZone Name : " + result.TimeZoneName);
            Console.WriteLine("Converted DateTime : " + result.DateTime);
        }