Skip to content

Commit

Permalink
ECMA-402 v1 constructor compatibility semantics for DateTimeFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
littledan committed Mar 28, 2016
1 parent 21afa2f commit ed3cd70
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions spec/datetimeformat.html
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,26 @@ <h1>ToLocalTime (date, calendar, timeZone)</h1>
It is recommended that implementations use the time zone information of the IANA Time Zone Database.
</emu-note>
</emu-clause>

<emu-clause id="sec-unwrapdatetimeformat" aoid="UnwrapDateTimeFormat">
<h1>UnwrapDateTimeFormat(nf)</h1>
<p>
The UnwrapDateTimeFormat abstract operation gets the underlying DateTimeFormat operation
for various methods which implement ECMA-402 v1 semantics for supporting initializing
existing Intl objects.
</p>
<emu-alg>
1. If _nf_ does not have an [[initializedDateTImeFormat]] internal slot,
1. If ? InstanceofOperator(_nf_, %DateTimeFormat%),
1. Let _fallback_ be ? RequireObjectCoercible(Get(_nf_, Intl.[[FallbackSymbol]])).
1. If _fallback_ has an [[initializedDateTimeFormat]] internal slot,
1. Let _nf_ be _fallback_.
1. Else, throw a *TypeError* exception.
1. Else, throw a *TypeError* exception.
1. Return _nf_.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>

<emu-clause id="sec-intl-datetimeformat-constructor">
Expand All @@ -314,6 +334,9 @@ <h1>Intl.DateTimeFormat ([ locales [ , options ]])</h1>

<emu-alg>
1. If NewTarget is *undefined*, let _newTarget_ be the active function object, else let _newTarget_ be NewTarget.
1. If _this_ is not *undefined*, and ? InstanceofOperator(_this_, %DateTimeFormat%),
1. Perform ? DefineOwnPropertyOrThrow(_this_, Intl.[[FallbackSymbol]], { [[Value]]: Construct(%DateTimeFormat%, _locales_, _options_), [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
1. Return _this_.
1. Let _dateTimeFormat_ be ? OrdinaryCreateFromConstructor(_newTarget_, `"%DateTimeFormatPrototype%"`, « [[initializedIntlObject]], [[initializedDateTimeFormat]], [[locale]], [[calendar]], [[numberingSystem]], [[timeZone]], [[weekday]], [[era]], [[year]], [[month]], [[day]], [[hour]], [[minute]], [[second]], [[timeZoneName]], [[hour12]], [[hourNo0]], [[pattern]], [[boundFormat]] »).
1. Return ? InitializeDateTimeFormat(_dateTimeFormat_, _locales_, _options_).
</emu-alg>
Expand Down Expand Up @@ -448,7 +471,7 @@ <h1>get Intl.DateTimeFormat.prototype.format</h1>
<emu-alg>
1. Let _dtf_ be *this* value.
1. If Type(_dtf_) is not Object, throw a *TypeError* exception.
1. If _dtf_ does not have an [[initializedDateTimeFormat]] internal slot, throw a *TypeError* exception.
1. Let _dtf_ be ? UnwrapDateTimeFormat(_dtf_).
1. If the [[boundFormat]] internal slot of _dtf_ is *undefined*, then
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>).
1. Let _bf_ be BoundFunctionCreate(_F_, _dft_, « »).
Expand All @@ -462,7 +485,7 @@ <h1>get Intl.DateTimeFormat.prototype.format</h1>
<h1>Intl.DateTimeFormat.prototype.resolvedOptions ()</h1>

<p>
This function provides access to the locale and formatting options computed during initialization of the object.
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.
</p>

<p>
Expand Down

0 comments on commit ed3cd70

Please sign in to comment.