Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch (un)balance_relative to avoid panicking #48

Merged
merged 1 commit into from
Jun 19, 2024
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
6 changes: 3 additions & 3 deletions src/components/duration/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
options::{
ArithmeticOverflow, RelativeTo, RoundingIncrement, TemporalRoundingMode, TemporalUnit,
},
utils, TemporalError, TemporalResult, NS_PER_DAY,
utils, TemporalError, TemporalResult, TemporalUnwrap, NS_PER_DAY,
};

use super::normalized::NormalizedTimeDuration;
Expand Down Expand Up @@ -65,7 +65,7 @@ impl DateDuration {
context: &mut C::Context,
) -> TemporalResult<Self> {
// 1. Assert: If plainRelativeTo is not undefined, calendarRec is not undefined.
let plain_relative = plain_relative_to.expect("plainRelativeTo must not be undefined.");
let plain_relative = plain_relative_to.temporal_unwrap()?;

// 2. Let defaultLargestUnit be DefaultTemporalLargestUnit(years, months, weeks, days, 0, 0, 0, 0, 0).
let default_largest = self.default_largest_unit();
Expand Down Expand Up @@ -189,7 +189,7 @@ impl DateDuration {
) -> TemporalResult<DateDuration> {
// TODO: Confirm 1 or 5 based off response to issue.
// 1. Assert: If plainRelativeTo is not undefined, calendarRec is not undefined.
let plain_relative = plain_relative_to.expect("plainRelativeTo must not be undefined.");
let plain_relative = plain_relative_to.temporal_unwrap()?;

// 2. Let allZero be false.
// 3. If years = 0, and months = 0, and weeks = 0, and days = 0, set allZero to true.
Expand Down