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: Improve PartitionDateTimeRangePattern #773

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Editorial: Consolidate practical-equality determination in PartitionD…
…ateTimeRangePattern
gibson042 committed Apr 11, 2023
commit fddd5a5fd80ed385057d4c5937b96aa21f1c28aa
21 changes: 7 additions & 14 deletions spec/datetimeformat.html
Original file line number Diff line number Diff line change
@@ -1067,30 +1067,23 @@ <h1>PartitionDateTimeRangePattern ( _dateTimeFormat_, _x_, _y_ )</h1>
1. If _dateFieldsPracticallyEqual_ is *true* and _patternContainsLargerDateField_ is *false*, then
Copy link
Member

Choose a reason for hiding this comment

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

It was a bit difficult to follow this change but now I'm confident the final result makes the flow simpler, thanks!

1. Set _rangePattern_ to _rp_.
1. If _fieldName_ is equal to [[AmPm]], then
1. Let _v1_ be _tm1_.[[Hour]].
1. Let _v2_ be _tm2_.[[Hour]].
1. If _v1_ is greater than 11 and _v2_ less or equal than 11, or _v1_ is less or equal than 11 and _v2_ is greater than 11, then
1. Set _dateFieldsPracticallyEqual_ to *false*.
1. If _tm1_.[[Hour]] is less than 12, let _v1_ be *"am"*; else let _v1_ be *"pm"*.
1. If _tm2_.[[Hour]] is less than 12, let _v2_ be *"am"*; else let _v2_ be *"pm"*.
1. Else if _fieldName_ is equal to [[DayPeriod]], then
1. Let _v1_ be a String value representing the day period of _tm1_; the String value depends upon the implementation and the effective locale of _dateTimeFormat_.
1. Let _v2_ be a String value representing the day period of _tm2_; the String value depends upon the implementation and the effective locale of _dateTimeFormat_.
1. If _v1_ is not equal to _v2_, then
1. Set _dateFieldsPracticallyEqual_ to *false*.
1. Else if _fieldName_ is equal to [[FractionalSecondDigits]], then
1. Let _fractionalSecondDigits_ be _dateTimeFormat_.[[FractionalSecondDigits]].
1. If _fractionalSecondDigits_ is *undefined*, then
1. Set _fractionalSecondDigits_ to 3.
1. Let _v1_ be _tm1_.[[Millisecond]].
1. Let _v2_ be _tm2_.[[Millisecond]].
1. Let _v1_ be floor(_v1_ &times; 10<sup>( _fractionalSecondDigits_ - 3 )</sup>).
1. Let _v2_ be floor(_v2_ &times; 10<sup>( _fractionalSecondDigits_ - 3 )</sup>).
1. If _v1_ is not equal to _v2_, then
1. Set _dateFieldsPracticallyEqual_ to *false*.
1. Let _exp_ be _fractionalSecondDigits_ - 3.
1. Let _v1_ be floor(_tm1_.[[Millisecond]] &times; 10<sup>_exp_</sup>).
1. Let _v2_ be floor(_tm2_.[[Millisecond]] &times; 10<sup>_exp_</sup>).
1. Else,
1. Let _v1_ be _tm1_.[[&lt;_fieldName_&gt;]].
1. Let _v2_ be _tm2_.[[&lt;_fieldName_&gt;]].
1. If _v1_ is not equal to _v2_, then
1. Set _dateFieldsPracticallyEqual_ to *false*.
1. If _v1_ is not equal to _v2_, then
1. Set _dateFieldsPracticallyEqual_ to *false*.
1. If _dateFieldsPracticallyEqual_ is *true*, then
1. Let _result_ be a new empty List.
1. Let _pattern_ be _dateTimeFormat_.[[Pattern]].