Skip to content

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented Aug 12, 2025

Adds an official definition of month code (so that it can be used as a parameter type) and a few month code-related operations, following on from discussion in tc39/proposal-intl-era-monthcode#69.

Noticed that this didn't use the saved RangeErrorCtor as is should have.
Copy link

codecov bot commented Aug 12, 2025

Codecov Report

❌ Patch coverage is 95.58824% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.82%. Comparing base (07c924b) to head (8d072d5).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
polyfill/lib/calendar.mjs 93.93% 1 Missing and 1 partial ⚠️
polyfill/lib/monthcode.mjs 96.42% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3144      +/-   ##
==========================================
+ Coverage   96.78%   96.82%   +0.04%     
==========================================
  Files          21       22       +1     
  Lines       10002     9995       -7     
  Branches     1830     1819      -11     
==========================================
- Hits         9680     9678       -2     
+ Misses        276      270       -6     
- Partials       46       47       +1     

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

Copy link
Collaborator

@sffc sffc left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Member

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

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

👍

ptomato and others added 3 commits August 13, 2025 13:53
These operations are used in the Intl Era Monthcode proposal. They are
also already useful in Temporal, so introduce them here.

Co-Authored-By: Shane F. Carr <[email protected]>
The polyfill already contained two functions that were doing essentially
the same things, so rename them. However they were also doing duplicated
work of validation that was already done in ToMonthCode, so eliminate
that duplication.

This simplifies the calendar code a little bit.
Similar to "calendar type" strings, we introduce "month code" strings
which are syntactically valid month codes. Move the description of month
code syntax out of the table and into its own clause.
@ptomato ptomato force-pushed the month-code-improvements branch from a03d53b to 01f92d8 Compare August 13, 2025 20:54
Copy link
Collaborator

@sffc sffc left a comment

Choose a reason for hiding this comment

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

I feel like if we go down this path, the month code type in the spec should be the Record, and we have an AO to convert the record to a string. But, I'm okay with this intermediate approach where month code is a valid month code string, but we seem to be inconsistent about it.

@ptomato
Copy link
Collaborator Author

ptomato commented Aug 14, 2025

I feel like if we go down this path, the month code type in the spec should be the Record

Yep, I feel the same way. But I also reached the same conclusion that this is OK as an intermediate approach.

@ptomato ptomato force-pushed the month-code-improvements branch from 01f92d8 to 8d072d5 Compare August 14, 2025 00:32
@ptomato ptomato merged commit e6f565d into main Aug 14, 2025
10 checks passed
@ptomato ptomato deleted the month-code-improvements branch August 14, 2025 00:36
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