From ed3cd70f06ae0c7d922829d13d7cb84151655bfd Mon Sep 17 00:00:00 2001 From: Dan Ehrenberg Date: Mon, 28 Mar 2016 13:35:34 -0700 Subject: [PATCH] ECMA-402 v1 constructor compatibility semantics for DateTimeFormat --- spec/datetimeformat.html | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/spec/datetimeformat.html b/spec/datetimeformat.html index 0297363d..87a2daeb 100644 --- a/spec/datetimeformat.html +++ b/spec/datetimeformat.html @@ -296,6 +296,26 @@

ToLocalTime (date, calendar, timeZone)

It is recommended that implementations use the time zone information of the IANA Time Zone Database. + + +

UnwrapDateTimeFormat(nf)

+

+ The UnwrapDateTimeFormat abstract operation gets the underlying DateTimeFormat operation + for various methods which implement ECMA-402 v1 semantics for supporting initializing + existing Intl objects. +

+ + 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_. + +
+ @@ -314,6 +334,9 @@

Intl.DateTimeFormat ([ locales [ , options ]])

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_). @@ -448,7 +471,7 @@

get Intl.DateTimeFormat.prototype.format

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 (). 1. Let _bf_ be BoundFunctionCreate(_F_, _dft_, « »). @@ -462,7 +485,7 @@

get Intl.DateTimeFormat.prototype.format

Intl.DateTimeFormat.prototype.resolvedOptions ()

- 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.