changeset a4689a7b33a2 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset&node=a4689a7b33a2
description:
        Run tests in UTC and use millisecond precision for moment comparison

        Backout of changeset d5742068fd8d

        issue10846
        review389071002
diffstat:

 Gruntfile.js |   3 +++
 src/pyson.js |   6 +++---
 src/sao.js   |   5 +----
 tests/sao.js |  38 +++++++++++++++++++-------------------
 4 files changed, 26 insertions(+), 26 deletions(-)

diffs (175 lines):

diff -r 26335e50cc8b -r a4689a7b33a2 Gruntfile.js
--- a/Gruntfile.js      Mon Oct 18 12:26:34 2021 +0200
+++ b/Gruntfile.js      Tue Oct 19 00:20:37 2021 +0200
@@ -140,6 +140,9 @@
                 args: [
                     '--no-sandbox',
                 ],
+                env: {
+                    TZ: 'UTC',
+                },
             },
         },
         all: ['tests/*.html']
diff -r 26335e50cc8b -r a4689a7b33a2 src/pyson.js
--- a/src/pyson.js      Mon Oct 18 12:26:34 2021 +0200
+++ b/src/pyson.js      Tue Oct 19 00:20:37 2021 +0200
@@ -453,7 +453,7 @@
         var values = [value.s1, value.s2];
         for (var i=0; i < 2; i++) {
             if (values[i] instanceof moment) {
-                values[i] = values[i].unix();
+                values[i] = values[i].valueOf();
             }
             else {
                 values[i] = Number(values[i]);
@@ -760,10 +760,10 @@
     Sao.PYSON.Date.eval_ = function(value, context) {
         var date = value.start;
         if (date && date.isDateTime) {
-            date = Sao.Date(date.year(), date.month(), date.date(), true);
+            date = Sao.Date(date.year(), date.month(), date.date());
         }
         if (!date || !date.isDate) {
-            date = Sao.Date(undefined, undefined, undefined, true);
+            date = Sao.Date();
         }
         if (value.y) date.year(value.y);
         if (value.M) date.month(value.M - 1);
diff -r 26335e50cc8b -r a4689a7b33a2 src/sao.js
--- a/src/sao.js        Mon Oct 18 12:26:34 2021 +0200
+++ b/src/sao.js        Tue Oct 19 00:20:37 2021 +0200
@@ -198,7 +198,7 @@
         }
     };
 
-    Sao.Date = function(year, month, day, utc) {
+    Sao.Date = function(year, month, day) {
         var date;
         if (month === undefined) {
             date = moment(year);
@@ -207,9 +207,6 @@
         else {
             date = moment();
         }
-        if (utc) {
-            date.utc();
-        }
         date.year(year);
         date.month(month);
         date.date(day);
diff -r 26335e50cc8b -r a4689a7b33a2 tests/sao.js
--- a/tests/sao.js      Mon Oct 18 12:26:34 2021 +0200
+++ b/tests/sao.js      Tue Oct 19 00:20:37 2021 +0200
@@ -468,18 +468,18 @@
             'Date(2020, 0, 2)))');
 
         eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Greater(
-            new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0),
-            Sao.Date(2020, 0, 1, true)));
-        QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), false,
-            'decode(Greater(PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0), ' +
-            'Date(2020, 0, 1, true)))');
+            new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 1000),
+            Sao.Date(2020, 0, 1)));
+        QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), true,
+            'decode(Greater(PYSON.DateTime(2020, 1, 1, 0, 0, 0, 1000), ' +
+            'Date(2020, 0, 1)))');
 
         eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Greater(
             new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0),
-            Sao.Date(2020, 0, 1, true), true));
+            Sao.Date(2020, 0, 1), true));
         QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), true,
             'decode(Greater(PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0), ' +
-            'Date(2020, 0, 1, true), true))');
+            'Date(2020, 0, 1), true))');
 
         eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Greater(
             new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0),
@@ -490,7 +490,7 @@
 
         eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Greater(
             new Sao.PYSON.Date(2020, 1, 1),
-            Sao.Date(2020, 0, 1, true)));
+            Sao.Date(2020, 0, 1)));
         QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), false,
             'decode(Greater(PYSON.Date(2020, 1, 1), Date(2020, 0, 1)))');
 
@@ -587,10 +587,10 @@
                 "Less(0, 1, false)");
 
         eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Less(
-            new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0),
+            new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 1000),
             Sao.Date(2020, 0, 1)));
         QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), false,
-            'decode(Less(PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0), ' +
+            'decode(Less(PYSON.DateTime(2020, 1, 1, 0, 0, 0, 1000), ' +
             'Date(2020, 0, 1)))');
 
         eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Less(
@@ -615,10 +615,10 @@
 
         eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Less(
             new Sao.PYSON.Date(2020, 1, 1),
-            new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 1, 0)));
+            new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 1000)));
         QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_), true,
             'decode(Less(PYSON.Date(2020, 1, 1), ' +
-            'PYSON.DateTime(2020, 1, 1, 0, 0, 1, 0)))');
+            'PYSON.DateTime(2020, 1, 1, 0, 0, 1000)))');
 
         eval_ = new Sao.PYSON.Encoder().encode(new Sao.PYSON.Less(
             new Sao.PYSON.DateTime(2020, 1, 1, 0, 0, 0, 0),
@@ -827,27 +827,27 @@
         eval_ = new Sao.PYSON.Encoder().encode(
                 new Sao.PYSON.Date(2010, 1, 12));
         QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_).valueOf(),
-                Sao.Date(2010, 0, 12, true).valueOf());
+                new Date(2010, 0, 12).valueOf());
 
         eval_ = new Sao.PYSON.Encoder().encode(
                 new Sao.PYSON.Date(2010, 1, 12, -1));
         QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_).valueOf(),
-                Sao.Date(2009, 0, 12, true).valueOf());
+                new Date(2009, 0, 12).valueOf());
 
         eval_ = new Sao.PYSON.Encoder().encode(
                 new Sao.PYSON.Date(2010, 1, 12, 0, 12));
         QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_).valueOf(),
-                Sao.Date(2011, 0, 12, true).valueOf());
+                new Date(2011, 0, 12).valueOf());
 
         eval_ = new Sao.PYSON.Encoder().encode(
                 new Sao.PYSON.Date(2010, 1, 12, 0, 0, -7));
         QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_).valueOf(),
-                Sao.Date(2010, 0, 5, true).valueOf());
+                new Date(2010, 0, 5).valueOf());
 
         eval_ = new Sao.PYSON.Encoder().encode(
                 new Sao.PYSON.Date(2010, 2, 22));
         QUnit.strictEqual(new Sao.PYSON.Decoder().decode(eval_).valueOf(),
-                Sao.Date(2010, 1, 22, true).valueOf());
+                new Date(2010, 1, 22).valueOf());
 
         QUnit.strictEqual(
             new Sao.PYSON.Date(2010, 1, 12, -1, 12, -7).toString(),
@@ -876,7 +876,7 @@
 
         QUnit.strictEqual(new Sao.PYSON.Decoder(
             {'datetime': datetime}).decode(eval_).valueOf(),
-            Sao.Date(2000, 1, 1, true).valueOf());
+            Sao.Date(2000, 1, 1).valueOf());
 
         eval_ = new Sao.PYSON.Encoder().encode(
             new Sao.PYSON.Date(
@@ -886,7 +886,7 @@
 
         QUnit.strictEqual(new Sao.PYSON.Decoder(
             {'foo': 'bar'}).decode(eval_).valueOf(),
-            Sao.Date(undefined, undefined, undefined, true).valueOf());
+            Sao.Date().valueOf());
     });
 
     QUnit.test('PYSON DateTime', function() {

Reply via email to