-
-
Notifications
You must be signed in to change notification settings - Fork 388
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 |
fn from(_: &JsValue, args: &[JsValue], context: &mut Context) -> JsResult<JsValue> { | ||
let item = args.get_or_undefined(0); | ||
// 1. If Type(item) is Object or Type(item) is String and item is not null, then | ||
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.
question: Is this up to date?
I currently have the specification showing the below for 9.2.2, which may actually simplify the logic here if so.
2. If item is an Object and item has an [[InitializedTemporalYearMonth]] internal slot, then
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.
It is up to date, you're right there's no check.
What's the best way to brand check these? downcasting feels performance heavy
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.
Downcasting is not really performance heavy, it's just two u64 comparisons. In this case, since you just need the inner data, you can just do something like:
if let Some(data) = item.as_object().and_then(JsObject::downcast_ref::<PlainYearMonth>) {
// Perform ? [GetTemporalOverflowOption](https://tc39.es/proposal-temporal/#sec-temporal-gettemporaloverflowoption)(options).
// b. Return ! [CreateTemporalYearMonth](https://tc39.es/proposal-temporal/#sec-temporal-createtemporalyearmonth)(item.[[ISOYear]], item.[[ISOMonth]], item.[[Calendar]], item.[[ISODay]]).
}
(not typechecked or borrow checked, maybe you'll have to clone if the call to get_temporal_overflow_option
causes a panic)
25e9fb9
to
89f1b10
Compare
89f1b10
to
015fda4
Compare
015fda4
to
90dda86
Compare
Adds methods to yearMonth and monthDay
Relies on boa-dev/temporal#44