Skip to content

Commit 8775fdc

Browse files
committed
ECMA-402 v1 constructor compatibility semantics for DateTimeFormat
1 parent b97fabb commit 8775fdc

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

spec/datetimeformat.html

+35-3
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,27 @@ <h1>ToLocalTime ( _date_, _calendar_, _timeZone_ )</h1>
360360
It is recommended that implementations use the time zone information of the IANA Time Zone Database.
361361
</emu-note>
362362
</emu-clause>
363+
364+
<emu-clause id="sec-unwrapdatetimeformat" aoid="UnwrapDateTimeFormat">
365+
<h1>UnwrapDateTimeFormat( dtf )</h1>
366+
<p>
367+
The UnwrapDateTimeFormat abstract operation gets the underlying DateTimeFormat operation
368+
for various methods which implement ECMA-402 v1 semantics for supporting initializing
369+
existing Intl objects.
370+
</p>
371+
<emu-normative-optional><span class="normative-optional">Normative Optional</span><div class="normative-optional-contents">
372+
<emu-alg>
373+
1. If _dtf_ does not have an [[initializedDateTimeFormat]] internal slot and ? InstanceofOperator(_dtf_, %DateTimeFormat%),
374+
1. Let _dtf_ be ? RequireObjectCoercible(Get(_dtf_, Intl.[[FallbackSymbol]])).
375+
</emu-alg>
376+
</div></emu-normative-optional>
377+
<emu-alg>
378+
2. If _dtf_ does not have an [[initializedDateTimeFormat]] internal slot,
379+
1. Throw a *TypeError* exception.
380+
1. Return _dtf_.
381+
</emu-alg>
382+
</emu-clause>
383+
</emu-clause>
363384
</emu-clause>
364385

365386
<emu-clause id="sec-intl-datetimeformat-constructor">
@@ -379,7 +400,18 @@ <h1>Intl.DateTimeFormat ( [ _locales_ [ , _options_ ] ] )</h1>
379400
<emu-alg>
380401
1. If NewTarget is *undefined*, let _newTarget_ be the active function object, else let _newTarget_ be NewTarget.
381402
1. Let _dateTimeFormat_ be ? OrdinaryCreateFromConstructor(_newTarget_, `"%DateTimeFormatPrototype%"`, &laquo; [[initializedIntlObject]], [[initializedDateTimeFormat]], [[locale]], [[calendar]], [[numberingSystem]], [[timeZone]], [[weekday]], [[era]], [[year]], [[month]], [[day]], [[hour]], [[minute]], [[second]], [[timeZoneName]], [[hour12]], [[hourNo0]], [[pattern]], [[boundFormat]] &raquo;).
382-
1. Return ? InitializeDateTimeFormat(_dateTimeFormat_, _locales_, _options_).
403+
1. Perform ? InitializeDateTimeFormat(_dateTimeFormat_, _locales_, _options_).
404+
</emu-alg>
405+
<emu-normative-optional><span class="normative-optional">Normative Optional</span><div class="normative-optional-contents">
406+
<emu-alg>
407+
4. Let _this_ be the *this* value.
408+
1. If NewTarget is *undefined* and ? InstanceofOperator(_this_, %NumberFormat%),
409+
1. Perform ? DefineOwnPropertyOrThrow(_this_, Intl.[[FallbackSymbol]], { [[Value]]: _dateTimeFormat_, [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
410+
1. Return _this_.
411+
</emu-alg>
412+
</div></emu-normative-optional>
413+
<emu-alg>
414+
1. Return _dateTimeFormat_.
383415
</emu-alg>
384416
</emu-clause>
385417
</emu-clause>
@@ -512,7 +544,7 @@ <h1>get Intl.DateTimeFormat.prototype.format</h1>
512544
<emu-alg>
513545
1. Let _dtf_ be *this* value.
514546
1. If Type(_dtf_) is not Object, throw a *TypeError* exception.
515-
1. If _dtf_ does not have an [[initializedDateTimeFormat]] internal slot, throw a *TypeError* exception.
547+
1. Let _dtf_ be ? UnwrapDateTimeFormat(_dtf_).
516548
1. If _dtf_.[[boundFormat]] is *undefined*, then
517549
1. Let _F_ be a new built-in function object as defined in DateTime Format Functions (<emu-xref href="#sec-datetime-format-functions"></emu-xref>).
518550
1. Let _bf_ be BoundFunctionCreate(_F_, _dft_, &laquo; &raquo;).
@@ -545,7 +577,7 @@ <h1>Intl.DateTimeFormat.prototype.formatToParts ( [ _date_ ] )</h1>
545577
<h1>Intl.DateTimeFormat.prototype.resolvedOptions ()</h1>
546578

547579
<p>
548-
This function provides access to the locale and formatting options computed during initialization of the object.
580+
This function provides access to the locale and formatting options computed during initialization of the object. This function initially invokes the internal algorithm UnwrapDateTimeFormat to get the %DateTimeFormat% object on which to operate.
549581
</p>
550582

551583
<p>

0 commit comments

Comments
 (0)