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

Implement Date parsing according to the spec #3564

Merged
merged 1 commit into from
Jan 9, 2024
Merged

Implement Date parsing according to the spec #3564

merged 1 commit into from
Jan 9, 2024

Conversation

raskad
Copy link
Member

@raskad raskad commented Jan 5, 2024

This PR implements parsing in Date() and Date.parse() according to the spec.

Until now we only parsed the given string in the RFC 3339 format. The spec allows for a more relaxed format, for example partial formats are allowed (e.g. 2024, 2024T00:00, ...). While the spec allows for implementation specifc parsing it also specifies that the output of Date.toString, Date.toUTCString and Date.toISOString must be parsable into an equal Date object. These formats are now also parsed (the Date.toISOString format is the same that the spec defines itself).

@raskad raskad added bug Something isn't working builtins PRs and Issues related to builtins/intrinsics waiting-on-review Waiting on reviews from the maintainers labels Jan 5, 2024
@raskad raskad added this to the v0.18.0 milestone Jan 5, 2024
@raskad raskad requested a review from a team January 5, 2024 06:48
Copy link

github-actions bot commented Jan 5, 2024

Test262 conformance changes

Test result main count PR count difference
Total 95,960 95,960 0
Passed 76,534 76,548 +14
Ignored 18,477 18,477 0
Failed 949 935 -14
Panics 0 0 0
Conformance 79.76% 79.77% +0.01%
Fixed tests (14):
test/built-ins/Date/S15.9.2.1_A2.js [strict mode] (previously Failed)
test/built-ins/Date/S15.9.2.1_A2.js (previously Failed)
test/built-ins/Date/15.9.1.15-1.js [strict mode] (previously Failed)
test/built-ins/Date/15.9.1.15-1.js (previously Failed)
test/built-ins/Date/parse/without-utc-offset.js [strict mode] (previously Failed)
test/built-ins/Date/parse/without-utc-offset.js (previously Failed)
test/built-ins/Date/parse/zero.js [strict mode] (previously Failed)
test/built-ins/Date/parse/zero.js (previously Failed)
test/built-ins/Date/prototype/toUTCString/negative-year.js [strict mode] (previously Failed)
test/built-ins/Date/prototype/toUTCString/negative-year.js (previously Failed)
test/built-ins/Date/prototype/toDateString/negative-year.js [strict mode] (previously Failed)
test/built-ins/Date/prototype/toDateString/negative-year.js (previously Failed)
test/built-ins/Date/prototype/toString/negative-year.js [strict mode] (previously Failed)
test/built-ins/Date/prototype/toString/negative-year.js (previously Failed)

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Attention: 52 lines in your changes are missing coverage. Please review.

Comparison is base (35df2de) 47.42% compared to head (27c2c1c) 47.44%.
Report is 3 commits behind head on main.

Files Patch % Lines
core/engine/src/builtins/date/utils.rs 59.68% 52 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3564      +/-   ##
==========================================
+ Coverage   47.42%   47.44%   +0.02%     
==========================================
  Files         470      470              
  Lines       45690    45809     +119     
==========================================
+ Hits        21667    21734      +67     
- Misses      24023    24075      +52     

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

Copy link
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 looks good to me! I really like some aspects of it!

I was going to have a bit of a nit about MINUS being used, but it looks like it's not in the ECMAScript spec 😅

.and_then(|c| if c == expect { Some(()) } else { None })
}

fn next_digit(&mut self) -> Option<u8> {
Copy link
Member

Choose a reason for hiding this comment

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

Oooooh, I like this. Definitely makes other parts of parsing a lot nicer too!

@nekevss nekevss requested a review from a team January 5, 2024 18:52
Copy link
Member

@HalidOdat HalidOdat left a comment

Choose a reason for hiding this comment

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

Nice work! Looks good to me! :)

@raskad raskad added this pull request to the merge queue Jan 9, 2024
Merged via the queue into main with commit a592883 Jan 9, 2024
14 checks passed
@raskad raskad deleted the date-parsing branch January 9, 2024 16:30
@jedel1043 jedel1043 removed the waiting-on-review Waiting on reviews from the maintainers label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants