Ejemplo n.º 1
0
        public void TestGetLocalTime()
        {
#if DEBUG
            PhpArray result1, result2;
            PhpTimeZone.CurrentTimeZone = PhpTimeZone.GetTimeZone("UTC");
            DateTime dt = new DateTime(2005, 11, 4, 5, 4, 3, 132);

            result1 = PhpDateTime.GetLocalTime(dt, false);
            result2 = PhpDateTime.GetLocalTime(dt, true);
            Assert.AreEqual((int)result1[0], 3);
            Assert.AreEqual((int)result1[1], 4);
            Assert.AreEqual((int)result1[2], 5);
            Assert.AreEqual((int)result1[3], 4);
            Assert.AreEqual((int)result1[4], 10);
            Assert.AreEqual((int)result1[5], 105);
            Assert.AreEqual((int)result1[6], 5);
            Assert.AreEqual((int)result1[7], 307);
            Assert.AreEqual((int)result1[8], 0);

            Assert.AreEqual((int)result1[0], (int)result2["tm_sec"]);
            Assert.AreEqual((int)result1[1], (int)result2["tm_min"]);
            Assert.AreEqual((int)result1[2], (int)result2["tm_hour"]);
            Assert.AreEqual((int)result1[3], (int)result2["tm_mday"]);
            Assert.AreEqual((int)result1[4], (int)result2["tm_mon"]);
            Assert.AreEqual((int)result1[5], (int)result2["tm_year"]);
            Assert.AreEqual((int)result1[6], (int)result2["tm_wday"]);
            Assert.AreEqual((int)result1[7], (int)result2["tm_yday"]);
            Assert.AreEqual((int)result1[8], (int)result2["tm_isdst"]);
#endif
        }
Ejemplo n.º 2
0
        public void TestGetTimeZone()
        {
            TimeZoneInfo zone;

            zone = PhpTimeZone.GetTimeZone("Europe/Prague");
            Assert.IsTrue(zone != null && zone.Id == "Europe/Prague");

            zone = PhpTimeZone.GetTimeZone("europe/prague");
            Assert.IsTrue(zone != null && zone.Id == "Europe/Prague");

            zone = PhpTimeZone.GetTimeZone("foo");
            Assert.IsNull(zone);
        }
Ejemplo n.º 3
0
    // public __construct ( string $timezone )
    public void __construct(string timezone_name)
    {
        if (timezone_name != null)
        {
            this.timezone = PhpTimeZone.GetTimeZone(timezone_name);

            if (this.timezone == null)
            {
                //PhpException.Throw(PhpError.Notice, LibResources.GetString("unknown_timezone", zoneName));
                throw new ArgumentException();
            }
        }
        else
        {
            this.timezone = PhpTimeZone.GetCurrentTimeZone(_ctx);
        }
    }