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: Support 'T' prefix in time-only strings and require it in cases of ambiguity #1952

Merged
merged 3 commits into from
Dec 17, 2021

Conversation

ptomato
Copy link
Collaborator

@ptomato ptomato commented Dec 3, 2021

Includes #1950 to avoid rebase conflicts. I'll make sure that one is merged before this one.

Closes: #1765

@codecov
Copy link

codecov bot commented Dec 3, 2021

Codecov Report

Merging #1952 (bc4b64c) into main (7e58ba3) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1952      +/-   ##
==========================================
+ Coverage   94.96%   94.97%   +0.01%     
==========================================
  Files          19       19              
  Lines       10967    10989      +22     
  Branches     1743     1751       +8     
==========================================
+ Hits        10415    10437      +22     
  Misses        535      535              
  Partials       17       17              
Flag Coverage Δ
test262 79.26% <71.42%> (-0.04%) ⬇️
tests 89.88% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
polyfill/lib/ecmascript.mjs 95.27% <100.00%> (+0.02%) ⬆️
polyfill/lib/regex.mjs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e58ba3...bc4b64c. Read the comment docs.

@ptomato
Copy link
Collaborator Author

ptomato commented Dec 3, 2021

Draft until presented at TC39

@ptomato ptomato marked this pull request as draft December 3, 2021 02:53
@ptomato ptomato added the spec-text Specification text involved label Dec 3, 2021
@ptomato
Copy link
Collaborator Author

ptomato commented Dec 17, 2021

This achieved consensus at the December 2021 TC39 meeting.

@ptomato ptomato marked this pull request as ready for review December 17, 2021 18:39
This prefix should always have been allowed according to ISO 8601. We had
neglected to implement it.

See: #1765
These now need to be parsed as follows:
Temporal.PlainDateTime.from(string).toPlainTime()

See #1765
ISO 8601 requires the 'T' prefix in cases where the time-only
representation is ambiguous.

Closes: #1765
@ptomato ptomato merged commit 514ede3 into main Dec 17, 2021
@ptomato ptomato deleted the 1765-time-only-repr branch December 17, 2021 20:15
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Dec 19, 2021
Slightly refector the implementation of tc39#1952 to enable a clearer
error message when the user tries to parse a date-only string
with `PlainTime.from`.

This is the same pattern that's used for other polyfill parsing:
`ParseISODateTime` is used for generic, regex-only parsing
while type-specific validation happens in the calling method,
e.g. `ParseTemporalTimeString` or `ParseTemporalZonedDateTimeString`.

Also add tests to verify that date strings are not allowed, and that
space is not accepted as a time designator prefix even though
space is accepted as a date/time separator.
Ms2ger pushed a commit that referenced this pull request Dec 20, 2021
Slightly refector the implementation of #1952 to enable a clearer
error message when the user tries to parse a date-only string
with `PlainTime.from`.

This is the same pattern that's used for other polyfill parsing:
`ParseISODateTime` is used for generic, regex-only parsing
while type-specific validation happens in the calling method,
e.g. `ParseTemporalTimeString` or `ParseTemporalZonedDateTimeString`.

Also add tests to verify that date strings are not allowed, and that
space is not accepted as a time designator prefix even though
space is accepted as a date/time separator.
justingrant added a commit to justingrant/temporal-polyfill that referenced this pull request Dec 20, 2021
Port of two overlapping PRs (the latter is a revision of the former):
* tc39/proposal-temporal#1952
* tc39/proposal-temporal#1986
justingrant added a commit to js-temporal/temporal-polyfill that referenced this pull request Jan 8, 2022
Port of two overlapping PRs (the latter is a revision of the former):
* tc39/proposal-temporal#1952
* tc39/proposal-temporal#1986
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 4, 2022
tc39/proposal-temporal#1952 added support for time
designator prefixes in PlainTime strings. This adds three tests to all
entry points that convert an ISO string to a PlainTime:

- no-implicit-midnight: ISO strings with only a date and no time are no
  longer accepted. Previously they were implicitly interpreted as 00:00.
- with-time-designator: Tests that various forms of string with time
  designator are correctly parsed.
- time-designator-required-for-disambiguation: Tests various cases where
  a string without a time designator is ambiguous and therefore the time
  designator is required, as well as various cases that implementations
  might assume are ambiguous but in fact are not.

This was a normative change that achieved consensus at the December 2021
TC39 meeting.
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 4, 2022
tc39/proposal-temporal#1952 added support for time
designator prefixes in PlainTime strings. This adds three tests to all
entry points that convert an ISO string to a PlainTime:

- no-implicit-midnight: ISO strings with only a date and no time are no
  longer accepted. Previously they were implicitly interpreted as 00:00.
- with-time-designator: Tests that various forms of string with time
  designator are correctly parsed.
- time-designator-required-for-disambiguation: Tests various cases where
  a string without a time designator is ambiguous and therefore the time
  designator is required, as well as various cases that implementations
  might assume are ambiguous but in fact are not.

This was a normative change that achieved consensus at the December 2021
TC39 meeting.
ptomato added a commit to ptomato/test262 that referenced this pull request Feb 5, 2022
tc39/proposal-temporal#1952 added support for time
designator prefixes in PlainTime strings. This adds three tests to all
entry points that convert an ISO string to a PlainTime:

- no-implicit-midnight: ISO strings with only a date and no time are no
  longer accepted. Previously they were implicitly interpreted as 00:00.
- with-time-designator: Tests that various forms of string with time
  designator are correctly parsed.
- time-designator-required-for-disambiguation: Tests various cases where
  a string without a time designator is ambiguous and therefore the time
  designator is required, as well as various cases that implementations
  might assume are ambiguous but in fact are not.

This was a normative change that achieved consensus at the December 2021
TC39 meeting.
rwaldron pushed a commit to tc39/test262 that referenced this pull request Feb 8, 2022
tc39/proposal-temporal#1952 added support for time
designator prefixes in PlainTime strings. This adds three tests to all
entry points that convert an ISO string to a PlainTime:

- no-implicit-midnight: ISO strings with only a date and no time are no
  longer accepted. Previously they were implicitly interpreted as 00:00.
- with-time-designator: Tests that various forms of string with time
  designator are correctly parsed.
- time-designator-required-for-disambiguation: Tests various cases where
  a string without a time designator is ambiguous and therefore the time
  designator is required, as well as various cases that implementations
  might assume are ambiguous but in fact are not.

This was a normative change that achieved consensus at the December 2021
TC39 meeting.
@FrankYFTang
Copy link
Contributor

Why do we need to introduce "CalendarDate" which is only used in an Assert?

$ egrep "CalendarDate[^a-zA-Z]" *
abstractops.html: CalendarDate :
abstractops.html: 1. Assert: ParseText(StringToCodePoints(isoString), |CalendarDate|) is a List of errors.

Could we remove that from that spec?

@ptomato
Copy link
Collaborator Author

ptomato commented May 9, 2022

This is done in #2187.

yjm123456789yjm pushed a commit to yjm123456789yjm/v8 that referenced this pull request Jul 18, 2022
Spec text:
https://tc39.es/proposal-temporal/#sec-temporal-iso8601grammar

Support 'T' prefix in time-only strings and require it in cases of ambiguity
Remove TemporalDateString and TemporalRelativeToString from parser
Change algorithm of ParseTemporalDateString

Related spec changes:
tc39/proposal-temporal#1952
tc39/proposal-temporal#2187


Bug: v8:11544
Change-Id: I7430afabb7dd78930b339b818bad7c7721decb99
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3636361
Reviewed-by: Shu-yu Guo <[email protected]>
Commit-Queue: Frank Tang <[email protected]>
Cr-Commit-Position: refs/heads/main@{#81792}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spec-text Specification text involved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PlainTime.from should throw with date-only strings like '2020-01-01', '2020-01', or '01-01'
5 participants