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

Updates to temporal_rs version and temporal methods #3900

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Apply review feedback for relativeTo
nekevss committed Jul 8, 2024
commit 7e9b487d5174c04b2dc318493597b69c9806aa20
20 changes: 11 additions & 9 deletions core/engine/src/builtins/temporal/mod.rs
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ use crate::{
realm::Realm,
string::StaticJsStrings,
value::Type,
Context, JsBigInt, JsError, JsNativeError, JsObject, JsResult, JsString, JsSymbol, JsValue,
Context, JsBigInt, JsNativeError, JsObject, JsResult, JsString, JsSymbol, JsValue,
};
use boa_macros::js_str;
use boa_profiler::Profiler;
@@ -250,16 +250,18 @@ pub(crate) fn to_relative_temporal_object(
) -> RelativeTemporalObjectResult {
let relative_to = options.get(PropertyKey::from(js_str!("relativeTo")), context)?;
let plain_date = match relative_to {
JsValue::String(relative_to_str) => Some(relative_to_str.into()),
JsValue::Object(relative_to_obj) => Some(relative_to_obj.into()),
_ => None,
}
.map(|plain_date| Ok::<_, JsError>(to_temporal_date(&plain_date, None, context)))
.transpose()?
.transpose()?;
JsValue::String(relative_to_str) => JsValue::from(relative_to_str),
JsValue::Object(relative_to_obj) => JsValue::from(relative_to_obj),
_ => {
return Err(JsNativeError::typ()
.with_message("Invalid type for converting to relativeTo object")
.into())
}
};
let plain_date = to_temporal_date(&plain_date, None, context)?;

// TODO: Implement TemporalZonedDateTime conversion when ZonedDateTime is implemented
Ok((plain_date, None))
Ok((Some(plain_date), None))
}

// 13.22 `LargerOfTwoTemporalUnits ( u1, u2 )`