Skip to content
Closed
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
7 changes: 4 additions & 3 deletions src/builtins/core/duration/normalized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,14 @@ impl InternalDurationRecord {
self.norm
}

pub(crate) fn sign(&self) -> Sign {
pub(crate) fn sign(&self) -> NonZeroSign {
let date_sign = self.date.sign();
if date_sign == Sign::Zero {
self.norm.sign()
} else {
date_sign
}
.to_nonzero_sign()
}
}

Expand Down Expand Up @@ -1291,7 +1292,7 @@ impl InternalDurationRecord {
|| (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().to_nonzero_sign();
let sign = duration.sign();

// 5. If irregularLengthUnit is true, then
let nudge_result = if irregular_length_unit {
Expand Down Expand Up @@ -1351,7 +1352,7 @@ impl InternalDurationRecord {
// 1. If IsCalendarUnit(unit) is true, or timeZone is not unset and unit is day, then
if unit.is_calendar_unit() || (time_zone.is_some() && unit == Unit::Day) {
// a. If InternalDurationSign(duration) < 0, let sign be -1; else let sign be 1
let sign = self.sign().to_nonzero_sign();
let sign = self.sign();
// b. Let record be ? NudgeToCalendarUnit(sign, duration, destEpochNs, isoDateTime, timeZone, calendar, 1, unit, trunc).
// c. Return record.[[Total]].
return self.nudge_calendar_unit_total(
Expand Down