Skip to content

Commit d8496bc

Browse files
authored
Include time duration in InternalDurationSign (#397)
https://tc39.es/proposal-temporal/#sec-temporal-internaldurationsign
1 parent f98f5cf commit d8496bc

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/builtins/core/duration/normalized.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,13 @@ impl NormalizedDurationRecord {
304304
self.norm
305305
}
306306

307-
pub(crate) fn sign(&self) -> TemporalResult<Sign> {
308-
Ok(self.date.sign())
307+
pub(crate) fn sign(&self) -> Sign {
308+
let date_sign = self.date.sign();
309+
if date_sign == Sign::Zero {
310+
self.norm.sign()
311+
} else {
312+
date_sign
313+
}
309314
}
310315
}
311316

@@ -955,7 +960,7 @@ impl NormalizedDurationRecord {
955960
|| (time_zone.is_some() && options.smallest_unit == Unit::Day);
956961

957962
// 4. If InternalDurationSign(duration) < 0, let sign be -1; else let sign be 1.
958-
let sign = duration.sign()?;
963+
let sign = duration.sign();
959964

960965
// 5. If irregularLengthUnit is true, then
961966
let nudge_result = if irregular_length_unit {
@@ -1007,7 +1012,7 @@ impl NormalizedDurationRecord {
10071012
// 1. If IsCalendarUnit(unit) is true, or timeZone is not unset and unit is day, then
10081013
if unit.is_calendar_unit() || (tz.is_some() && unit == Unit::Day) {
10091014
// a. Let sign be InternalDurationSign(duration).
1010-
let sign = self.sign()?;
1015+
let sign = self.sign();
10111016
// b. Let record be ? NudgeToCalendarUnit(sign, duration, destEpochNs, isoDateTime, timeZone, calendar, 1, unit, trunc).
10121017
let record = self.nudge_calendar_unit(
10131018
sign,

0 commit comments

Comments
 (0)