Skip to content

feat(intl): implement Temporal.PlainYearMonth.prototype.toLocaleString#5098

Open
alienx5499 wants to merge 6 commits intoboa-dev:mainfrom
alienx5499:feat/5083-plainyearmonth-tolocalestring
Open

feat(intl): implement Temporal.PlainYearMonth.prototype.toLocaleString#5098
alienx5499 wants to merge 6 commits intoboa-dev:mainfrom
alienx5499:feat/5083-plainyearmonth-tolocalestring

Conversation

@alienx5499
Copy link
Contributor

@alienx5499 alienx5499 commented Mar 15, 2026

This Pull Request fixes/closes #5083.

It changes the following:

  • Implement Temporal.PlainYearMonth.prototype.toLocaleString per spec. It now acts as a thin wrapper that delegates to a new, centralized HandleDateTimeValue dispatcher (§15.6.22) in the Intl module. When the caller omits dateStyle/timeStyle, default year: "numeric" and month: "short" are applied so ICU does not fall back to full date defaults (reference day) — fixes Test262 default-does-not-include-day-time-and-time-zone-name.js.
  • Implement HandleDateTimeTemporalYearMonth (§15.6.16) to compute the Intl formatting anchor from the Temporal plain value; validate Intl calendar against the Temporal calendar, and model Temporal plain timeZone by forcing Intl timeZone to "+00:00".
  • Add tests for PlainYearMonth.prototype.toLocaleString: returns string, invalid receiver throws TypeError, and (with the intl feature) different locales/options affect output; plain timeZone is ignored/overridden, incompatible calendar throws, and default output excludes reference day/time/timeZoneName (regression for Test262 default-does-not-include-day-time-and-time-zone-name.js).

Testing

  • cargo test -p boa_engine --no-default-features --features temporal --lib plain_year_month (Temporal-only tests)
  • cargo test -p boa_engine --features intl_bundled,temporal --lib plain_year_month (with intl)
  • cargo run -p boa_tester -- run --suite test/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/default-does-not-include-day-time-and-time-zone-name.js

Status: rebased onto main after #5080; this PR now only contains the Temporal PlainYearMonth.prototype.toLocaleString changes for #5083.

@github-actions github-actions bot added Waiting On Review Waiting on reviews from the maintainers C-Tests Issues and PRs related to the tests. C-Builtins PRs and Issues related to builtins/intrinsics C-Intl Changes related to the `Intl` implementation and removed Waiting On Review Waiting on reviews from the maintainers labels Mar 15, 2026
@github-actions github-actions bot added this to the v1.0.0 milestone Mar 15, 2026
@github-actions
Copy link

github-actions bot commented Mar 15, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,079 50,080 +1
Ignored 2,072 2,072 0
Failed 812 811 -1
Panics 0 0 0
Conformance 94.55% 94.56% +0.00%
Fixed tests (1):
test/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/datestyle-and-timestyle.js (previously Failed)

Tested main commit: 26271b7c3f6f357f12fd835a0402d8b643f03db5
Tested PR commit: fceb44a4e37de47b171fe2b919a45e4fef706734
Compare commits: 26271b7...fceb44a

@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 76.59574% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.86%. Comparing base (6ddc2b4) to head (ea730d8).
⚠️ Report is 918 commits behind head on main.

Files with missing lines Patch % Lines
...e/engine/src/builtins/intl/date_time_format/mod.rs 75.28% 22 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5098       +/-   ##
===========================================
+ Coverage   47.24%   59.86%   +12.62%     
===========================================
  Files         476      589      +113     
  Lines       46892    63490    +16598     
===========================================
+ Hits        22154    38010    +15856     
- Misses      24738    25480      +742     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jedel1043 jedel1043 added the Blocked Waiting for another code change label Mar 16, 2026
@alienx5499 alienx5499 force-pushed the feat/5083-plainyearmonth-tolocalestring branch from f11323d to fceb44a Compare March 19, 2026 10:30
@github-actions github-actions bot added the Waiting On Review Waiting on reviews from the maintainers label Mar 19, 2026
@alienx5499 alienx5499 marked this pull request as ready for review March 19, 2026 10:36
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.

Generally worth noting, that from what I can tell. The T.p.toLocaleString implementations all seem to require similar plumbing.

The specification can be found here

Ok(JsString::from(year_month.inner.to_string()).into())
#[cfg(feature = "intl")]
{
use crate::builtins::{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: the implementation here should ideally follow or adapt the specification steps provided in the Temporal specification as additions to ECMA402

@github-actions
Copy link

github-actions bot commented Mar 20, 2026

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,732 50,734 +2
Ignored 1,426 1,426 0
Failed 805 803 -2
Panics 0 0 0
Conformance 95.79% 95.79% +0.00%
Fixed tests (2):
test/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/datestyle-and-timestyle.js (previously Failed)
test/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/options-conflict.js (previously Failed)

Tested main commit: 8fcbfcbb8b9e70fe878d28376a6496eaa57a70d7
Tested PR commit: ea730d8a5219977c053444136818dc69d333ca01
Compare commits: 8fcbfcb...ea730d8

@alienx5499 alienx5499 requested a review from nekevss March 21, 2026 08:01
@alienx5499
Copy link
Contributor Author

Hi @nekevss,

I’ve addressed your feedback and aligned the implementation more closely with the Temporal -> ECMA-402 specification steps, and rebased on latest main.

Since #5080 is now merged, the original blocking dependency should be resolved. Could you please take another look when you have time?

If the Blocked label was only due to that dependency, it may no longer be needed.

Let me know if anything still needs adjustment.

Thanks!

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.

This is looking good overall and the tests appear to be promising.

This method is a little tricky, especially when it comes to the specification. There's a lot of complicated specification text, but in order to better support the other temporal built-ins and follow up work on this code path.

It's worth noting that if there's other code paths that you aren't trying to support currently. Feel free to return a result where the other branches return a js_error!("Not yet implemented").

}

// Compute epochNs from isoDate + NoonTimeRecord (steps 2-3), then pass it to the shared
// ECMA-402 formatting pipeline as epoch milliseconds.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: this should ideally not be inlined from HandleDateTimeValue.

The implementation here should probably stick as close to the specification as possible while also being able to expand to support the other temporal built-ins

@alienx5499
Copy link
Contributor Author

Hi @nekevss,

Updated based on your feedback, moved the Temporal.PlainYearMonth logic out of HandleDateTimeValue and into a dedicated handler, keeping the dispatcher clean and closer to the spec structure.

Would appreciate a re-review when you have time.

Thanks!

@alienx5499 alienx5499 requested a review from nekevss March 25, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Blocked Waiting for another code change C-Builtins PRs and Issues related to builtins/intrinsics C-Intl Changes related to the `Intl` implementation C-Tests Issues and PRs related to the tests. Waiting On Review Waiting on reviews from the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Temporal.PlainYearMonth.prototype.toLocaleString

3 participants