Skip to content

Commit

Permalink
Add toLocaleString
Browse files Browse the repository at this point in the history
Also, because ecmarkup detects (correctly!) that
`ToIntlMathematicalValue` never fails, temporarily add an
attribute to the header disabling global checks. This check
should presumably be removed, but possibly not until our
changes get merged into 402.
  • Loading branch information
jessealama committed Jul 24, 2024
1 parent fadc80f commit 9c7b3ef
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
33 changes: 33 additions & 0 deletions intl.emu
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,37 @@
</p>
</emu-note>

<emu-clause id="sup-properties-of-the-number-prototype-object">
<h1>Properties of the Number Prototype Object</h1>

<p>
The following definition(s) refer to the abstract operation thisNumberValue as defined in es2024, <emu-xref href="#sec-properties-of-the-number-prototype-object"></emu-xref>.
</p>

<emu-clause id="sup-decimal128.prototype.tolocalestring">
<h1>Number.prototype.toLocaleString ( [ _locales_ [ , _options_ ] ] )</h1>

<p>
This definition supersedes the definition provided in es2024, <emu-xref href="#sec-decimal128.prototype.tolocalestring"></emu-xref>.
</p>

<p>
When the `toLocaleString` method is called with optional arguments _locales_ and _options_, the following steps are taken:
</p>

<emu-alg>
1. Let _numberFormat_ be ? Construct(%Intl.NumberFormat%, &laquo; _locales_, _options_ &raquo;).
1. Let _O_ be the *this* value.
1. If _O_ has the [[Decimal128Data]] internal slot, then
1. Let _d_ be _O_.[[Decimal128Data]].
1. Return FormatNumeric(_numberFormat_, _d_).
1. Otherwise:
1. Let _x_ be ? ThisNumberValue(_O_).
1. Return FormatNumeric(_numberFormat_, ! ToIntlMathematicalValue(_x_)).
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="numberformat-objects">
<h1>NumberFormat Objects</h1>
<emu-clause id="sec-numberformat-abstracts">
Expand All @@ -23,6 +54,8 @@
): either a normal completion containing an Intl mathematical value or a throw completion
</h1>
<dl class="header">
<dt>skip global checks</dt>
<dd>true</dd>
<dt>description</dt>
<dd>
It returns _value_ converted to an <dfn id="intl-mathematical-value">Intl mathematical value</dfn>, which is either a mathematical value<ins> a finite Decimal128 value,</ins> or one of ~positive-infinity~, ~negative-infinity~, ~not-a-number~, and ~negative-zero~.
Expand Down
7 changes: 7 additions & 0 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,13 @@ location: https://github.com/tc39/proposal-decimal/
</emu-note>
</emu-clause>

<emu-clause id="sec-decimal128.prototype.tolocalestring">
<h1>Decimal128.prototype.toLocaleString ( [ _reserved1_ [ , _reserved2_ ] ] )</h1>
<p>An ECMAScript implementation that includes the ECMA-402 Internationalization API must implement this method as specified in the ECMA-402 specification. If an ECMAScript implementation does not include the ECMA-402 API the following specification of this method is used:</p>
<p>This method produces a String value that represents this Number value formatted according to the conventions of the host environment’s current locale. This method is implementation-defined, and it is permissible, but not encouraged, for it to return the same thing as <emu-xref href="#sec-decimal128.prototype.tostring">`toString`</emu-xref>.</p>
<p>The meanings of the optional parameters to this method are defined in the ECMA-402 specification; implementations that do not include ECMA-402 support must not use those parameter positions for anything else.</p>
</emu-clause>

<emu-clause id="sec-decimal128.prototype.toexponential">
<h1>Decimal128.prototype.toExponential ( [ _options_ ] )</h1>
<p>This method generates a String representation of the current Decimal128 object, in exponential format (e.g., *"123e-4"*).</p>
Expand Down

0 comments on commit 9c7b3ef

Please sign in to comment.