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

Fewer CalendarDay/CalendarDateFromFields calls during PlainYearMonth add/subtract #2798

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

arshaw
Copy link
Contributor

@arshaw arshaw commented Mar 7, 2024

While investigating for #2794 (ultimately unsuccessful), I uncovered a way to have less user-code calls from PlainYearMonth add/subtract.

I don't see it in the calendar invariants list, but this axiom probably goes without saying: the day before the first day of one month is the last day of the previous month.

If add/subtract moves backward in time, the algorithm requires us to determine the last day of the current month before proceeding with PlainDate-style add/subtract.

Right now, the last day is being determined, but seems unnecessary to thread it back through CalendarDateFromFields, no?

Adjusted tests:
tc39/test262@main...fullcalendar:test262:temporal-fewer-calls-pym-math

Copy link

codecov bot commented Mar 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.60%. Comparing base (02a6d14) to head (fe4ad56).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2798      +/-   ##
==========================================
- Coverage   96.60%   96.60%   -0.01%     
==========================================
  Files          23       23              
  Lines       12312    12304       -8     
  Branches     2272     2272              
==========================================
- Hits        11894    11886       -8     
  Misses        356      356              
  Partials       62       62              

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

@ptomato
Copy link
Collaborator

ptomato commented Apr 18, 2024

After #2826 we should rewrite this to be an editorial PR. Marking as draft for now.

@ptomato ptomato marked this pull request as draft April 18, 2024 20:50
arshaw and others added 2 commits September 10, 2024 11:19
…addition

Spec text algorithm corresponding to the previous commit. There is no need
to convert the end-of-month ISO date to a calendar date and then back to
an ISO date.

This looks like it might have removed an observable step, but I think
CalendarDateFromFields could already not throw here, because of the
assertion that _endOfMonth_ was a valid ISO date within range.
@ptomato ptomato force-pushed the fewer-calls-pym-math branch from fe4ad56 to 4150c9e Compare September 10, 2024 18:25
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.

Rebased. This is now an editorial change and doesn't require any modifications to test262. I've added the corresponding spec text.

@ptomato ptomato marked this pull request as ready for review September 10, 2024 18:26
@ptomato ptomato merged commit 8f8413d into tc39:main Sep 10, 2024
5 checks passed
@ptomato ptomato deleted the fewer-calls-pym-math branch September 10, 2024 18:29
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.

2 participants