Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/builtins/core/duration/normalized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,13 @@ impl NormalizedDurationRecord {
self.norm
}

pub(crate) fn sign(&self) -> TemporalResult<Sign> {
Ok(self.date.sign())
pub(crate) fn sign(&self) -> Sign {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhhh, interesting that was holdover.

let date_sign = self.date.sign();
if date_sign == Sign::Zero {
self.norm.sign()
} else {
date_sign
}
}
}

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

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

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