Bug 1483545 - Intl.RelativeTimeFormat: Treat -0 as indicating a past time. r=zbraniecki
authorJason Orendorff <jorendorff@mozilla.com>
Thu, 22 Nov 2018 17:34:12 +0000
changeset 504210 d3b4650e49e13b1a15f642c54368b1576d974094
parent 504209 7bc182b1c57fe2ecd470c7e3a32d3d2ee20ed8db
child 504211 c042ee04a7abf3a57b5a557b19829b43df3163c9
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerszbraniecki
bugs1483545
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1483545 - Intl.RelativeTimeFormat: Treat -0 as indicating a past time. r=zbraniecki Differential Revision: https://phabricator.services.mozilla.com/D11127
js/src/builtin/intl/RelativeTimeFormat.cpp
js/src/tests/jstests.list
js/src/tests/non262/Intl/RelativeTimeFormat/format.js
--- a/js/src/builtin/intl/RelativeTimeFormat.cpp
+++ b/js/src/builtin/intl/RelativeTimeFormat.cpp
@@ -296,22 +296,16 @@ js::intl_FormatRelativeTime(JSContext* c
     CallArgs args = CallArgsFromVp(argc, vp);
     MOZ_ASSERT(args.length() == 4);
 
     Rooted<RelativeTimeFormatObject*> relativeTimeFormat(cx);
     relativeTimeFormat = &args[0].toObject().as<RelativeTimeFormatObject>();
 
     double t = args[1].toNumber();
 
-    // ICU doesn't handle -0 well: work around this by converting it to +0.
-    // See: http://bugs.icu-project.org/trac/ticket/12936
-    if (IsNegativeZero(t)) {
-        t = +0.0;
-    }
-
     // Obtain a cached URelativeDateTimeFormatter object.
     constexpr auto RT_FORMAT_SLOT = RelativeTimeFormatObject::URELATIVE_TIME_FORMAT_SLOT;
     void* priv = relativeTimeFormat->getReservedSlot(RT_FORMAT_SLOT).toPrivate();
     URelativeDateTimeFormatter* rtf = static_cast<URelativeDateTimeFormatter*>(priv);
     if (!rtf) {
         rtf = NewURelativeDateTimeFormatter(cx, relativeTimeFormat);
         if (!rtf) {
             return false;
--- a/js/src/tests/jstests.list
+++ b/js/src/tests/jstests.list
@@ -472,24 +472,16 @@ skip script test262/built-ins/Function/p
 skip script test262/annexB/language/function-code/block-decl-nested-blocks-with-fun-decl.js
 
 # https://bugzilla.mozilla.org/show_bug.cgi?id=1406171
 skip script test262/built-ins/Reflect/ownKeys/return-on-corresponding-order-large-index.js
 
 # https://bugzilla.mozilla.org/show_bug.cgi?id=1473229
 skip include test262/intl402/RelativeTimeFormat/prototype/formatToParts/jstests.list
 
-# https://bugzilla.mozilla.org/show_bug.cgi?id=1483545
-skip script test262/intl402/RelativeTimeFormat/prototype/format/en-us-numeric-always.js
-skip script test262/intl402/RelativeTimeFormat/prototype/format/en-us-numeric-auto.js
-skip script test262/intl402/RelativeTimeFormat/prototype/format/en-us-style-short.js
-skip script test262/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-long.js
-skip script test262/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-narrow.js
-skip script test262/intl402/RelativeTimeFormat/prototype/format/pl-pl-style-short.js
-
 # https://bugzilla.mozilla.org/show_bug.cgi?id=1508684
 skip script test262/built-ins/RegExp/prototype/multiline/cross-realm.js
 skip script test262/built-ins/RegExp/prototype/global/cross-realm.js
 skip script test262/built-ins/RegExp/prototype/sticky/cross-realm.js
 skip script test262/built-ins/RegExp/prototype/ignoreCase/cross-realm.js
 skip script test262/built-ins/RegExp/prototype/unicode/cross-realm.js
 skip script test262/built-ins/RegExp/prototype/source/cross-realm.js
 
--- a/js/src/tests/non262/Intl/RelativeTimeFormat/format.js
+++ b/js/src/tests/non262/Intl/RelativeTimeFormat/format.js
@@ -8,68 +8,68 @@
 var rtf;
 
 addIntlExtras(Intl);
 
 {
   // Numeric format
   rtf = new Intl.RelativeTimeFormat("en-US");
   assertEq(rtf.format(0, "second"), "in 0 seconds");
-  assertEq(rtf.format(-0, "second"), "in 0 seconds");
+  assertEq(rtf.format(-0, "second"), "0 seconds ago");
   assertEq(rtf.format(-1, "second"), "1 second ago");
   assertEq(rtf.format(1, "second"), "in 1 second");
 
   assertEq(rtf.format(0, "minute"), "in 0 minutes");
-  assertEq(rtf.format(-0, "minute"), "in 0 minutes");
+  assertEq(rtf.format(-0, "minute"), "0 minutes ago");
   assertEq(rtf.format(-1, "minute"), "1 minute ago");
   assertEq(rtf.format(1, "minute"), "in 1 minute");
 
   assertEq(rtf.format(0, "hour"), "in 0 hours");
-  assertEq(rtf.format(-0, "hour"), "in 0 hours");
+  assertEq(rtf.format(-0, "hour"), "0 hours ago");
   assertEq(rtf.format(-1, "hour"), "1 hour ago");
   assertEq(rtf.format(1, "hour"), "in 1 hour");
 
   assertEq(rtf.format(0, "day"), "in 0 days");
-  assertEq(rtf.format(-0, "day"), "in 0 days");
+  assertEq(rtf.format(-0, "day"), "0 days ago");
   assertEq(rtf.format(-1, "day"), "1 day ago");
   assertEq(rtf.format(1, "day"), "in 1 day");
 
   assertEq(rtf.format(0, "week"), "in 0 weeks");
-  assertEq(rtf.format(-0, "week"), "in 0 weeks");
+  assertEq(rtf.format(-0, "week"), "0 weeks ago");
   assertEq(rtf.format(-1, "week"), "1 week ago");
   assertEq(rtf.format(1, "week"), "in 1 week");
 
   assertEq(rtf.format(0, "month"), "in 0 months");
-  assertEq(rtf.format(-0, "month"), "in 0 months");
+  assertEq(rtf.format(-0, "month"), "0 months ago");
   assertEq(rtf.format(-1, "month"), "1 month ago");
   assertEq(rtf.format(1, "month"), "in 1 month");
 
   assertEq(rtf.format(0, "year"), "in 0 years");
-  assertEq(rtf.format(-0, "year"), "in 0 years");
+  assertEq(rtf.format(-0, "year"), "0 years ago");
   assertEq(rtf.format(-1, "year"), "1 year ago");
   assertEq(rtf.format(1, "year"), "in 1 year");
 }
 
 {
   // Text format
   rtf = new Intl.RelativeTimeFormat("en-US", {
     numeric: "auto"
   });
   assertEq(rtf.format(0, "second"), "now");
   assertEq(rtf.format(-0, "second"), "now");
   assertEq(rtf.format(-1, "second"), "1 second ago");
   assertEq(rtf.format(1, "second"), "in 1 second");
 
   assertEq(rtf.format(0, "minute"), "in 0 minutes");
-  assertEq(rtf.format(-0, "minute"), "in 0 minutes");
+  assertEq(rtf.format(-0, "minute"), "0 minutes ago");
   assertEq(rtf.format(-1, "minute"), "1 minute ago");
   assertEq(rtf.format(1, "minute"), "in 1 minute");
 
   assertEq(rtf.format(0, "hour"), "in 0 hours");
-  assertEq(rtf.format(-0, "hour"), "in 0 hours");
+  assertEq(rtf.format(-0, "hour"), "0 hours ago");
   assertEq(rtf.format(-1, "hour"), "1 hour ago");
   assertEq(rtf.format(1, "hour"), "in 1 hour");
 
   assertEq(rtf.format(0, "day"), "today");
   assertEq(rtf.format(-0, "day"), "today");
   assertEq(rtf.format(-1, "day"), "yesterday");
   assertEq(rtf.format(1, "day"), "tomorrow");