Skip to content

Polyfill: Fix two tests related to date/time formatting#3256

Merged
Ms2ger merged 3 commits intotc39:mainfrom
catamorphism:date-time-amend
Jan 26, 2026
Merged

Polyfill: Fix two tests related to date/time formatting#3256
Ms2ger merged 3 commits intotc39:mainfrom
catamorphism:date-time-amend

Conversation

@catamorphism
Copy link
Contributor

  1. Remove 'timeZoneName' from hasAnyDateTimeOptions. This matches the spec ( https://tc39.es/proposal-temporal/#sec-getdatetimeformat step 14).
  2. Add a case to timeAmend to throw an exception for the 'dateStyle' option. This matches the spec
    ( https://tc39.es/proposal-temporal/#sec-createdatetimeformat step 45c).

This allows the following tests to pass:

  • intl402/DateTimeFormat/prototype/{format, formatToParts, formatRange, formatRangeToParts}/temporal-plaindatetime-unsupported-options.js
  • intl402/Temporal/PlainTime/prototype/toLocaleString/datestyle-and-timestyle.js

Copy link
Collaborator

@ptomato ptomato left a comment

Choose a reason for hiding this comment

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

I dug into this a bit today and found that it requires a bit more refactoring.

You can see in the CI log that intl402/DateTimeFormat/prototype/format/temporal-plaintime-formatting-datetime-style.js unexpectedly fails here. I initially thought this test was incorrect, but by my reading of the spec it is actually correct — dateStyle and timeStyle together should throw when passed to the toLocaleString method of PlainDate, PlainTime, PlainYearMonth, or PlainMonthDay, but should be accepted in the Intl.DateTimeFormat constructor.

I've kind of half-done the refactoring already while trying to figure out what was going on. Let me know if you want to go over it together so you can take it over to finish this PR, or alternatively I can clean up what I have and push it to this PR.

Either way, we'll also need to update the pinned test262 commit to include Anba's modifications to the tests.

@ptomato
Copy link
Collaborator

ptomato commented Jan 21, 2026

tc39/test262#4880 should add more test coverage relevant to this.

catamorphism and others added 3 commits January 23, 2026 14:44
Remove 'timeZoneName' from hasAnyDateTimeOptions. This matches the
spec (https://tc39.es/proposal-temporal/#sec-getdatetimeformat step 14).

hasDateOptions and hasTimeOptions already check for dateStyle and
timeStyle respectively, so those can be deleted as well.
This fixes a polyfill bug that was previously not covered by tests. When
calling the toLocaleString methods of PlainDate, PlainMonthDay,
PlainTime, or PlainYearMonth, the formatter should be created using the
'required' parameter, so that at least one date or time option is
required (depending on the type being formatted).

This parameter does not correspond to any constructor argument of
Intl.DateTimeFormat, so we need to export a CreateDateTimeFormat()
function from intl.mjs to expose the functionality to other files.
Rename the existing createDateTimeFormat() to
internalCreateDateTimeFormat().
@ptomato ptomato dismissed their stale review January 23, 2026 22:48

Comments addressed

@ptomato
Copy link
Collaborator

ptomato commented Jan 23, 2026

OK, I cleaned up my half-done refactor and pushed it to this branch. I'd appreciate if someone else besides me could take a look at it.

@ptomato ptomato requested a review from Ms2ger January 23, 2026 22:49
@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.89%. Comparing base (9291822) to head (77c14d3).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3256      +/-   ##
==========================================
- Coverage   97.91%   97.89%   -0.03%     
==========================================
  Files          22       22              
  Lines       10367    10405      +38     
  Branches     1805     1819      +14     
==========================================
+ Hits        10151    10186      +35     
- Misses        197      200       +3     
  Partials       19       19              

☔ 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.

@Ms2ger Ms2ger merged commit 1a46f87 into tc39:main Jan 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants