Skip to content

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

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

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

Conversation

@alienx5499
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

codecov bot commented Mar 15, 2026

Codecov Report

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

Files with missing lines Patch % Lines
...e/engine/src/builtins/intl/date_time_format/mod.rs 75.00% 22 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5098       +/-   ##
===========================================
+ Coverage   47.24%   59.97%   +12.72%     
===========================================
  Files         476      590      +114     
  Lines       46892    63766    +16874     
===========================================
+ Hits        22154    38243    +16089     
- Misses      24738    25523      +785     

☔ 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

github-actions bot commented Mar 20, 2026

Test262 conformance changes

Test result main count PR count difference
Total 53,125 53,125 0
Passed 51,049 51,052 +3
Ignored 1,482 1,482 0
Failed 594 591 -3
Panics 0 0 0
Conformance 96.09% 96.10% +0.01%
Fixed tests (3):
test/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/lone-options-accepted.js (previously Failed)
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: 3cec5e6bc4454077cb8d65b537d368d633137e0e
Tested PR commit: a1db0486e9b3ea6b9726ec0bef8508e42005ca5c
Compare commits: 3cec5e6...a1db048

@alienx5499 alienx5499 requested a review from nekevss March 21, 2026 08:01
@alienx5499
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@alienx5499
Copy link
Copy Markdown
Contributor Author

Hi @nekevss,

Just a quick followup, the earlier feedback has been addressed.

Happy to refine further if needed. Would appreciate a re review when you get a chance.

Thanks!

@Vellumic
Copy link
Copy Markdown
Contributor

I noticed this PR uses logic that violates the ECMA-402 specification regarding dateStyle/timeStyle fallbacks. I've already submitted a separate bugfix and regression test for this issue here: #5324.

Furthermore, this PR duplicates parts of the formatting infrastructure I'm currently working on in #5199. We should avoid merging these changes to prevent double-work and immediate technical debt.

@alienx5499
Copy link
Copy Markdown
Contributor Author

alienx5499 commented Apr 13, 2026

@Vellumic
You’re right about the dateStyle/timeStyle fallback, that was introduced earlier in #5080 and is now corrected here, along with regression tests.

This PR focuses on implementing Temporal.PlainYearMonth.prototype.toLocaleString #5083 with minimal, spec-aligned changes.

@Vellumic
Copy link
Copy Markdown
Contributor

I see you used my fix in your code, however it doesn't fixes the general issue I was addressing earlier. Because Temporal was designed with legacy Date flaws in mind, it needs more complex parsing.

@alienx5499
Copy link
Copy Markdown
Contributor Author

@Vellumic

The change here addresses the dateStyle/timeStyle fallback behavior in the shared Date formatting path, which this PR depends on.

This PR is scoped to Temporal.PlainYearMonth.prototype.toLocaleString #5083. Broader Temporal formatting concerns should be handled separately if needed.

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

4 participants