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

Normative: Fix ZonedDateTime::round incorrect results with smallestUnit:day #2797

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

arshaw
Copy link
Contributor

@arshaw arshaw commented Mar 7, 2024

This is my proposed fix to #2790

Adjusted tests:
tc39/test262@main...fullcalendar:test262:temporal-2790-round-zdt-day

Could someone please review?

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 (985b826) to head (f464da6).

❗ Current head f464da6 differs from pull request most recent head 4e9ef15. Consider uploading reports for the commit 4e9ef15 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2797      +/-   ##
==========================================
+ Coverage   96.51%   96.60%   +0.09%     
==========================================
  Files          23       23              
  Lines       12386    12304      -82     
  Branches     2294     2276      -18     
==========================================
- Hits        11954    11886      -68     
+ Misses        372      356      -16     
- Partials       60       62       +2     

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

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.

Thanks for doing this, and the test262 tests as well! I'm pretty sure I understand it and it seems correct to me. Good to know that there were actually a few wrong tests in test262, not just adjustments to the observable user calls.

To present this to TC39 we'll need a change to the spec text. Are you interested in taking on that task as well?

polyfill/lib/ecmascript.mjs Outdated Show resolved Hide resolved
polyfill/lib/zoneddatetime.mjs Outdated Show resolved Hide resolved
@arshaw
Copy link
Contributor Author

arshaw commented Mar 20, 2024

@ptomato, sorry for the delay. I was on vaca for 1 week and upon returning have lots to catch up on. Will try my best to address all feedback by EOW.

@ptomato
Copy link
Collaborator

ptomato commented Mar 20, 2024

@ptomato, sorry for the delay. I was on vaca for 1 week and upon returning have lots to catch up on. Will try my best to address all feedback by EOW.

No problem. I think we are still in plenty of time for the TC39 agenda review deadline, 2024-03-29. If you would like help with the spec text, I'd be happy to contribute that part if it will let you concentrate on catching up with other things.

@arshaw
Copy link
Contributor Author

arshaw commented Mar 21, 2024

Hi @ptomato, I addressed all feed back and also added some tests that will make all new code have coverage.

Writing the spec text was driving me nuts as I'm unfamiliar with the notation and conventions. I'd greatly appreciate it if you could do it.

I'm happy to do any further refinements to make this compatible with what TC39 expects.

@arshaw arshaw marked this pull request as ready for review March 21, 2024 15:11
@ptomato
Copy link
Collaborator

ptomato commented Mar 21, 2024

@arshaw I've got a draft of the spec text, would you mind checking the "Allow edits from maintainers" checkbox? Then I can push it to this branch in a new commit.

Could you also submit the relevant test262 tests in fullcalendar/test262 as a PR to tc39/test262? I would offer to do it and save you some time, but then the UI won't let me approve my own PR.

@arshaw
Copy link
Contributor Author

arshaw commented Mar 22, 2024

@ptomato, the checkbox didn't show up I believe because you are not a collaborator on fullcalendar/proposal-temporal. I invited you. Hope fully the checkbox shows up after accepting.

I've created the test262 PR here:
tc39/test262#4021

@ptomato
Copy link
Collaborator

ptomato commented Mar 22, 2024

That's odd - it specifically shouldn't be necessary for me to be a collaborator on the source repo and that's never happened to me before! But once I accepted the invitation, I was able to add the commit.

Sorry about that!

@arshaw
Copy link
Contributor Author

arshaw commented Mar 22, 2024

@ptomato, I built and reviewed your spec changes, and everything looks as expected. Thank you so much.

@ptomato ptomato changed the title Fix: ZonedDateTime::round incorrect results with smallestUnit:day Normative: Fix ZonedDateTime::round incorrect results with smallestUnit:day Mar 22, 2024
@ptomato ptomato mentioned this pull request Mar 22, 2024
91 tasks
@arshaw arshaw marked this pull request as ready for review March 25, 2024 21:19
Copy link
Collaborator

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

LGTM!

@ptomato
Copy link
Collaborator

ptomato commented Apr 8, 2024

This change reached consensus at the TC39 meeting of 2024-04-08.

arshaw and others added 2 commits April 8, 2024 18:31
The following code shows how ZonedDateTime would previously get rounded up
by two days instead of the intended 1 day:

const zdt0 = Temporal.ZonedDateTime.from('2024-03-10T23:00:01[America/New_York]')
const zdt1 = zdt0.round({ smallestUnit: 'day', roundingMode: 'ceil' })
console.log(zdt1.toString()) // '2024-03-12T00:00:00-04:00[America/New_York]'

- 23:00:01 is considered the numerator
- 23:00:00 is considered the denominator (because 2024-03-10 has 23 hours
  in this tz)
- Dividing results in a number slightly larger than 1
- The ceil func nudges it to 2 (i.e. 2 days from 2024-03-10T00:00:00)

This is the spec text corresponding to the reference code change in the
previous commit.

Closes: tc39#2790
@ptomato ptomato force-pushed the 2790-round-zdt-day branch from f464da6 to 31fcba2 Compare April 9, 2024 01:31
@ptomato
Copy link
Collaborator

ptomato commented Apr 9, 2024

Tests failed due to the formatting snapshot of chinese and dangi calendars having changed in whatever Node point release is being installed on CI. That's a test in test262 staging which should probably not be there. I'll look into that tomorrow.

@ptomato
Copy link
Collaborator

ptomato commented Apr 9, 2024

test262 fix is in tc39/test262#4048. If it gets merged within a few days, I will update this PR to pull it in. If not, I'll add that test to the expected failures file and merge this.

@ptomato ptomato force-pushed the 2790-round-zdt-day branch from 31fcba2 to 4e9ef15 Compare April 10, 2024 15:39
@ptomato ptomato merged commit 1c9ddf5 into tc39:main Apr 10, 2024
5 checks passed
@ptomato ptomato deleted the 2790-round-zdt-day branch April 10, 2024 15:47
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