Beispiel #1
0
 private static JSC.JSValue ConvertDate(JSC.JSValue thisBind, JSC.Arguments args) {
   if(args.Length == 2 && args[1].ValueType == JSC.JSValueType.String) {
     // 2015-09-16T14:15:18.994Z
     var s = args[1].ToString();
     if(s != null && s.Length == 24 && s[4] == '-' && s[7] == '-' && s[10] == 'T' && s[13] == ':' && s[16] == ':' && s[19] == '.') {
       var a = new JSC.Arguments();
       a.Add(args[1]);
       var jdt = new JSL.Date(a);
       return JSC.JSValue.Wrap(jdt);
     }
   }
   return args[1];
 }
Beispiel #2
0
        public void DateStringify()
        {
            var dt   = new DateTime(2018, 05, 15, 10, 05, 02); // {15.05.2018 10:05:02}
            var dt_j = JSC.JSObject.Marshal(dt);               //  {Tue May 15 2018 10:05:02 GMT+0200 (W. Europe Daylight Time)}
            var json = JSL.JSON.stringify(dt_j);               // "2018-05-15T08:05:02.000Z"
            var j_s  = JSL.JSON.parse(json);
            var j_dt = new JSL.Date(new JSC.Arguments()
            {
                j_s
            });                           // {Tue May 15 2018 08:05:02 GMT+0200 (W. Europe Daylight Time)}
            var dt_o = j_dt.ToDateTime(); // {15.05.2018 08:05:02}

            Assert.AreEqual(dt, dt_o);    // failed. Expected:<15.05.2018 10:05:02>. Actual:<15.05.2018 08:05:02>.
        }