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

Editorial: DRY refactor of time formatting #2629

Merged
merged 1 commit into from
Jul 17, 2023

Conversation

justingrant
Copy link
Collaborator

@justingrant justingrant commented Jul 15, 2023

This editorial PR removes redundant spec text dealing with time formatting:

  • Adds a new AO FormatTimeString, and calls it in TemporalTimeToString, TemporalDateTimeToString, and TimeString (the legacy date AO in 262).
  • Removes FormatSecondsStringPart and replaces it with a new AO FormatFractionalSeconds, and call it in FormatTimeString and TemporalDurationToString. The text of this new AO is aligned with similar text in GetOffsetStringFor in Normative: Limit offset time zones to minutes precision #2607.
  • Replaces sub-second formatting text in TemporalDurationToString with a call to FormatFractionalSeconds.
  • Aligns polyfill code to these spec changes.

Note that this PR doesn't touch spec text for formatting time zone offsets because there are several in-flight PRs dealing with offsets and I wanted to keep this PR merge-conflict-free. But once those PRs land and the dust settles, then I'll send another editorial PR to DRY offset string formatting too, by using FormatTimeString to replace bespoke formatting text for offsets.

@justingrant justingrant force-pushed the refactor-FormatSecondsStringPart branch from 630ff7a to 281f1bc Compare July 15, 2023 23:56
@codecov
Copy link

codecov bot commented Jul 15, 2023

Codecov Report

Merging #2629 (5fa747b) into main (736d6db) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2629      +/-   ##
==========================================
- Coverage   95.98%   95.96%   -0.02%     
==========================================
  Files          20       20              
  Lines       11574    11528      -46     
  Branches     2201     2193       -8     
==========================================
- Hits        11109    11063      -46     
  Misses        401      401              
  Partials       64       64              
Impacted Files Coverage Δ
polyfill/lib/ecmascript.mjs 98.25% <100.00%> (-0.01%) ⬇️
polyfill/lib/plaintime.mjs 98.21% <100.00%> (-0.02%) ⬇️

... and 2 files with indirect coverage changes

spec/abstractops.html Outdated Show resolved Hide resolved
@justingrant justingrant force-pushed the refactor-FormatSecondsStringPart branch 2 times, most recently from c409664 to 9f7e46d Compare July 17, 2023 04:53
@justingrant justingrant changed the title Editorial: refactor FormatSecondsStringPart Editorial: DRY refactor of time formatting Jul 17, 2023
@justingrant
Copy link
Collaborator Author

@gibson042 - I expanded the scope of this PR to align with your feedback in #2607 (comment). I added a new FormatTimeString AO that we can use for offset string formatting too once all the PR dust settles for those offset PRs. For now, this PR only touches non-offset time formatting to avoid merge conflicts with all the offset PRs, but I'll open a new PR later to have offset formatting use FormatTimeString too.

Want to re-review this PR? Thanks!

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.

Nice! I think I'd also like to see colon-vs.-empty-string separator parameterization (for FormatOffsetTimeZoneIdentifier), but that might be best placed in a followup. :shipit:

spec/duration.html Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
spec/abstractops.html Outdated Show resolved Hide resolved
@justingrant justingrant force-pushed the refactor-FormatSecondsStringPart branch from 9f7e46d to 045c2c9 Compare July 17, 2023 18:34
This editorial commit removes redundant spec text dealing with time
formatting:
* Adds a new AO FormatTimeString, and calls it in TemporalTimeToString,
  TemporalDateTimeToString, and TimeString (the legacy date AO in 262).
* Removes FormatSecondsStringPart and replaces it with a new AO
  FormatFractionalSeconds, and call it in FormatTimeString and
  TemporalDurationToString. The text of this new AO is aligned with
  similar text in GetOffsetStringFor in tc39#2607.
* Replaces sub-second formatting text in TemporalDurationToString
  with a call to FormatFractionalSeconds.
* Aligns polyfill code to these spec changes.
* Adjusts polyfill code in a few places to better match the spec.

Note that this commit doesn't touch spec text for formatting time zone
offsets because there are several in-flight PRs dealing with offsets
and I wanted to keep this PR merge-conflict-free. But once those
PRs land and the dust settles, then I'll send another editorial PR to
DRY offset string formatting too, by using FormatTimeString to replace
bespoke formatting text for offsets.
@justingrant justingrant force-pushed the refactor-FormatSecondsStringPart branch from 045c2c9 to 5fa747b Compare July 17, 2023 18:42
@justingrant
Copy link
Collaborator Author

I'd also like to see colon-vs.-empty-string separator parameterization (for FormatOffsetTimeZoneIdentifier), but that might be best placed in a followup. :shipit:

Yep, was gonna save that for the next PR after all the other normative offset-related PRs have landed.

I made all the edits you recommended, so gonna merge this now. Thanks for your help!

@justingrant justingrant merged commit c429eed into tc39:main Jul 17, 2023
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Jul 18, 2023
Simplify offset formatting by using FormatTimeString instead of bespoke
formatting logic. This commit completes the time-formatting refactor that
tc39#2629 started.
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Jul 18, 2023
Simplify offset formatting by using FormatTimeString instead of bespoke
formatting logic. This commit completes the time-formatting refactor that
tc39#2629 started.
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Jul 18, 2023
Simplify offset formatting by using FormatTimeString instead of bespoke
formatting logic. This commit completes the time-formatting refactor that
tc39#2629 started.
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Jul 18, 2023
Simplify offset formatting by using FormatTimeString instead of bespoke
formatting logic. This commit completes the time-formatting refactor that
tc39#2629 started.
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Jul 19, 2023
Simplify offset formatting by using FormatTimeString instead of bespoke
formatting logic. This commit completes the time-formatting refactor that
tc39#2629 started.
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Jul 19, 2023
Simplify offset formatting by using FormatTimeString instead of bespoke
formatting logic. This commit completes the time-formatting refactor that
tc39#2629 started.
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Jul 19, 2023
Simplify offset formatting by using FormatTimeString instead of bespoke
formatting logic. This commit completes the time-formatting refactor that
tc39#2629 started.
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Jul 19, 2023
Simplify offset formatting by using FormatTimeString instead of bespoke
formatting logic. This commit completes the time-formatting refactor that
tc39#2629 started.
justingrant added a commit to justingrant/proposal-temporal that referenced this pull request Jul 19, 2023
Simplify offset formatting by using FormatTimeString instead of bespoke
formatting logic. This commit completes the time-formatting refactor that
tc39#2629 started.
justingrant added a commit that referenced this pull request Jul 19, 2023
Simplify offset formatting by using FormatTimeString instead of bespoke
formatting logic. This commit completes the time-formatting refactor that
#2629 started.
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Sep 13, 2023
vinnydiehl pushed a commit to vinnydiehl/mozilla-unified that referenced this pull request Sep 14, 2023
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