-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Temporal.Duration normalization tests, part 1 of 3 #3957
Conversation
1723d88
to
ede7fc0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only change I don't understand is the february leap year math - could you walk me through that? Happy to discuss offline in a call if that's easier
test/built-ins/Temporal/Duration/compare/precision-exact-mathematical-values-1.js
Outdated
Show resolved
Hide resolved
test/built-ins/Temporal/Duration/prototype/round/february-leap-year.js
Outdated
Show resolved
Hide resolved
...ins/Temporal/Duration/prototype/round/precision-exact-in-balance-duration-relative-months.js
Outdated
Show resolved
Hide resolved
...poral/Duration/prototype/round/throws-in-unbalance-duration-relative-when-sign-mismatched.js
Show resolved
Hide resolved
test/built-ins/Temporal/PlainYearMonth/prototype/since/roundingincrement-non-integer.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline: the february leap year rounding test was previously not testing what it stated. Temporal is supposed to use RFC 5545 arithmetic (add years, then months, then days) and wasn't correctly doing that in duration before; the normative changes fix that. Instead, the test will be changed to have a start date (1968-03-01) such that the date arithmetic ends in a leap month. The durations remain the same. Thanks @ptomato for walking through it with me!
Approved pending that change
A few results change because the algorithm previously used for rounding didn't always add duration units to dates in RFC 5545 order, and we also introduce a special case for rounding with largestUnit years or months and smallestUnit weeks.
Tests with conditions that would trip a division by zero in implementations if they didn't carefully implement the spec.
ede7fc0
to
33632ee
Compare
Thanks for the review. I've pushed a change addressing the comment about the February leap year test (I picked 1972-03-01 as the starting date instead of 1968-03-01, it works just as well with that) as well as incorporating results that changed from the largestUnit years/months + smallestUnit weeks workaround that came up in code review of tc39/proposal-temporal#2722. Click to reveal a convenient diff of what changeddiff --git a/test/built-ins/Temporal/Duration/prototype/round/calendar-possibly-required.js b/test/built-ins/Temporal/Duration/prototype/round/calendar-possibly-required.js
index 84c88a69be..0d2a1098a6 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/calendar-possibly-required.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/calendar-possibly-required.js
@@ -45,8 +45,8 @@ assert.throws(
"rounding a week Duration fails without largest/smallest unit"
);
-TemporalHelpers.assertDuration(duration3.round(relativeToYears), 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, "round week duration to years");
-TemporalHelpers.assertDuration(duration3.round(relativeToMonths), 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, "round week duration to months");
+TemporalHelpers.assertDuration(duration3.round(relativeToYears), 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, "round week duration to years");
+TemporalHelpers.assertDuration(duration3.round(relativeToMonths), 0, 1, 0, 4, 0, 0, 0, 0, 0, 0, "round week duration to months");
TemporalHelpers.assertDuration(duration3.round(relativeToWeeks), 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, "round week duration to weeks");
TemporalHelpers.assertDuration(duration3.round(relativeToDays), 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, "round week duration to days");
diff --git a/test/built-ins/Temporal/Duration/prototype/round/february-leap-year.js b/test/built-ins/Temporal/Duration/prototype/round/february-leap-year.js
index 5d21105ba9..bd7cd6b463 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/february-leap-year.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/february-leap-year.js
@@ -10,29 +10,29 @@ features: [Temporal]
// Based on a test case by André Bargull <[email protected]>
-// Note: February in a leap year.
-const relativeTo = new Temporal.PlainDate(1972, 2, 1);
+// Note: One day after February in a leap year.
+const relativeTo = new Temporal.PlainDate(1972, 3, 1);
const options = {
largestUnit: "years",
relativeTo,
};
-const twoDaysLessThanFourYears = new Temporal.Duration(3, 11, 0, 29);
+const twoDaysLessThanFourYears = new Temporal.Duration(3, 11, 0, 27);
TemporalHelpers.assertDuration(
twoDaysLessThanFourYears.round(options),
- 3, 11, 0, 29, 0, 0, 0, 0, 0, 0,
+ 3, 11, 0, 27, 0, 0, 0, 0, 0, 0,
"Two days less than four years starting in February in a leap year shouldn't balance up"
);
-const oneDayLessThanFourYears = new Temporal.Duration(3, 11, 0, 30);
+const oneDayLessThanFourYears = new Temporal.Duration(3, 11, 0, 28);
TemporalHelpers.assertDuration(
oneDayLessThanFourYears.round(options),
- 3, 11, 0, 30, 0, 0, 0, 0, 0, 0,
+ 3, 11, 0, 28, 0, 0, 0, 0, 0, 0,
"One day less than four years starting in February in a leap year shouldn't balance up"
);
-const fourYears = new Temporal.Duration(3, 11, 0, 31);
+const fourYears = new Temporal.Duration(3, 11, 0, 29);
TemporalHelpers.assertDuration(
fourYears.round(options),
4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
diff --git a/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js b/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js
index 76123dc6de..b42a868e63 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js
@@ -424,10 +424,32 @@ const expectedOpsForUnbalanceRoundBalance = expectedOpsForZonedRelativeTo.concat
"call options.relativeTo.calendar.dateAdd", // 10.d
"call options.relativeTo.calendar.dateUntil", // 10.e
]);
-new Temporal.Duration(0, 1, 1).round(createOptionsObserver({ largestUnit: "months", smallestUnit: "weeks", relativeTo: zonedRelativeTo }));
+new Temporal.Duration(0, 1, 1).round(createOptionsObserver({ largestUnit: "years", smallestUnit: "weeks", relativeTo: zonedRelativeTo }));
assert.compareArray(
actual,
expectedOpsForUnbalanceRoundBalance,
+ "order of operations with largestUnit = years, smallestUnit = weeks, and ZonedDateTime relativeTo"
+);
+actual.splice(0); // clear
+
+// code path that skips user code calls in BalanceDateDurationRelative due to
+// special case for largestUnit months and smallestUnit weeks
+const expectedOpsForWeeksSpecialCase = expectedOpsForZonedRelativeTo.concat([
+ // ToTemporalDate
+ "call options.relativeTo.timeZone.getOffsetNanosecondsFor",
+ // lookup in Duration.p.round
+ "get options.relativeTo.calendar.dateAdd",
+ "get options.relativeTo.calendar.dateUntil",
+ // RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime
+ "call options.relativeTo.calendar.dateAdd",
+ "call options.relativeTo.timeZone.getPossibleInstantsFor", // 13. GetInstantFor
+ // RoundDuration
+ "call options.relativeTo.calendar.dateAdd", // 14.p MoveRelativeDate
+]);
+new Temporal.Duration(0, 1, 1).round(createOptionsObserver({ largestUnit: "months", smallestUnit: "weeks", relativeTo: zonedRelativeTo }));
+assert.compareArray(
+ actual,
+ expectedOpsForWeeksSpecialCase,
"order of operations with largestUnit = months, smallestUnit = weeks, and ZonedDateTime relativeTo"
);
actual.splice(0); // clear
diff --git a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-ceil.js b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-ceil.js
index 6da85af6b8..27306ed1df 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-ceil.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-ceil.js
@@ -9,19 +9,23 @@ features: [Temporal]
---*/
const instance = new Temporal.Duration(5, 6, 7, 8, 40, 30, 20, 123, 987, 500);
-const relativeTo = new Temporal.PlainDate(2020, 1, 1);
+// Chosen such that 8 months forwards from relativeToForwards is the
+// same number of days as 8 months backwards from relativeToBackwards
+// (for convenience)
+const relativeToForwards = new Temporal.PlainDate(2020, 4, 1);
+const relativeToBackwards = new Temporal.PlainDate(2020, 12, 1);
const expected = [
["years", [6], [-5]],
["months", [5, 8], [-5, -7]],
["weeks", [5, 6, 9], [-5, -6, -8]],
- ["days", [5, 6, 7, 10], [-5, -6, -7, -9]],
- ["hours", [5, 6, 7, 9, 17], [-5, -6, -7, -9, -16]],
- ["minutes", [5, 6, 7, 9, 16, 31], [-5, -6, -7, -9, -16, -30]],
- ["seconds", [5, 6, 7, 9, 16, 30, 21], [-5, -6, -7, -9, -16, -30, -20]],
- ["milliseconds", [5, 6, 7, 9, 16, 30, 20, 124], [-5, -6, -7, -9, -16, -30, -20, -123]],
- ["microseconds", [5, 6, 7, 9, 16, 30, 20, 123, 988], [-5, -6, -7, -9, -16, -30, -20, -123, -987]],
- ["nanoseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987, 500], [-5, -6, -7, -9, -16, -30, -20, -123, -987, -500]],
+ ["days", [5, 7, 0, 28], [-5, -7, 0, -27]],
+ ["hours", [5, 7, 0, 27, 17], [-5, -7, 0, -27, -16]],
+ ["minutes", [5, 7, 0, 27, 16, 31], [-5, -7, 0, -27, -16, -30]],
+ ["seconds", [5, 7, 0, 27, 16, 30, 21], [-5, -7, 0, -27, -16, -30, -20]],
+ ["milliseconds", [5, 7, 0, 27, 16, 30, 20, 124], [-5, -7, 0, -27, -16, -30, -20, -123]],
+ ["microseconds", [5, 7, 0, 27, 16, 30, 20, 123, 988], [-5, -7, 0, -27, -16, -30, -20, -123, -987]],
+ ["nanoseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987, 500], [-5, -7, 0, -27, -16, -30, -20, -123, -987, -500]],
];
const roundingMode = "ceil";
@@ -30,12 +34,12 @@ expected.forEach(([smallestUnit, expectedPositive, expectedNegative]) => {
const [py, pm = 0, pw = 0, pd = 0, ph = 0, pmin = 0, ps = 0, pms = 0, pµs = 0, pns = 0] = expectedPositive;
const [ny, nm = 0, nw = 0, nd = 0, nh = 0, nmin = 0, ns = 0, nms = 0, nµs = 0, nns = 0] = expectedNegative;
TemporalHelpers.assertDuration(
- instance.round({ smallestUnit, relativeTo, roundingMode }),
+ instance.round({ smallestUnit, relativeTo: relativeToForwards, roundingMode }),
py, pm, pw, pd, ph, pmin, ps, pms, pµs, pns,
`rounds to ${smallestUnit} (roundingMode = ${roundingMode}, positive case)`
);
TemporalHelpers.assertDuration(
- instance.negated().round({ smallestUnit, relativeTo, roundingMode }),
+ instance.negated().round({ smallestUnit, relativeTo: relativeToBackwards, roundingMode }),
ny, nm, nw, nd, nh, nmin, ns, nms, nµs, nns,
`rounds to ${smallestUnit} (rounding mode = ${roundingMode}, negative case)`
);
diff --git a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-expand.js b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-expand.js
index 86e9ee64aa..1119637349 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-expand.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-expand.js
@@ -9,19 +9,23 @@ features: [Temporal]
---*/
const instance = new Temporal.Duration(5, 6, 7, 8, 40, 30, 20, 123, 987, 500);
-const relativeTo = new Temporal.PlainDate(2020, 1, 1);
+// Chosen such that 8 months forwards from relativeToForwards is the
+// same number of days as 8 months backwards from relativeToBackwards
+// (for convenience)
+const relativeToForwards = new Temporal.PlainDate(2020, 4, 1);
+const relativeToBackwards = new Temporal.PlainDate(2020, 12, 1);
const expected = [
["years", [6], [-6]],
["months", [5, 8], [-5, -8]],
["weeks", [5, 6, 9], [-5, -6, -9]],
- ["days", [5, 6, 7, 10], [-5, -6, -7, -10]],
- ["hours", [5, 6, 7, 9, 17], [-5, -6, -7, -9, -17]],
- ["minutes", [5, 6, 7, 9, 16, 31], [-5, -6, -7, -9, -16, -31]],
- ["seconds", [5, 6, 7, 9, 16, 30, 21], [-5, -6, -7, -9, -16, -30, -21]],
- ["milliseconds", [5, 6, 7, 9, 16, 30, 20, 124], [-5, -6, -7, -9, -16, -30, -20, -124]],
- ["microseconds", [5, 6, 7, 9, 16, 30, 20, 123, 988], [-5, -6, -7, -9, -16, -30, -20, -123, -988]],
- ["nanoseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987, 500], [-5, -6, -7, -9, -16, -30, -20, -123, -987, -500]],
+ ["days", [5, 7, 0, 28], [-5, -7, 0, -28]],
+ ["hours", [5, 7, 0, 27, 17], [-5, -7, 0, -27, -17]],
+ ["minutes", [5, 7, 0, 27, 16, 31], [-5, -7, 0, -27, -16, -31]],
+ ["seconds", [5, 7, 0, 27, 16, 30, 21], [-5, -7, 0, -27, -16, -30, -21]],
+ ["milliseconds", [5, 7, 0, 27, 16, 30, 20, 124], [-5, -7, 0, -27, -16, -30, -20, -124]],
+ ["microseconds", [5, 7, 0, 27, 16, 30, 20, 123, 988], [-5, -7, 0, -27, -16, -30, -20, -123, -988]],
+ ["nanoseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987, 500], [-5, -7, 0, -27, -16, -30, -20, -123, -987, -500]],
];
const roundingMode = "expand";
@@ -30,12 +34,12 @@ expected.forEach(([smallestUnit, expectedPositive, expectedNegative]) => {
const [py, pm = 0, pw = 0, pd = 0, ph = 0, pmin = 0, ps = 0, pms = 0, pµs = 0, pns = 0] = expectedPositive;
const [ny, nm = 0, nw = 0, nd = 0, nh = 0, nmin = 0, ns = 0, nms = 0, nµs = 0, nns = 0] = expectedNegative;
TemporalHelpers.assertDuration(
- instance.round({ smallestUnit, relativeTo, roundingMode }),
+ instance.round({ smallestUnit, relativeTo: relativeToForwards, roundingMode }),
py, pm, pw, pd, ph, pmin, ps, pms, pµs, pns,
`rounds to ${smallestUnit} (roundingMode = ${roundingMode}, positive case)`
);
TemporalHelpers.assertDuration(
- instance.negated().round({ smallestUnit, relativeTo, roundingMode }),
+ instance.negated().round({ smallestUnit, relativeTo: relativeToBackwards, roundingMode }),
ny, nm, nw, nd, nh, nmin, ns, nms, nµs, nns,
`rounds to ${smallestUnit} (rounding mode = ${roundingMode}, negative case)`
);
diff --git a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-floor.js b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-floor.js
index 3ab95f9794..7e875cc95c 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-floor.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-floor.js
@@ -9,19 +9,23 @@ features: [Temporal]
---*/
const instance = new Temporal.Duration(5, 6, 7, 8, 40, 30, 20, 123, 987, 500);
-const relativeTo = new Temporal.PlainDate(2020, 1, 1);
+// Chosen such that 8 months forwards from relativeToForwards is the
+// same number of days as 8 months backwards from relativeToBackwards
+// (for convenience)
+const relativeToForwards = new Temporal.PlainDate(2020, 4, 1);
+const relativeToBackwards = new Temporal.PlainDate(2020, 12, 1);
const expected = [
["years", [5], [-6]],
["months", [5, 7], [-5, -8]],
["weeks", [5, 6, 8], [-5, -6, -9]],
- ["days", [5, 6, 7, 9], [-5, -6, -7, -10]],
- ["hours", [5, 6, 7, 9, 16], [-5, -6, -7, -9, -17]],
- ["minutes", [5, 6, 7, 9, 16, 30], [-5, -6, -7, -9, -16, -31]],
- ["seconds", [5, 6, 7, 9, 16, 30, 20], [-5, -6, -7, -9, -16, -30, -21]],
- ["milliseconds", [5, 6, 7, 9, 16, 30, 20, 123], [-5, -6, -7, -9, -16, -30, -20, -124]],
- ["microseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987], [-5, -6, -7, -9, -16, -30, -20, -123, -988]],
- ["nanoseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987, 500], [-5, -6, -7, -9, -16, -30, -20, -123, -987, -500]],
+ ["days", [5, 7, 0, 27], [-5, -7, 0, -28]],
+ ["hours", [5, 7, 0, 27, 16], [-5, -7, 0, -27, -17]],
+ ["minutes", [5, 7, 0, 27, 16, 30], [-5, -7, 0, -27, -16, -31]],
+ ["seconds", [5, 7, 0, 27, 16, 30, 20], [-5, -7, 0, -27, -16, -30, -21]],
+ ["milliseconds", [5, 7, 0, 27, 16, 30, 20, 123], [-5, -7, 0, -27, -16, -30, -20, -124]],
+ ["microseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987], [-5, -7, 0, -27, -16, -30, -20, -123, -988]],
+ ["nanoseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987, 500], [-5, -7, 0, -27, -16, -30, -20, -123, -987, -500]],
];
const roundingMode = "floor";
@@ -30,12 +34,12 @@ expected.forEach(([smallestUnit, expectedPositive, expectedNegative]) => {
const [py, pm = 0, pw = 0, pd = 0, ph = 0, pmin = 0, ps = 0, pms = 0, pµs = 0, pns = 0] = expectedPositive;
const [ny, nm = 0, nw = 0, nd = 0, nh = 0, nmin = 0, ns = 0, nms = 0, nµs = 0, nns = 0] = expectedNegative;
TemporalHelpers.assertDuration(
- instance.round({ smallestUnit, relativeTo, roundingMode }),
+ instance.round({ smallestUnit, relativeTo: relativeToForwards, roundingMode }),
py, pm, pw, pd, ph, pmin, ps, pms, pµs, pns,
`rounds to ${smallestUnit} (roundingMode = ${roundingMode}, positive case)`
);
TemporalHelpers.assertDuration(
- instance.negated().round({ smallestUnit, relativeTo, roundingMode }),
+ instance.negated().round({ smallestUnit, relativeTo: relativeToBackwards, roundingMode }),
ny, nm, nw, nd, nh, nmin, ns, nms, nµs, nns,
`rounds to ${smallestUnit} (rounding mode = ${roundingMode}, negative case)`
);
diff --git a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfCeil.js b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfCeil.js
index 2955e900ba..556638410c 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfCeil.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfCeil.js
@@ -9,19 +9,23 @@ features: [Temporal]
---*/
const instance = new Temporal.Duration(5, 6, 7, 8, 40, 30, 20, 123, 987, 500);
-const relativeTo = new Temporal.PlainDate(2020, 1, 1);
+// Chosen such that 8 months forwards from relativeToForwards is the
+// same number of days as 8 months backwards from relativeToBackwards
+// (for convenience)
+const relativeToForwards = new Temporal.PlainDate(2020, 4, 1);
+const relativeToBackwards = new Temporal.PlainDate(2020, 12, 1);
const expected = [
["years", [6], [-6]],
["months", [5, 8], [-5, -8]],
["weeks", [5, 6, 8], [-5, -6, -8]],
- ["days", [5, 6, 7, 10], [-5, -6, -7, -10]],
- ["hours", [5, 6, 7, 9, 17], [-5, -6, -7, -9, -17]],
- ["minutes", [5, 6, 7, 9, 16, 30], [-5, -6, -7, -9, -16, -30]],
- ["seconds", [5, 6, 7, 9, 16, 30, 20], [-5, -6, -7, -9, -16, -30, -20]],
- ["milliseconds", [5, 6, 7, 9, 16, 30, 20, 124], [-5, -6, -7, -9, -16, -30, -20, -124]],
- ["microseconds", [5, 6, 7, 9, 16, 30, 20, 123, 988], [-5, -6, -7, -9, -16, -30, -20, -123, -987]],
- ["nanoseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987, 500], [-5, -6, -7, -9, -16, -30, -20, -123, -987, -500]],
+ ["days", [5, 7, 0, 28], [-5, -7, 0, -28]],
+ ["hours", [5, 7, 0, 27, 17], [-5, -7, 0, -27, -17]],
+ ["minutes", [5, 7, 0, 27, 16, 30], [-5, -7, 0, -27, -16, -30]],
+ ["seconds", [5, 7, 0, 27, 16, 30, 20], [-5, -7, 0, -27, -16, -30, -20]],
+ ["milliseconds", [5, 7, 0, 27, 16, 30, 20, 124], [-5, -7, 0, -27, -16, -30, -20, -124]],
+ ["microseconds", [5, 7, 0, 27, 16, 30, 20, 123, 988], [-5, -7, 0, -27, -16, -30, -20, -123, -987]],
+ ["nanoseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987, 500], [-5, -7, 0, -27, -16, -30, -20, -123, -987, -500]],
];
const roundingMode = "halfCeil";
@@ -30,12 +34,12 @@ expected.forEach(([smallestUnit, expectedPositive, expectedNegative]) => {
const [py, pm = 0, pw = 0, pd = 0, ph = 0, pmin = 0, ps = 0, pms = 0, pµs = 0, pns = 0] = expectedPositive;
const [ny, nm = 0, nw = 0, nd = 0, nh = 0, nmin = 0, ns = 0, nms = 0, nµs = 0, nns = 0] = expectedNegative;
TemporalHelpers.assertDuration(
- instance.round({ smallestUnit, relativeTo, roundingMode }),
+ instance.round({ smallestUnit, relativeTo: relativeToForwards, roundingMode }),
py, pm, pw, pd, ph, pmin, ps, pms, pµs, pns,
`rounds to ${smallestUnit} (roundingMode = ${roundingMode}, positive case)`
);
TemporalHelpers.assertDuration(
- instance.negated().round({ smallestUnit, relativeTo, roundingMode }),
+ instance.negated().round({ smallestUnit, relativeTo: relativeToBackwards, roundingMode }),
ny, nm, nw, nd, nh, nmin, ns, nms, nµs, nns,
`rounds to ${smallestUnit} (rounding mode = ${roundingMode}, negative case)`
);
diff --git a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfEven.js b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfEven.js
index d7bd41745a..1facefa910 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfEven.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfEven.js
@@ -9,19 +9,23 @@ features: [Temporal]
---*/
const instance = new Temporal.Duration(5, 6, 7, 8, 40, 30, 20, 123, 987, 500);
-const relativeTo = new Temporal.PlainDate(2020, 1, 1);
+// Chosen such that 8 months forwards from relativeToForwards is the
+// same number of days as 8 months backwards from relativeToBackwards
+// (for convenience)
+const relativeToForwards = new Temporal.PlainDate(2020, 4, 1);
+const relativeToBackwards = new Temporal.PlainDate(2020, 12, 1);
const expected = [
["years", [6], [-6]],
["months", [5, 8], [-5, -8]],
["weeks", [5, 6, 8], [-5, -6, -8]],
- ["days", [5, 6, 7, 10], [-5, -6, -7, -10]],
- ["hours", [5, 6, 7, 9, 17], [-5, -6, -7, -9, -17]],
- ["minutes", [5, 6, 7, 9, 16, 30], [-5, -6, -7, -9, -16, -30]],
- ["seconds", [5, 6, 7, 9, 16, 30, 20], [-5, -6, -7, -9, -16, -30, -20]],
- ["milliseconds", [5, 6, 7, 9, 16, 30, 20, 124], [-5, -6, -7, -9, -16, -30, -20, -124]],
- ["microseconds", [5, 6, 7, 9, 16, 30, 20, 123, 988], [-5, -6, -7, -9, -16, -30, -20, -123, -988]],
- ["nanoseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987, 500], [-5, -6, -7, -9, -16, -30, -20, -123, -987, -500]],
+ ["days", [5, 7, 0, 28], [-5, -7, 0, -28]],
+ ["hours", [5, 7, 0, 27, 17], [-5, -7, 0, -27, -17]],
+ ["minutes", [5, 7, 0, 27, 16, 30], [-5, -7, 0, -27, -16, -30]],
+ ["seconds", [5, 7, 0, 27, 16, 30, 20], [-5, -7, 0, -27, -16, -30, -20]],
+ ["milliseconds", [5, 7, 0, 27, 16, 30, 20, 124], [-5, -7, 0, -27, -16, -30, -20, -124]],
+ ["microseconds", [5, 7, 0, 27, 16, 30, 20, 123, 988], [-5, -7, 0, -27, -16, -30, -20, -123, -988]],
+ ["nanoseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987, 500], [-5, -7, 0, -27, -16, -30, -20, -123, -987, -500]],
];
const roundingMode = "halfEven";
@@ -30,12 +34,12 @@ expected.forEach(([smallestUnit, expectedPositive, expectedNegative]) => {
const [py, pm = 0, pw = 0, pd = 0, ph = 0, pmin = 0, ps = 0, pms = 0, pµs = 0, pns = 0] = expectedPositive;
const [ny, nm = 0, nw = 0, nd = 0, nh = 0, nmin = 0, ns = 0, nms = 0, nµs = 0, nns = 0] = expectedNegative;
TemporalHelpers.assertDuration(
- instance.round({ smallestUnit, relativeTo, roundingMode }),
+ instance.round({ smallestUnit, relativeTo: relativeToForwards, roundingMode }),
py, pm, pw, pd, ph, pmin, ps, pms, pµs, pns,
`rounds to ${smallestUnit} (roundingMode = ${roundingMode}, positive case)`
);
TemporalHelpers.assertDuration(
- instance.negated().round({ smallestUnit, relativeTo, roundingMode }),
+ instance.negated().round({ smallestUnit, relativeTo: relativeToBackwards, roundingMode }),
ny, nm, nw, nd, nh, nmin, ns, nms, nµs, nns,
`rounds to ${smallestUnit} (rounding mode = ${roundingMode}, negative case)`
);
diff --git a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfExpand.js b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfExpand.js
index 3cb7ac5fcb..e5544b0e2b 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfExpand.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfExpand.js
@@ -9,19 +9,23 @@ features: [Temporal]
---*/
const instance = new Temporal.Duration(5, 6, 7, 8, 40, 30, 20, 123, 987, 500);
-const relativeTo = new Temporal.PlainDate(2020, 1, 1);
+// Chosen such that 8 months forwards from relativeToForwards is the
+// same number of days as 8 months backwards from relativeToBackwards
+// (for convenience)
+const relativeToForwards = new Temporal.PlainDate(2020, 4, 1);
+const relativeToBackwards = new Temporal.PlainDate(2020, 12, 1);
const expected = [
["years", [6], [-6]],
["months", [5, 8], [-5, -8]],
["weeks", [5, 6, 8], [-5, -6, -8]],
- ["days", [5, 6, 7, 10], [-5, -6, -7, -10]],
- ["hours", [5, 6, 7, 9, 17], [-5, -6, -7, -9, -17]],
- ["minutes", [5, 6, 7, 9, 16, 30], [-5, -6, -7, -9, -16, -30]],
- ["seconds", [5, 6, 7, 9, 16, 30, 20], [-5, -6, -7, -9, -16, -30, -20]],
- ["milliseconds", [5, 6, 7, 9, 16, 30, 20, 124], [-5, -6, -7, -9, -16, -30, -20, -124]],
- ["microseconds", [5, 6, 7, 9, 16, 30, 20, 123, 988], [-5, -6, -7, -9, -16, -30, -20, -123, -988]],
- ["nanoseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987, 500], [-5, -6, -7, -9, -16, -30, -20, -123, -987, -500]],
+ ["days", [5, 7, 0, 28], [-5, -7, 0, -28]],
+ ["hours", [5, 7, 0, 27, 17], [-5, -7, 0, -27, -17]],
+ ["minutes", [5, 7, 0, 27, 16, 30], [-5, -7, 0, -27, -16, -30]],
+ ["seconds", [5, 7, 0, 27, 16, 30, 20], [-5, -7, 0, -27, -16, -30, -20]],
+ ["milliseconds", [5, 7, 0, 27, 16, 30, 20, 124], [-5, -7, 0, -27, -16, -30, -20, -124]],
+ ["microseconds", [5, 7, 0, 27, 16, 30, 20, 123, 988], [-5, -7, 0, -27, -16, -30, -20, -123, -988]],
+ ["nanoseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987, 500], [-5, -7, 0, -27, -16, -30, -20, -123, -987, -500]],
];
const roundingMode = "halfExpand";
@@ -30,12 +34,12 @@ expected.forEach(([smallestUnit, expectedPositive, expectedNegative]) => {
const [py, pm = 0, pw = 0, pd = 0, ph = 0, pmin = 0, ps = 0, pms = 0, pµs = 0, pns = 0] = expectedPositive;
const [ny, nm = 0, nw = 0, nd = 0, nh = 0, nmin = 0, ns = 0, nms = 0, nµs = 0, nns = 0] = expectedNegative;
TemporalHelpers.assertDuration(
- instance.round({ smallestUnit, relativeTo, roundingMode }),
+ instance.round({ smallestUnit, relativeTo: relativeToForwards, roundingMode }),
py, pm, pw, pd, ph, pmin, ps, pms, pµs, pns,
`rounds to ${smallestUnit} (roundingMode = ${roundingMode}, positive case)`
);
TemporalHelpers.assertDuration(
- instance.negated().round({ smallestUnit, relativeTo, roundingMode }),
+ instance.negated().round({ smallestUnit, relativeTo: relativeToBackwards, roundingMode }),
ny, nm, nw, nd, nh, nmin, ns, nms, nµs, nns,
`rounds to ${smallestUnit} (rounding mode = ${roundingMode}, negative case)`
);
diff --git a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfFloor.js b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfFloor.js
index 7d284fc62a..452893743f 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfFloor.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfFloor.js
@@ -9,19 +9,23 @@ features: [Temporal]
---*/
const instance = new Temporal.Duration(5, 6, 7, 8, 40, 30, 20, 123, 987, 500);
-const relativeTo = new Temporal.PlainDate(2020, 1, 1);
+// Chosen such that 8 months forwards from relativeToForwards is the
+// same number of days as 8 months backwards from relativeToBackwards
+// (for convenience)
+const relativeToForwards = new Temporal.PlainDate(2020, 4, 1);
+const relativeToBackwards = new Temporal.PlainDate(2020, 12, 1);
const expected = [
["years", [6], [-6]],
["months", [5, 8], [-5, -8]],
["weeks", [5, 6, 8], [-5, -6, -8]],
- ["days", [5, 6, 7, 10], [-5, -6, -7, -10]],
- ["hours", [5, 6, 7, 9, 17], [-5, -6, -7, -9, -17]],
- ["minutes", [5, 6, 7, 9, 16, 30], [-5, -6, -7, -9, -16, -30]],
- ["seconds", [5, 6, 7, 9, 16, 30, 20], [-5, -6, -7, -9, -16, -30, -20]],
- ["milliseconds", [5, 6, 7, 9, 16, 30, 20, 124], [-5, -6, -7, -9, -16, -30, -20, -124]],
- ["microseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987], [-5, -6, -7, -9, -16, -30, -20, -123, -988]],
- ["nanoseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987, 500], [-5, -6, -7, -9, -16, -30, -20, -123, -987, -500]],
+ ["days", [5, 7, 0, 28], [-5, -7, 0, -28]],
+ ["hours", [5, 7, 0, 27, 17], [-5, -7, 0, -27, -17]],
+ ["minutes", [5, 7, 0, 27, 16, 30], [-5, -7, 0, -27, -16, -30]],
+ ["seconds", [5, 7, 0, 27, 16, 30, 20], [-5, -7, 0, -27, -16, -30, -20]],
+ ["milliseconds", [5, 7, 0, 27, 16, 30, 20, 124], [-5, -7, 0, -27, -16, -30, -20, -124]],
+ ["microseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987], [-5, -7, 0, -27, -16, -30, -20, -123, -988]],
+ ["nanoseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987, 500], [-5, -7, 0, -27, -16, -30, -20, -123, -987, -500]],
];
const roundingMode = "halfFloor";
@@ -30,12 +34,12 @@ expected.forEach(([smallestUnit, expectedPositive, expectedNegative]) => {
const [py, pm = 0, pw = 0, pd = 0, ph = 0, pmin = 0, ps = 0, pms = 0, pµs = 0, pns = 0] = expectedPositive;
const [ny, nm = 0, nw = 0, nd = 0, nh = 0, nmin = 0, ns = 0, nms = 0, nµs = 0, nns = 0] = expectedNegative;
TemporalHelpers.assertDuration(
- instance.round({ smallestUnit, relativeTo, roundingMode }),
+ instance.round({ smallestUnit, relativeTo: relativeToForwards, roundingMode }),
py, pm, pw, pd, ph, pmin, ps, pms, pµs, pns,
`rounds to ${smallestUnit} (roundingMode = ${roundingMode}, positive case)`
);
TemporalHelpers.assertDuration(
- instance.negated().round({ smallestUnit, relativeTo, roundingMode }),
+ instance.negated().round({ smallestUnit, relativeTo: relativeToBackwards, roundingMode }),
ny, nm, nw, nd, nh, nmin, ns, nms, nµs, nns,
`rounds to ${smallestUnit} (rounding mode = ${roundingMode}, negative case)`
);
diff --git a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfTrunc.js b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfTrunc.js
index f63582f809..2fa6a810b8 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfTrunc.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-halfTrunc.js
@@ -9,19 +9,23 @@ features: [Temporal]
---*/
const instance = new Temporal.Duration(5, 6, 7, 8, 40, 30, 20, 123, 987, 500);
-const relativeTo = new Temporal.PlainDate(2020, 1, 1);
+// Chosen such that 8 months forwards from relativeToForwards is the
+// same number of days as 8 months backwards from relativeToBackwards
+// (for convenience)
+const relativeToForwards = new Temporal.PlainDate(2020, 4, 1);
+const relativeToBackwards = new Temporal.PlainDate(2020, 12, 1);
const expected = [
["years", [6], [-6]],
["months", [5, 8], [-5, -8]],
["weeks", [5, 6, 8], [-5, -6, -8]],
- ["days", [5, 6, 7, 10], [-5, -6, -7, -10]],
- ["hours", [5, 6, 7, 9, 17], [-5, -6, -7, -9, -17]],
- ["minutes", [5, 6, 7, 9, 16, 30], [-5, -6, -7, -9, -16, -30]],
- ["seconds", [5, 6, 7, 9, 16, 30, 20], [-5, -6, -7, -9, -16, -30, -20]],
- ["milliseconds", [5, 6, 7, 9, 16, 30, 20, 124], [-5, -6, -7, -9, -16, -30, -20, -124]],
- ["microseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987], [-5, -6, -7, -9, -16, -30, -20, -123, -987]],
- ["nanoseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987, 500], [-5, -6, -7, -9, -16, -30, -20, -123, -987, -500]],
+ ["days", [5, 7, 0, 28], [-5, -7, 0, -28]],
+ ["hours", [5, 7, 0, 27, 17], [-5, -7, 0, -27, -17]],
+ ["minutes", [5, 7, 0, 27, 16, 30], [-5, -7, 0, -27, -16, -30]],
+ ["seconds", [5, 7, 0, 27, 16, 30, 20], [-5, -7, 0, -27, -16, -30, -20]],
+ ["milliseconds", [5, 7, 0, 27, 16, 30, 20, 124], [-5, -7, 0, -27, -16, -30, -20, -124]],
+ ["microseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987], [-5, -7, 0, -27, -16, -30, -20, -123, -987]],
+ ["nanoseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987, 500], [-5, -7, 0, -27, -16, -30, -20, -123, -987, -500]],
];
const roundingMode = "halfTrunc";
@@ -30,12 +34,12 @@ expected.forEach(([smallestUnit, expectedPositive, expectedNegative]) => {
const [py, pm = 0, pw = 0, pd = 0, ph = 0, pmin = 0, ps = 0, pms = 0, pµs = 0, pns = 0] = expectedPositive;
const [ny, nm = 0, nw = 0, nd = 0, nh = 0, nmin = 0, ns = 0, nms = 0, nµs = 0, nns = 0] = expectedNegative;
TemporalHelpers.assertDuration(
- instance.round({ smallestUnit, relativeTo, roundingMode }),
+ instance.round({ smallestUnit, relativeTo: relativeToForwards, roundingMode }),
py, pm, pw, pd, ph, pmin, ps, pms, pµs, pns,
`rounds to ${smallestUnit} (roundingMode = ${roundingMode}, positive case)`
);
TemporalHelpers.assertDuration(
- instance.negated().round({ smallestUnit, relativeTo, roundingMode }),
+ instance.negated().round({ smallestUnit, relativeTo: relativeToBackwards, roundingMode }),
ny, nm, nw, nd, nh, nmin, ns, nms, nµs, nns,
`rounds to ${smallestUnit} (rounding mode = ${roundingMode}, negative case)`
);
diff --git a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-trunc.js b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-trunc.js
index a85bd36580..ffe1beb00c 100644
--- a/test/built-ins/Temporal/Duration/prototype/round/roundingmode-trunc.js
+++ b/test/built-ins/Temporal/Duration/prototype/round/roundingmode-trunc.js
@@ -9,19 +9,23 @@ features: [Temporal]
---*/
const instance = new Temporal.Duration(5, 6, 7, 8, 40, 30, 20, 123, 987, 500);
-const relativeTo = new Temporal.PlainDate(2020, 1, 1);
+// Chosen such that 8 months forwards from relativeToForwards is the
+// same number of days as 8 months backwards from relativeToBackwards
+// (for convenience)
+const relativeToForwards = new Temporal.PlainDate(2020, 4, 1);
+const relativeToBackwards = new Temporal.PlainDate(2020, 12, 1);
const expected = [
["years", [5], [-5]],
["months", [5, 7], [-5, -7]],
["weeks", [5, 6, 8], [-5, -6, -8]],
- ["days", [5, 6, 7, 9], [-5, -6, -7, -9]],
- ["hours", [5, 6, 7, 9, 16], [-5, -6, -7, -9, -16]],
- ["minutes", [5, 6, 7, 9, 16, 30], [-5, -6, -7, -9, -16, -30]],
- ["seconds", [5, 6, 7, 9, 16, 30, 20], [-5, -6, -7, -9, -16, -30, -20]],
- ["milliseconds", [5, 6, 7, 9, 16, 30, 20, 123], [-5, -6, -7, -9, -16, -30, -20, -123]],
- ["microseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987], [-5, -6, -7, -9, -16, -30, -20, -123, -987]],
- ["nanoseconds", [5, 6, 7, 9, 16, 30, 20, 123, 987, 500], [-5, -6, -7, -9, -16, -30, -20, -123, -987, -500]],
+ ["days", [5, 7, 0, 27], [-5, -7, 0, -27]],
+ ["hours", [5, 7, 0, 27, 16], [-5, -7, 0, -27, -16]],
+ ["minutes", [5, 7, 0, 27, 16, 30], [-5, -7, 0, -27, -16, -30]],
+ ["seconds", [5, 7, 0, 27, 16, 30, 20], [-5, -7, 0, -27, -16, -30, -20]],
+ ["milliseconds", [5, 7, 0, 27, 16, 30, 20, 123], [-5, -7, 0, -27, -16, -30, -20, -123]],
+ ["microseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987], [-5, -7, 0, -27, -16, -30, -20, -123, -987]],
+ ["nanoseconds", [5, 7, 0, 27, 16, 30, 20, 123, 987, 500], [-5, -7, 0, -27, -16, -30, -20, -123, -987, -500]],
];
const roundingMode = "trunc";
@@ -30,12 +34,12 @@ expected.forEach(([smallestUnit, expectedPositive, expectedNegative]) => {
const [py, pm = 0, pw = 0, pd = 0, ph = 0, pmin = 0, ps = 0, pms = 0, pµs = 0, pns = 0] = expectedPositive;
const [ny, nm = 0, nw = 0, nd = 0, nh = 0, nmin = 0, ns = 0, nms = 0, nµs = 0, nns = 0] = expectedNegative;
TemporalHelpers.assertDuration(
- instance.round({ smallestUnit, relativeTo, roundingMode }),
+ instance.round({ smallestUnit, relativeTo: relativeToForwards, roundingMode }),
py, pm, pw, pd, ph, pmin, ps, pms, pµs, pns,
`rounds to ${smallestUnit} (roundingMode = ${roundingMode}, positive case)`
);
TemporalHelpers.assertDuration(
- instance.negated().round({ smallestUnit, relativeTo, roundingMode }),
+ instance.negated().round({ smallestUnit, relativeTo: relativeToBackwards, roundingMode }),
ny, nm, nw, nd, nh, nmin, ns, nms, nµs, nns,
`rounds to ${smallestUnit} (rounding mode = ${roundingMode}, negative case)`
);
diff --git a/test/staging/Temporal/Duration/old/round.js b/test/staging/Temporal/Duration/old/round.js
index b7fd879a06..5bc92fb56a 100644
--- a/test/staging/Temporal/Duration/old/round.js
+++ b/test/staging/Temporal/Duration/old/round.js
@@ -208,7 +208,7 @@ assert.sameValue(`${ hours25.round({
assert.sameValue(`${ d.round({
smallestUnit: "seconds",
relativeTo
- }) }`, "P5Y5M5W5DT5H5M5S");
+ }) }`, "P5Y6M10DT5H5M5S");
});
// does not accept non-string primitives for relativeTo
@@ -325,24 +325,24 @@ var roundAndBalanceResults = {
years: "P6Y",
months: "P5Y6M",
weeks: "P5Y5M6W",
- days: "P5Y5M5W5D",
- hours: "P5Y5M5W5DT5H",
- minutes: "P5Y5M5W5DT5H5M",
- seconds: "P5Y5M5W5DT5H5M5S",
- milliseconds: "P5Y5M5W5DT5H5M5.005S",
- microseconds: "P5Y5M5W5DT5H5M5.005005S",
- nanoseconds: "P5Y5M5W5DT5H5M5.005005005S"
+ days: "P5Y6M10D",
+ hours: "P5Y6M10DT5H",
+ minutes: "P5Y6M10DT5H5M",
+ seconds: "P5Y6M10DT5H5M5S",
+ milliseconds: "P5Y6M10DT5H5M5.005S",
+ microseconds: "P5Y6M10DT5H5M5.005005S",
+ nanoseconds: "P5Y6M10DT5H5M5.005005005S"
},
months: {
months: "P66M",
weeks: "P65M6W",
- days: "P65M5W5D",
- hours: "P65M5W5DT5H",
- minutes: "P65M5W5DT5H5M",
- seconds: "P65M5W5DT5H5M5S",
- milliseconds: "P65M5W5DT5H5M5.005S",
- microseconds: "P65M5W5DT5H5M5.005005S",
- nanoseconds: "P65M5W5DT5H5M5.005005005S"
+ days: "P66M10D",
+ hours: "P66M10DT5H",
+ minutes: "P66M10DT5H5M",
+ seconds: "P66M10DT5H5M5S",
+ milliseconds: "P66M10DT5H5M5.005S",
+ microseconds: "P66M10DT5H5M5.005005S",
+ nanoseconds: "P66M10DT5H5M5.005005005S"
},
weeks: {
weeks: "P288W",
@@ -521,42 +521,42 @@ assert.sameValue(`${ d.round({
smallestUnit: "hours",
roundingIncrement: 3,
relativeTo
-}) }`, "P5Y5M5W5DT6H");
+}) }`, "P5Y6M10DT6H");
// rounds to an increment of minutes
assert.sameValue(`${ d.round({
smallestUnit: "minutes",
roundingIncrement: 30,
relativeTo
-}) }`, "P5Y5M5W5DT5H");
+}) }`, "P5Y6M10DT5H");
// rounds to an increment of seconds
assert.sameValue(`${ d.round({
smallestUnit: "seconds",
roundingIncrement: 15,
relativeTo
-}) }`, "P5Y5M5W5DT5H5M");
+}) }`, "P5Y6M10DT5H5M");
// rounds to an increment of milliseconds
assert.sameValue(`${ d.round({
smallestUnit: "milliseconds",
roundingIncrement: 10,
relativeTo
-}) }`, "P5Y5M5W5DT5H5M5.01S");
+}) }`, "P5Y6M10DT5H5M5.01S");
// rounds to an increment of microseconds
assert.sameValue(`${ d.round({
smallestUnit: "microseconds",
roundingIncrement: 10,
relativeTo
-}) }`, "P5Y5M5W5DT5H5M5.00501S");
+}) }`, "P5Y6M10DT5H5M5.00501S");
// rounds to an increment of nanoseconds
assert.sameValue(`${ d.round({
smallestUnit: "nanoseconds",
roundingIncrement: 10,
relativeTo
-}) }`, "P5Y5M5W5DT5H5M5.00500501S");
+}) }`, "P5Y6M10DT5H5M5.00500501S");
// valid hour increments divide into 24
[ |
(stacked on top of #3956, will rebase as appropriate)This PR contains tests that cover a Temporal normative change that reached consensus in July 2023.
Normative PR: tc39/proposal-temporal#2722