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

add some temporal methods #3856

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

add some temporal methods #3856

wants to merge 14 commits into from

Conversation

jasonwilliams
Copy link
Member

@jasonwilliams jasonwilliams commented May 15, 2024

Adds methods to yearMonth and monthDay

Relies on boa-dev/temporal#44

@jasonwilliams jasonwilliams added the enhancement New feature or request label May 15, 2024
Copy link

Test262 conformance changes

Test result main count PR count difference
Total 50,731 50,731 0
Passed 42,973 42,980 +7
Ignored 1,395 1,395 0
Failed 6,363 6,356 -7
Panics 18 18 0
Conformance 84.71% 84.72% +0.01%
Fixed tests (7):
test/built-ins/Temporal/PlainYearMonth/calendar-undefined.js (previously Failed)
test/built-ins/Temporal/PlainYearMonth/prototype/calendarId/branding.js (previously Failed)
test/built-ins/Temporal/PlainYearMonth/prototype/calendarId/builtin-calendar-no-observable-calls.js (previously Failed)
test/built-ins/Temporal/PlainYearMonth/prototype/month/branding.js (previously Failed)
test/built-ins/Temporal/PlainYearMonth/prototype/month/builtin-calendar-no-observable-calls.js (previously Failed)
test/built-ins/Temporal/PlainYearMonth/prototype/year/branding.js (previously Failed)
test/built-ins/Temporal/PlainYearMonth/prototype/year/builtin-calendar-no-observable-calls.js (previously Failed)

Copy link
Member

@nekevss nekevss left a 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 😄

core/engine/src/builtins/temporal/plain_year_month/mod.rs Outdated Show resolved Hide resolved
@jasonwilliams
Copy link
Member Author

linked to boa-dev/temporal#44

@jasonwilliams jasonwilliams marked this pull request as ready for review May 24, 2024 16:11
core/engine/src/builtins/temporal/plain_year_month/mod.rs Outdated Show resolved Hide resolved
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() {
Copy link
Member

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

Copy link
Member Author

@jasonwilliams jasonwilliams Jun 25, 2024

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

Copy link
Member

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants