1.1 Abstract Operations for DurationFormat Objects
Several DurationFormat algorithms use values from the following table, which provides internal slots and property names for Duration instances, and which is also used to key Records of templates to format individual Duration components:
A Duration Record is a Record value used to represent a Duration.
Duration Records have the fields listed in the Value Slot column of Table 1
1.1.2 ToIntegerWithoutRounding ( argument )
The abstract operation ToIntegerWithoutRounding takes argument argument (an ECMAScript language value). It converts argument to an integer, throwing if doing so would require rounding. It performs the following steps when called:
The abstract operation DurationRecordSign takes argument record (a Duration Record) and returns an integer. It returns 1 if the most significant non-zero field in record is positive, and -1 if the most significant non-zero field is negative. If all the fields are zero, it returns 0. It performs the following steps when called:
For each row of Table 1, except the header row, in table order, do
Let valueSlot be the Value Slot value of the current row.
Let v be record.[[<valueSlot>]].
If v < 0, return -1.
If v > 0, return 1.
1.1.5 IsValidDurationRecord ( record )
The abstract operation IsValidDurationRecord takes argument record (a Duration Record). It returns true if record represents a valid duration, and false otherwise. It performs the following steps when called:
1.1.6 GetDurationUnitOptions ( unit, options, baseStyle, stylesList, digitalBase, prevStyle )
The abstract operation GetDurationUnitOptions takes arguments unit (a String), options (an ECMAScript language value), baseStyle (a String), stylesList (a List of String), digitalBase (a String), and prevStyle (a String) and returns a Record with [[Style]] and [[Display]] fields. It extracts the relevant options for any given unit from an options bag and returns them as a Record. It performs the following steps when called:
Let style be ? GetOption(options, unit, "string", stylesList, undefined).
Let displayDefault be "always".
If style is undefined, then
If baseStyle is "digital", then
If unit is not one of "hours", "minutes", or "seconds", then
The abstract operation PartitionDurationFormatPattern takes arguments durationFormat (a DurationFormat) and duration (a Duration Record) and returns a List. It creates and returns a List with all the corresponding parts according to the effective locale and the formatting options of durationFormat. It performs the following steps when called:
Adding the time separator as a separate list element is wrong, because it will be formatted as a single entry through the list formatter resulting in strings like "12, :, 30, :, and 45".
1.2 The Intl.DurationFormat Constructor
The DurationFormat constructor is the %DurationFormat% intrinsic object and a standard built-in property of the Intl object. Behaviour common to all service constructor properties of the Intl object is specified in 9.1.
The value of the [[AvailableLocales]] internal slot is implementation defined within the constraints described in 9.1.
The value of the [[RelevantExtensionKeys]] internal slot is « "nu" ».
The value of the [[LocaleData]] internal slot is implementation defined within the constraints described in 9.1 and the following additional constraints for all locale values locale:
[[LocaleData]].[[<locale>]].[[nu]] must be a List as specified in 12.3.3.
[[LocaleData]].[[<locale>]].[[digitalFormat]] must be record with just one field, [[separator]], which contains the appropriate time unit separator for that locale.
It is recommended that implementations use the locale data provided by the Common Locale Data Repository (available at http://cldr.unicode.org/).
1.4 Properties of the Intl.DurationFormat Prototype Object
The Intl.DurationFormat prototype object is itself an ordinary object. %DurationFormatPrototype% is not an Intl.DurationFormat instance and does not have an [[InitializedDurationFormat]] internal slot or any of the other internal slots of Intl.DurationFormat instance objects.
The initial value of Intl.DurationFormat.prototype.constructor is the intrinsic object %DurationFormat%.
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.