[njs] "new Date()" incorrectly returned always Jan 1, 1970.

Igor Sysoev igor at sysoev.ru
Fri Apr 15 14:21:24 UTC 2016


details:   http://hg.nginx.org/njs/rev/1c50334fbea6
branches:  
changeset: 99:1c50334fbea6
user:      Igor Sysoev <igor at sysoev.ru>
date:      Thu Apr 14 18:23:09 2016 +0300
description:
"new Date()" incorrectly returned always Jan 1, 1970.

diffstat:

 njs/njs_date.c           |  2 +-
 njs/test/njs_unit_test.c |  2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diffs (24 lines):

diff -r 51009da8e3d0 -r 1c50334fbea6 njs/njs_date.c
--- a/njs/njs_date.c	Mon Apr 11 14:39:59 2016 +0300
+++ b/njs/njs_date.c	Thu Apr 14 18:23:09 2016 +0300
@@ -88,7 +88,7 @@ njs_date_constructor(njs_vm_t *vm, njs_v
 
     if (vm->frame->ctor) {
 
-        if (nargs == 0) {
+        if (nargs == 1) {
             time = njs_gettime();
 
         } else if (nargs == 2 && njs_is_string(&args[1])) {
diff -r 51009da8e3d0 -r 1c50334fbea6 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Mon Apr 11 14:39:59 2016 +0300
+++ b/njs/test/njs_unit_test.c	Thu Apr 14 18:23:09 2016 +0300
@@ -4025,7 +4025,7 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("Date.parse('-000001-01-01T00:00:00.000Z')"),
       nxt_string("-62198755200000") },
 
-    { nxt_string("var d = new Date(); d == Date.parse(d.toString())"),
+    { nxt_string("var d = new Date(); d == Date.parse(d.toISOString())"),
       nxt_string("true") },
 
     { nxt_string("var s = Date(); s === Date(Date.parse(s))"),



More information about the nginx-devel mailing list