Commit f03d02e2 authored by Frank Tang's avatar Frank Tang Committed by V8 LUCI CQ

[Temporal] Sync PR 2261

Disallow negative day lengths as round result

PR https://github.com/tc39/proposal-temporal/pull/2261

Also fix the missing extraValues=<"day"> to GetTemporalUnit

Spec Text: https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.round

Bug: v8:11544
Change-Id: Ibc963d5d93dde30f29df707ef3b3ecea99cd4a60
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3855704Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82798}
parent f54b1eb4
......@@ -17102,12 +17102,12 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::Round(
}
// 6. Let smallestUnit be ? GetTemporalUnit(roundTo, "smallestUnit", time,
// required).
// required, « "day" »).
Unit smallest_unit;
MAYBE_ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, smallest_unit,
GetTemporalUnit(isolate, round_to, "smallestUnit", UnitGroup::kTime,
Unit::kDay, true, method_name),
Unit::kDay, true, method_name, Unit::kDay),
Handle<JSTemporalZonedDateTime>());
// 7. Let roundingMode be ? ToTemporalRoundingMode(roundTo, "halfExpand").
......@@ -17180,8 +17180,8 @@ MaybeHandle<JSTemporalZonedDateTime> JSTemporalZonedDateTime::Round(
// 18. Let dayLengthNs be ℝ(endNs - startNs).
Handle<BigInt> day_length_ns =
BigInt::Subtract(isolate, end_ns, start_ns).ToHandleChecked();
// 19. If dayLengthNs is 0, then
if (!day_length_ns->ToBoolean()) {
// 19. If dayLengthNs 0, then
if (day_length_ns->IsNegative() || !day_length_ns->ToBoolean()) {
// a. Throw a RangeError exception.
THROW_NEW_ERROR(isolate, NEW_TEMPORAL_INVALID_ARG_RANGE_ERROR(),
JSTemporalZonedDateTime);
......
......@@ -682,7 +682,6 @@
'built-ins/Temporal/PlainTime/prototype/add/argument-string-duration-too-large': [FAIL],
'built-ins/Temporal/PlainTime/prototype/subtract/argument-string-duration-too-large': [FAIL],
'built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/fixed-offset-near-date-time-limits': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-daylength-too-large': [FAIL],
'intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition': [FAIL],
'intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition': [FAIL],
......@@ -693,7 +692,6 @@
'built-ins/Temporal/PlainDateTime/prototype/toString/fractionalseconddigits-non-integer': [FAIL],
'built-ins/Temporal/PlainMonthDay/refisoyear-out-of-range': [FAIL],
'built-ins/Temporal/PlainTime/prototype/toString/fractionalseconddigits-non-integer': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-daylength-zero-or-negative': [FAIL],
'built-ins/Temporal/ZonedDateTime/prototype/toString/fractionalseconddigits-non-integer': [FAIL],
'intl402/Temporal/TimeZone/from/etc-timezone': [FAIL],
'intl402/Temporal/TimeZone/from/iana-legacy-names': [FAIL],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment