Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
74 changes: 0 additions & 74 deletions intl.emu
Original file line number Diff line number Diff line change
Expand Up @@ -50,80 +50,6 @@
1. Return FormatNumeric(_numberFormat_, _numValue_).
</emu-alg>
</emu-clause>

<emu-clause id="sup-amount.prototype.convertto">
<h1>Amount.prototype.convertTo ( _options_ )</h1>

<p>This definition supersedes the definition provided in es2025, <emu-xref href="#sec-amount.prototype.convertto"></emu-xref>.</p>

<p>This function performs the following steps when called:</p>

<emu-alg>
1. Let _O_ be the *this* value.
1. Perform ? RequireInternalSlot(_O_, [[AmountValue]]).
1. Let _sourceUnit_ be _O_.[[Unit]].
1. If _sourceUnit_ is *undefined*, throw a *TypeError* exception.
1. Let _validatedOpts_ be ? GetAmountConvertToOptions(_options_).
1. Let _targetUnit_ be _validatedOpts_.[[Unit]].
1. Let _roundingMode_ be _validatedOpts_.[[RoundingMode]].
1. Let _roundingPriority_ be _validatedOpts_.[[RoundingPriority]].
1. Let _minFractionDigits_ be _validatedOpts_.[[MiniumumFractionDigits]].
1. Let _maxFractionDigits_ be _validatedOpts_.[[MaximumFractionDigits]].
1. Let _minSignificantDigits_ be _validatedOpts_.[[MinimumSignificantDigits]].
1. Let _maxSignificantDigits_ be _validatedOpts_.[[MaximumSignificantDigits]].
1. Let _locale_ be _validatedOpts_.[[Locale]].
1. Let _usage_ be _validatedOpts_.[[Usage]].
1. If _targetUnit_ is *undefined* and _locale_ is *undefined* and _usage_ is *undefined*, throw a *TypeError* exception.
1. Let _v_ be _O_.[[AmountValue]].
1. If _v_ is a Number, then
1. Let _sourceValue_ be _v_.
1. Else if _v_ is a BigInt, then
1. Let _sourceValue_ be 𝔽(ℝ(_v_)).
1. Else,
1. Assert: _v_ is a String.
1. Let _sourceValue_ be StringToNumber(_v_).
1. If _targetUnit_ is not *undefined*, then
1. If _locale_ is not *undefined* or _usage_ is not *undefined*, throw a *TypeError* exception.
1. Else,
1. Let _matcher_ be ? GetOption(_validatedOpts_, *"localeMatcher"*, ~string~, « *"lookup"*, *"best fit"* », *"best fit"*).
1. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locale_).
1. If _usage_ is *undefined*, set _usage_ to *"default"*.
1. Set _targetUnit_ to ? ResolveUnitPreference(_sourceUnit_, _sourceValue_, _requestedLocales_, _usage_, _matcher_).
1. Let _convertedValue_ be ? ConvertUnitValue(_sourceValue_, _sourceUnit_, _targetUnit_).
1. Let _result_ be OrdinaryObjectCreate(%Amount.prototype%, « [[AmountValue]], [[Unit]] »).
1. TODO Let _intlObject_ be an Object suitable for use as the first argument of a call to <emu-xref href="#sec-formatnumerictostring">FormatNumericToString</emu-xref> that uses _minSignificantDigits_, _maxSignificantDigits_, _minFractionDigits_, _maxFractionDigits_, _roundingPriority_, and _roundingMode_.
1. Let _formatted_ be FormatNumericToString(_intlObject_, _convertedValue_, 0).
1. Set _result_.[[AmountValue]] to _formatted_.[[FormattedString]].
1. Set _result_.[[Unit]] to _targetUnit_.
1. Return _result_.
</emu-alg>
</emu-clause>

<emu-clause id="sec-resolveunitpreference" type="implementation-defined abstract operation">
<h1>ResolveUnitPreference (
_sourceUnit_: a String,
_sourceValue_: a Number,
_requestedLocales_: a Language Priority List,
_usage_: a String,
_localeMatcher_: a String,
): either a normal completion containing a String or a throw completion
</h1>
<dl class="header">
<dt>description</dt>
<dd>It determines the preferred target unit for _sourceUnit_ in the locale best matching _requestedLocales_ and _usage_ context, based on CLDR unit preferences data.</dd>
</dl>
<emu-alg>
1. Let _sourceConv_ be ? GetUnitConversionFactor(_sourceUnit_).
1. Let _category_ be _sourceConv_.[[Category]].
1. Let _availableLocales_ be the Available Locales List for locales for which the <code>&lt;unitPreferences></code> element data of <a href="https://unicode.org/reports/tr35/tr35-info.html#Unit_Preferences">UTS #35 Part 6 Supplemental, Unit Preferences</a> includes data.
1. Let _localeData_ be a Record whose field names are the elements of _availableLocales_ and whose values are Records.
1. Let _r_ be ResolveLocale(_availableLocales_, _requestedLocales_, the Record { [[localeMatcher]]: _localeMatcher_ }, « », _localeData_).
1. Let _locale_ be _r_.[[Locale]].
1. Let _preferredUnit_ be the preferred unit for _category_, _locale_, _usage_, and _sourceValue_ as specified by the <code>&lt;unitPreferences></code> element data of <a href="https://unicode.org/reports/tr35/tr35-info.html#Unit_Preferences">UTS #35 Part 6 Supplemental, Unit Preferences</a>.
1. If _preferredUnit_ is *undefined*, throw a *RangeError* exception.
1. Return _preferredUnit_.
</emu-alg>
</emu-clause>
</emu-clause>

<emu-clause id="sec-amount-intl-normative-references">
Expand Down
Loading
Loading