Bug 1050755: Allow to call Date.UTC with fewer than two arguments per ES2017. r=shu
authorAndré Bargull <andre.bargull@gmail.com>
Mon, 27 Feb 2017 13:22:45 -0800
changeset 374266 4db4dc2a462030b580be573af2e57658637f8a1a
parent 374265 1d547b862e0d366d4cde08596daee767ac26d4ee
child 374267 52078590e97f04df089da2b1799a630ecc5525bf
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshu
bugs1050755
milestone54.0a1
Bug 1050755: Allow to call Date.UTC with fewer than two arguments per ES2017. r=shu
js/src/jsdate.cpp
js/src/tests/jstests.list
--- a/js/src/jsdate.cpp
+++ b/js/src/jsdate.cpp
@@ -581,86 +581,92 @@ RegionMatches(const char* s1, int s1off,
         s1off++;
         s2off++;
         count--;
     }
 
     return count == 0;
 }
 
-/* ES6 20.3.3.4. */
+// ES2017 draft rev (TODO: Add git hash when PR 642 is merged.)
+// 20.3.3.4
+// Date.UTC(year [, month [, date [, hours [, minutes [, seconds [, ms]]]]]])
 static bool
 date_UTC(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
-    // Steps 1-2.
+    // Step 1.
     double y;
     if (!ToNumber(cx, args.get(0), &y))
         return false;
 
-    // Steps 3-4.
+    // Step 2.
     double m;
-    if (!ToNumber(cx, args.get(1), &m))
-        return false;
-
-    // Steps 5-6.
+    if (args.length() >= 2) {
+        if (!ToNumber(cx, args[1], &m))
+            return false;
+    } else {
+        m = 0;
+    }
+
+    // Step 3.
     double dt;
     if (args.length() >= 3) {
         if (!ToNumber(cx, args[2], &dt))
             return false;
     } else {
         dt = 1;
     }
 
-    // Steps 7-8.
+    // Step 4.
     double h;
     if (args.length() >= 4) {
         if (!ToNumber(cx, args[3], &h))
             return false;
     } else {
         h = 0;
     }
 
-    // Steps 9-10.
+    // Step 5.
     double min;
     if (args.length() >= 5) {
         if (!ToNumber(cx, args[4], &min))
             return false;
     } else {
         min = 0;
     }
 
-    // Steps 11-12.
+    // Step 6.
     double s;
     if (args.length() >= 6) {
         if (!ToNumber(cx, args[5], &s))
             return false;
     } else {
         s = 0;
     }
 
-    // Steps 13-14.
+    // Step 7.
     double milli;
     if (args.length() >= 7) {
         if (!ToNumber(cx, args[6], &milli))
             return false;
     } else {
         milli = 0;
     }
 
-    // Step 15.
+    // Step 8.
     double yr = y;
     if (!IsNaN(y)) {
         double yint = ToInteger(y);
         if (0 <= yint && yint <= 99)
             yr = 1900 + yint;
     }
 
-    // Step 16.
+    // Step 9.
     ClippedTime time = TimeClip(MakeDate(MakeDay(yr, m, dt), MakeTime(h, min, s, milli)));
     args.rval().set(TimeValue(time));
     return true;
 }
 
 /*
  * Read and convert decimal digits from s[*i] into *result
  * while *i < limit.
--- a/js/src/tests/jstests.list
+++ b/js/src/tests/jstests.list
@@ -533,19 +533,16 @@ skip script test262/annexB/language/eval
 skip script test262/language/expressions/async-generators/expression-yield-as-statement.js
 skip script test262/language/expressions/async-generators/expression-await-thenable-as-yield-operand.js
 skip script test262/language/expressions/async-generators/expression-yield-as-operand.js
 skip script test262/language/expressions/async-generators/expression-await-as-yield-operand.js
 skip script test262/language/expressions/async-generators/expression-yield-newline.js
 skip script test262/language/expressions/async-generators/expression-await-promise-as-yield-operand.js
 skip script test262/language/expressions/async-generators/expression-yield-star-before-newline.js
 
-# https://bugzilla.mozilla.org/show_bug.cgi?id=1050755
-skip script test262/built-ins/Date/UTC/return-value.js
-
 # SIMD.
 skip script test262/built-ins/Simd/check.js
 skip script test262/built-ins/Simd/from.js
 skip script test262/built-ins/Simd/operators.js
 skip script test262/built-ins/Simd/replace_lane.js
 skip script test262/built-ins/Simd/shuffle.js
 skip script test262/built-ins/Simd/swizzle.js