You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_format_: a DateTime Format Record or a DateTime Range Pattern Format Record,
726
-
_pattern_: a Pattern String,
727
-
<del>_x_: a Number,</del>
728
-
<ins>_epochNanoseconds_: a BigInt,</ins>
729
-
): a List of Records with fields [[Type]] (a String) and [[Value]] (a String)
730
-
</h1>
731
-
<dlclass="header">
732
-
<dt>description</dt>
733
-
<dd>It <del>interprets _x_ as a time value as specified in es2024, <emu-xrefhref="#sec-time-values-and-time-range"></emu-xref>, and</del> creates the corresponding parts <ins>for the epoch time _epochNanoseconds_</ins> according to _pattern_ and to the effective locale and the formatting options of _dateTimeFormat_ and _format_.</dd>
734
-
</dl>
735
-
<emu-alg>
736
-
1. <del>Let _x_ be TimeClip(_x_).</del>
737
-
1. <del>If _x_ is *NaN*, throw a *RangeError* exception.</del>
738
-
1. Let _locale_ be _dateTimeFormat_.[[Locale]].
739
-
1. Let _nfOptions_ be OrdinaryObjectCreate(*null*).
1. Let _nf3_ be ! Construct(%Intl.NumberFormat%, « _locale_, _nf3Options_ »).
752
-
1. Let _tm_ be ToLocalTime(<del>ℤ(ℝ(_x_) × 10<sup>6</sup>)</del><ins>_epochNanoseconds_</ins>, _dateTimeFormat_.[[Calendar]], _dateTimeFormat_.[[TimeZone]]).
753
-
1. Let _patternParts_ be PartitionPattern(_pattern_).
754
-
1. Let _result_ be a new empty List.
755
-
1. For each Record { [[Type]], [[Value]] } _patternPart_ of _patternParts_, do
756
-
1. Let _p_ be _patternPart_.[[Type]].
757
-
1. If _p_ is *"literal"*, then
758
-
1. Append the Record { [[Type]]: *"literal"*, [[Value]]: _patternPart_.[[Value]] } to _result_.
759
-
1. Else if _p_ is *"fractionalSecondDigits"*, then
760
-
1.Assert:_format_ has a field [[fractionalSecondDigits]].
761
-
1. Let _v_ be _tm_.[[Millisecond]].
762
-
1. Set _v_ to floor(_v_ × 10<sup>( _fractionalSecondDigits_ - 3 )</sup>).
763
-
1. Let _fv_ be FormatNumeric(_nf3_, _v_).
764
-
1. Append the Record { [[Type]]: *"fractionalSecond"*, [[Value]]: _fv_ } to _result_.
765
-
1. Else if _p_ is *"dayPeriod"*, then
766
-
1.Assert:_format_ has a field [[dayPeriod]].
767
-
1. Let _f_ be _format_.[[dayPeriod]].
768
-
1. Let _fv_ be a String value representing the day period of _tm_ in the form given by _f_; the String value depends upon the implementation and the effective locale of _dateTimeFormat_.
769
-
1. Append the Record { [[Type]]: _p_, [[Value]]: _fv_ } to _result_.
770
-
1. Else if _p_ is *"timeZoneName"*, then
771
-
1.Assert:_format_ has a field [[timeZoneName]].
772
-
1. Let _f_ be _format_.[[timeZoneName]].
773
-
1. Let _v_ be _dateTimeFormat_.[[TimeZone]].
774
-
1. Let _fv_ be a String value representing _v_ in the form given by _f_; the String value depends upon the implementation and the effective locale of _dateTimeFormat_. The String value may also depend on the value of the [[InDST]] field of _tm_ if _f_ is *"short"*, *"long"*, *"shortOffset"*, or *"longOffset"*. If the implementation does not have such a localized representation of _f_, then use the String value of _v_ itself.
775
-
1. Append the Record { [[Type]]: _p_, [[Value]]: _fv_ } to _result_.
776
-
1. Else if _p_ matches a Property column of the row in <emu-xrefhref="#table-datetimeformat-components"></emu-xref>, then
777
-
1.Assert:_format_ has a field [[<_p_>]].
778
-
1. Let _f_ be _format_.[[<_p_>]].
779
-
1. Let _v_ be the value of _tm_'s field whose name is the Internal Slot column of the matching row.
780
-
1. If _p_ is *"year"* and _v_ ≤ 0, set _v_ to 1 - _v_.
781
-
1. If _p_ is *"month"*, set _v_ to _v_ + 1.
782
-
1. If _p_ is *"hour"* and _dateTimeFormat_.[[HourCycle]] is *"h11"* or *"h12"*, then
783
-
1. Set _v_ to _v_ modulo 12.
784
-
1. If _v_ is 0 and _dateTimeFormat_.[[HourCycle]] is *"h12"*, set _v_ to 12.
785
-
1. If _p_ is *"hour"* and _dateTimeFormat_.[[HourCycle]] is *"h24"*, then
786
-
1. If _v_ is 0, set _v_ to 24.
787
-
1. If _f_ is *"numeric"*, then
788
-
1. Let _fv_ be FormatNumeric(_nf_, _v_).
789
-
1. Else if _f_ is *"2-digit"*, then
790
-
1. Let _fv_ be FormatNumeric(_nf2_, _v_).
791
-
1. Let _codePoints_ be StringToCodePoints(_fv_).
792
-
1. Let _count_ be the number of elements in _codePoints_.
793
-
1. If _count_ > 2, then
794
-
1. Let _tens_ be _codePoints_[_count_ - 2].
795
-
1. Let _ones_ be _codePoints_[_count_ - 1].
796
-
1. Set _fv_ to CodePointsToString(« _tens_, _ones_ »).
797
-
1. Else if _f_ is *"narrow"*, *"short"*, or *"long"*, then
798
-
1. Let _fv_ be a String value representing _v_ in the form given by _f_; the String value depends upon the implementation and the effective locale and calendar of _dateTimeFormat_. If _p_ is *"month"*, then the String value may also depend on whether _format_.[[day]] is present. If the implementation does not have a localized representation of _f_, then use the String value of _v_ itself.
799
-
1. Append the Record { [[Type]]: _p_, [[Value]]: _fv_ } to _result_.
800
-
1. Else if _p_ is *"ampm"*, then
801
-
1. Let _v_ be _tm_.[[Hour]].
802
-
1. If _v_ is greater than 11, then
803
-
1. Let _fv_ be an implementation and locale dependent String value representing *"post meridiem"*.
804
-
1. Else,
805
-
1. Let _fv_ be an implementation and locale dependent String value representing *"ante meridiem"*.
806
-
1. Append the Record { [[Type]]: *"dayPeriod"*, [[Value]]: _fv_ } to _result_.
807
-
1. Else if _p_ is *"relatedYear"*, then
808
-
1. Let _v_ be _tm_.[[RelatedYear]].
809
-
1. Let _fv_ be FormatNumeric(_nf_, _v_).
810
-
1. Append the Record { [[Type]]: *"relatedYear"*, [[Value]]: _fv_ } to _result_.
811
-
1. Else if _p_ is *"yearName"*, then
812
-
1. Let _v_ be _tm_.[[YearName]].
813
-
1. Let _fv_ be an implementation and locale dependent String value representing _v_.
814
-
1. Append the Record { [[Type]]: *"yearName"*, [[Value]]: _fv_ } to _result_.
815
-
1. Else,
816
-
1. Let _unknown_ be an implementation-, locale-, and numbering system-dependent String based on <del>_x_</del><ins>_epochNanoseconds_</ins> and _p_.
817
-
1. Append the Record { [[Type]]: *"unknown"*, [[Value]]: _unknown_ } to _result_.
818
-
1. Return _result_.
819
-
</emu-alg>
820
-
821
-
<emu-note>
822
-
It is recommended that implementations use the locale and calendar dependent strings provided by the Common Locale Data Repository (available at <ahref="https://cldr.unicode.org/">https://cldr.unicode.org/</a>), and use CLDR *"abbreviated"* strings for DateTimeFormat *"short"* strings, and CLDR *"wide"* strings for DateTimeFormat *"long"* strings.
0 commit comments