Ejemplo n.º 1
0
        public void Can_Do_Date_GetMethods()
        {
            var lsmethods = new LJSDateMethods();

            lsmethods.Init();

            var date = DateTime.Now;
            var dutc = date.ToUniversalTime();

            Assert.AreEqual(date.Day, lsmethods.GetDate(new LDate(date)));
            Assert.AreEqual((int)date.DayOfWeek, lsmethods.GetDay(new LDate(date)));
            Assert.AreEqual(date.Year, lsmethods.GetFullYear(new LDate(date)));
            Assert.AreEqual(date.Hour, lsmethods.GetHours(new LDate(date)));
            Assert.AreEqual(date.Millisecond, lsmethods.GetMilliseconds(new LDate(date)));
            Assert.AreEqual(date.Minute, lsmethods.GetMinutes(new LDate(date)));
            Assert.AreEqual(date.Month, lsmethods.GetMonth(new LDate(date)));
            Assert.AreEqual(date.Second, lsmethods.GetSeconds(new LDate(date)));

            Assert.AreEqual(dutc.Day, lsmethods.GetUtcDate(new LDate(dutc)));
            Assert.AreEqual((int)dutc.DayOfWeek, lsmethods.GetUtcDay(new LDate(dutc)));
            Assert.AreEqual(dutc.Year, lsmethods.GetUtcFullYear(new LDate(dutc)));
            Assert.AreEqual(dutc.Hour, lsmethods.GetUtcHours(new LDate(dutc)));
            Assert.AreEqual(dutc.Millisecond, lsmethods.GetUtcMilliseconds(new LDate(dutc)));
            Assert.AreEqual(dutc.Minute, lsmethods.GetUtcMinutes(new LDate(dutc)));
            Assert.AreEqual(dutc.Month, lsmethods.GetUtcMonth(new LDate(dutc)));
            Assert.AreEqual(dutc.Second, lsmethods.GetUtcSeconds(new LDate(date)));
        }
Ejemplo n.º 2
0
        public void Can_Do_Date_SetMethods()
        {
            var lsmethods = new LJSDateMethods();

            lsmethods.Init();

            var testdate = new DateTime(2012, 9, 15, 10, 30, 00);
            var l        = new LDate(testdate);


            l.Value = testdate;
            Check(2013, (ld) => ld.Value.Year, l, (ldate) => lsmethods.SetFullYear(ldate, 2013, 4, 1));
            l.Value = testdate;
            Check(4, (ld) => ld.Value.Month, l, (ldate) => lsmethods.SetFullYear(ldate, 2013, 4, 1));
            l.Value = testdate;
            Check(1, (ld) => ld.Value.Day, l, (ldate) => lsmethods.SetFullYear(ldate, 2013, 4, 1));
            l.Value = testdate;
            Check(4, (ld) => ld.Value.Month, l, (ldate) => lsmethods.SetMonth(ldate, 4, 1));
            l.Value = testdate;
            Check(1, (ld) => ld.Value.Day, l, (ldate) => lsmethods.SetDate(ldate, 1));
            l.Value = testdate;
            Check(4, (ld) => ld.Value.Hour, l, (ldate) => lsmethods.SetHours(ldate, 4, 30, 1, 150));
            l.Value = testdate;
            Check(30, (ld) => ld.Value.Minute, l, (ldate) => lsmethods.SetMinutes(ldate, 30, 1, 150));
            l.Value = testdate;
            Check(1, (ld) => ld.Value.Second, l, (ldate) => lsmethods.SetSeconds(ldate, 1, 150));
            l.Value = testdate;
            Check(150, (ld) => ld.Value.Millisecond, l, (ldate) => lsmethods.SetMilliseconds(ldate, 150));
        }
Ejemplo n.º 3
0
        public void Can_Do_Date_SetMethods_Via_Execute()
        {
            var lsmethods = new LJSDateMethods();

            lsmethods.Init();

            var testdate = new DateTime(2012, 9, 15, 10, 30, 00);
            var l        = new LDate(testdate);


            l.Value = testdate; Check(2013, (ld) => ld.Value.Year, l, (ldate) => lsmethods.ExecuteMethod(ldate, "setFullYear", new object[] { 2013, 4, 1 }));
            l.Value = testdate; Check(4, (ld) => ld.Value.Month, l, (ldate) => lsmethods.ExecuteMethod(ldate, "setFullYear", new object[] { 2013, 4, 1 }));
            l.Value = testdate; Check(1, (ld) => ld.Value.Day, l, (ldate) => lsmethods.ExecuteMethod(ldate, "setFullYear", new object[] { 2013, 4, 1 }));
            l.Value = testdate; Check(4, (ld) => ld.Value.Month, l, (ldate) => lsmethods.ExecuteMethod(ldate, "setMonth", new object[] { 4, 1 }));
            l.Value = testdate; Check(1, (ld) => ld.Value.Day, l, (ldate) => lsmethods.ExecuteMethod(ldate, "setDate", new object[] { 1 }));
            l.Value = testdate; Check(4, (ld) => ld.Value.Hour, l, (ldate) => lsmethods.ExecuteMethod(ldate, "setHours", new object[] { 4, 30, 1, 150 }));
            l.Value = testdate; Check(30, (ld) => ld.Value.Minute, l, (ldate) => lsmethods.ExecuteMethod(ldate, "setMinutes", new object[] { 30, 1, 150 }));
            l.Value = testdate; Check(1, (ld) => ld.Value.Second, l, (ldate) => lsmethods.ExecuteMethod(ldate, "setSeconds", new object[] { 1, 150 }));
            l.Value = testdate; Check(150, (ld) => ld.Value.Millisecond, l, (ldate) => lsmethods.ExecuteMethod(ldate, "setMilliseconds", new object[] { 150 }));
        }