-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
add some temporal methods #3856
base: main
Are you sure you want to change the base?
Conversation
Test262 conformance changes
Fixed tests (7):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a little early feedback 😄
linked to boa-dev/temporal#44 |
25e9fb9
to
89f1b10
Compare
89f1b10
to
015fda4
Compare
015fda4
to
90dda86
Compare
b9c1f29
to
68578ef
Compare
6997e1e
to
a4a190f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PartialDuration
update looks good to me! Had a couple more comments around MonthDay. 😄
} | ||
|
||
// 12. Let minutes be ? Get(temporalDurationLike, "minutes"). | ||
let minutes = unknown_object.get(js_str!("minutes"), context)?; | ||
// 13. If minutes is not undefined, set result.[[Minutes]] to ? ToIntegerIfIntegral(minutes). | ||
if !minutes.is_undefined() { | ||
result.set_minutes(f64::from(to_integer_if_integral(&minutes, context)?)); | ||
result.minutes = Some(FiniteF64::from(to_integer_if_integral(&minutes, context)?)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: It might be nice if we had a JsValue::map
that acted similar to Option::map
, where Undefined is None.
|
||
// 3. NOTE: The following steps read properties and perform independent validation in alphabetical order. | ||
// 4. Let days be ? Get(temporalDurationLike, "days"). | ||
let days = unknown_object.get(js_str!("days"), context)?; | ||
if !days.is_undefined() { | ||
// 5. If days is not undefined, set result.[[Days]] to ? ToIntegerIfIntegral(days). | ||
result.set_days(f64::from(to_integer_if_integral(&days, context)?)); | ||
result.days = Some(FiniteF64::from(to_integer_if_integral(&days, context)?)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: potentially use in-place Option
operations.
There may be some benefit to use either insert
or get_or_insert
over " = Some(...) ". i.e. result.days.insert(FiniteF64::from(...));
fn from(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult<JsValue> { | ||
let options = get_options_object(args.get_or_undefined(1))?; | ||
let item = args.get_or_undefined(0); | ||
let inner = if item.is_object() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: extract into to_temporal_month_day
function
Technically, ToTemporalMonthDay
is only called twice by by from
and equals
, so I could see the argument to not extract it. But having a to-X method implementation would be consistent with all the other built-ins and hopefully make everything a bit more readable.
} else { | ||
temporal_duration_like.years() | ||
}; | ||
let years = temporal_duration_like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: I definitely much prefer this to the previous code!
Was double checking this. I think the new revision of |
Adds methods to yearMonth and monthDay
Relies on boa-dev/temporal#44