From 13cacbe7794ac4cc2083e6fdfbbf405d4bdc2c16 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 22 Dec 2025 14:56:38 -0800 Subject: [PATCH] Move more of Duration over to NonZeroSign --- src/builtins/core/duration/normalized.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/builtins/core/duration/normalized.rs b/src/builtins/core/duration/normalized.rs index 7e8a472cd..5d020f560 100644 --- a/src/builtins/core/duration/normalized.rs +++ b/src/builtins/core/duration/normalized.rs @@ -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() } } @@ -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 { @@ -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(