Draft ECMA-402 / July 10, 2026

ECMAScript® 2027 Internationalization API Specification

この仕様への貢献について

この仕様は、ECMAScriptコミュニティの協力のもと、GitHubで開発されています。仕様の開発に貢献する方法はいくつかあります:

コロフォンを参照して、このドキュメントの作成方法について詳しく知ることができます。

イントロダクション

この仕様のソースは https://github.com/tc39/ecma402 にあります。

ECMAScript 2027 国際化 API 仕様(ECMA-402 第14版)は、ECMA-262 を補完する主要な言語依存機能を提供します。その機能は、Unicode の国際化コンポーネント(ICU)ライブラリhttps://unicode-org.github.io/icu-docs/)、.NET フレームワーク、Java プラットフォームなどの確立された国際化 API から選択されています。

第1版 API は、Nebojša Ćirić と Jungshik Shin の提案に基づき、2010年9月に Ecma TC39 によって設立されたアドホックグループによって開発されました。

第2版 API は、2015年6月の総会で ECMAScript 第6版の補完として採用されました。

第3版 API は、Ecma TC39 の新しい年間リリースサイクルとオープン開発プロセスの下で最初にリリースされた版です。ECMA-402 ソースドキュメントからプレーンテキストのソースドキュメントが作成され、GitHub 上でのさらなる開発の基盤となりました。この標準の開発期間中、バグ修正、編集修正、その他の改善を表す多数のプルリクエストやイシューが提出されました。さらに、Ecmarkup、Ecmarkdown、Grammarkdown などの多数のソフトウェアツールがこの作業を支援するために開発されました。

多くの組織を代表する多数の個人が、Ecma TC39 内でこの版および以前の版の開発に非常に重要な貢献をしました。また、TC39 の ECMAScript 活動を支援する活発なコミュニティが生まれました。このコミュニティは、多くのドラフトをレビューし、数多くのバグレポートを提出し、実装実験を行い、テストスイートを提供し、ECMAScript 国際化について世界中の開発者コミュニティを教育しました。残念ながら、この活動に貢献したすべての人や組織を特定して認識することは不可能です。

Norbert Lindenberg
ECMA-402 第1版 プロジェクトエディター

Rick Waldron
ECMA-402 第2版 プロジェクトエディター

Caridy Patiño
ECMA-402 第3版、第4版、第5版 プロジェクトエディター

Caridy Patiño, Daniel Ehrenberg, Leo Balter
ECMA-402 第6版 プロジェクトエディター

Leo Balter, Valerie Young, Isaac Durazo
ECMA-402 第7版 プロジェクトエディター

Leo Balter, Richard Gibson
ECMA-402 第8版 プロジェクトエディター

Leo Balter, Richard Gibson, Ujjwal Sharma
ECMA-402 第9版 プロジェクトエディター

Richard Gibson, Ujjwal Sharma
ECMA-402 第10版 プロジェクトエディター

Richard Gibson, Ujjwal Sharma
ECMA-402 第11版 プロジェクトエディター

Ben Allen, Richard Gibson, Ujjwal Sharma
ECMA-402 第12版 プロジェクトエディター

Ben Allen, Richard Gibson, Ujjwal Sharma
ECMA-402 第13版 プロジェクトエディター

Ben Allen, Richard Gibson, Ujjwal Sharma
ECMA-402 第14版 プロジェクトエディター

1 スコープ

この標準は、異なる言語や国で使用される言語的および文化的慣習に適応する必要があるプログラムをサポートするECMAScriptオブジェクトのアプリケーションプログラミングインターフェイスを定義します。

2 適合性

本仕様の適合する実装は、ECMA-262に適合しなければならず、本仕様で記述されたすべてのオブジェクト、プロパティ、関数、およびプログラムのセマンティクスを提供し、サポートしなければならない。本仕様のいかなる内容も、ECMA-262で禁止されている動作を許可することを意図しておらず、そのような矛盾は編集上の誤りとみなされ、ECMA-262の制約を上書きするものではない。

適合する実装は、本仕様で記述されていない追加のオブジェクト、プロパティ、関数を提供することが許可されている。特に、適合する実装は、本仕様で記述されていないプロパティや、そのプロパティの値を、本仕様で記述されたオブジェクトに対して提供することが許可されている。適合する実装は、本仕様で定義された関数にオプションの引数を追加することは許可されていない。

適合する実装は、以下のoptions引数のプロパティについて、追加の値を受け入れ、その場合はRangeErrorをスローする代わりに実装依存の動作をすることが許可されている:

3 規範参照

以下の参照文書は本書の適用に必要です。日付付き参照の場合、引用された版のみが適用されます。日付なし参照の場合、参照文書の最新版(改訂や修正を含む)が適用されます。

ECMAScript 2027 言語仕様 (ECMA-262 第18版、または後継)。
https://www.ecma-international.org/publications/standards/Ecma-262.htm

Note
本仕様のこれらの参照に依存するセクションは、最善の努力で更新されますが、これらの標準と最新状態であることは保証されません。

4 概要

このセクションは非規範的です。

4.1 国際化、ローカライゼーション、グローバリゼーション

ソフトウェアの国際化とは、異なる言語を話し、異なる文化的期待を持つユーザーのニーズをサポートする、または容易に適応できるように設計し、世界中のユーザー間のコミュニケーションを可能にすることを意味します。ローカライゼーションは、特定の言語や文化への実際の適応です。ソフトウェアのグローバリゼーションは、一般的に国際化とローカライゼーションの組み合わせと理解されています。グローバリゼーションは、すべての言語をサポートするテキスト表現を使用し、言語、国、タイムゾーン、その他関連するパラメータを識別する標準識別子を使用することから始まります。ユーザーが理解できるユーザーインターフェース言語やデータ表示を使用し、最終的にはユーザーの言語、文化、環境に特化した製品適応が必要となる場合もあります。

ECMA-262はテキスト表現にUnicodeを使用し、いくつかの言語依存関数を提供することで基盤を築いていますが、これらの関数の動作をアプリケーションが制御することはほとんどできません。本仕様は、その基盤の上にカスタマイズ可能な言語依存機能のセットを提供します。このAPIは、国際化されていないアプリケーションにも有用であり、単一の言語や地域のみを対象とする場合でも、その言語や地域を適切にサポートする必要があります。しかし、このAPIは複数の言語や地域を同時にサポートするアプリケーションも可能にし、サーバー環境などで必要となる場合もあります。

4.2 API概要

本仕様は、ECMA-262を補完するために設計されており、主要な言語依存機能を提供し、実装に全体または一部を追加できます。本仕様は、ECMAScriptコードから観察可能な新しい言語値([[FallbackSymbol]]内部スロットの値や、%Intl%からプロパティアクセスによって到達可能な値の集合など)を導入し、またECMA-262で規定されている一部の関数の定義を改良します(下記参照)。どちらのカテゴリも、ECMA-262で定義された値やインターフェースに対して許可されている動作を禁止するものではなく、本仕様の採用をどの実装でも可能にするためです。

本仕様は、ほとんどのアプリケーションで必要とされる主要な言語依存機能を提供します:ロケールの選択と検査、文字列比較(照合)と大文字小文字変換、複数形ルール、テキスト分割、数値、絶対・相対日時、期間、リストの書式化。ECMA-262はこの基本機能のための関数を提供しています(Array.prototype上:toLocaleStringString.prototype上:localeComparetoLocaleLowerCasetoLocaleUpperCaseNumber.prototype上:toLocaleStringDate.prototype上:toLocaleStringtoLocaleDateStringtoLocaleTimeString)、実際の動作はほとんど実装依存です。本仕様は、追加機能、言語や動作の詳細の制御、必要な機能のより完全な仕様を提供します。

アプリケーションはAPIを2つの方法で利用できます:

  1. サービスコンストラクタを直接使用してオブジェクトを構築し、優先言語リストと動作を構成するオプションを指定します。オブジェクトは主要な関数(compareselectformatなど)を提供し、繰り返し呼び出すことができます。また、resolvedOptions関数も提供され、アプリケーションはオブジェクトの正確な構成を知ることができます。
  2. 上記のECMA-262の関数を間接的に使用します。照合や書式化関数は、本仕様でCollator、NumberFormat、DateTimeFormatコンストラクタと同じ引数を受け入れ、compareやformatメソッドと同じ結果を生成するように再仕様化されています。大文字小文字変換関数は、優先言語リストを受け入れるように再仕様化されています。

Intlオブジェクトは、本仕様で定義されたすべての機能をまとめるために使用され、名前の衝突を避けます。

Note
APIには様々なフォーマッターが含まれていますが、解析機能は提供していません。これは意図的であり、利点と欠点を十分に検討した上で決定されています。詳細はissue trackerの議論を参照してください。

4.3 APIの規則

すべてのIntlコンストラクタは、クラスによって定義されたかのように動作し、関数として呼び出された場合(NewTargetなし)にはTypeError例外をスローするべきです。過去の版との互換性のため、これは%Intl.Collator%%Intl.DateTimeFormat%%Intl.NumberFormat%には適用されません。これらは関数として呼び出された場合、新しいオブジェクトを構築して返します。

Note
ECMA 402 v1では、Intlコンストラクタは既存オブジェクトをレシーバーとして呼び出すことで、関連する内部スロットを追加し、そのオブジェクトをクラスのインスタンスに変換するモードをサポートしていました。ECMA 402 v2では、この機能は削除され、既存オブジェクトへの内部スロット追加を避けるためでした。ECMA 402 v3では、この機能が「規範的オプション」として再追加され、コンストラクタが呼び出された場合、任意のオブジェクトに基底Intlインスタンスをチェーンするモードになりました。詳細はIssue 57を参照してください。

4.4 実装依存性

国際化の性質上、本仕様はいくつかの詳細を実装依存とせざるを得ません:

  • 十分なローカライゼーションを備えた実装がサポートするロケールの集合:言語学者は数千の人間言語を記述しており、IANA Language Subtag Registryにはロケール識別子の基礎となる7000以上の主要言語サブタグが含まれています。Common Locale Data Repositoryのような大規模なロケールデータコレクションでも、すべての言語や地域的・方言的変種のごく一部しかカバーしていません。リソース制約のあるデバイスを対象とする実装では、さらにサブセットを減らす必要がある場合もあります。
  • 書式パターンなどのローカライゼーションの正確な形式:多くの場合、ロケール依存の慣習は標準化されておらず、異なる形式が並存したり、時代によって変化します。異なる国際化ライブラリは異なる形式を実装している場合があり、どれも実際には間違いではありません。このAPIを既存ライブラリの上に実装できるようにするため、こうした違いを許容する必要があります。
  • Unicodeのサブセット:照合などの操作は、Unicode文字セット全体を含む文字列で動作できますが、Unicode標準もECMAScript標準も、実装がUnicode文字セットのサブセットに機能を限定することを許容しています。さらに、ロケール慣習は通常、Unicode文字セット全体ではなく、そのロケールに関連する文字についてのみ動作を規定しています。Unicode Collation Algorithmは、Unicode文字セット全体のデフォルト照合順序とローカル慣習へのテーラリングを組み合わせていますが、サブセットやテーラリングによって動作の違いが生じます。

ブラウザ実装では、特定のオリジンに対して表示されるロケール、通貨、カレンダー、番号体系などの初期集合は、同じユーザーエージェント文字列(エンジンとプラットフォームバージョン)を共有するすべてのユーザーで同一でなければなりません。さらに、これらの集合の動的な変更によってユーザーが互いに識別可能になってはなりません。この制約は、国際化に内在するフィンガープリントリスクを減らすために課されており、将来の改訂で緩和される可能性があります。この制約の結果、オンデマンドでロケールインストールを許可するブラウザ実装が、特定のオリジンから新しいロケールのインストールを必要とするリクエストを初めて受け取った場合、そのロケールが既にインストールされているかどうかを明らかにしてはなりません。

本仕様全体で、実装依存・ロケール依存の動作はILD、実装依存・ロケール依存・番号体系依存の動作はILNDと呼ばれます。

4.4.1 実装間の互換性

ECMA 402は、その関数で使用されるデータのスキーマを記述します。 内部データは実装依存であり、時間とともに変化し、実装ごとに異なることが予想されます。 この違いはプログラマーにとって可視であり、特定の出力に依存するプログラムを構築することも可能です。 しかし、本仕様は、実装間で適切に記述されたプログラムが動作するための合理的な制約を記述しようとしています。 実装は、言語データの調和に向けた努力を継続することが奨励されます。

5 表記規則

この規格は、ECMA-262の表記規則のサブセットを使用します:

Note
ECMA-262で説明されているように、アルゴリズムはECMAScript構造の必要な意味論を正確に指定するために使用されますが、特定の実装技術の使用を示唆するものではありません。内部スロットはオブジェクト値の意味論を定義するために使用されますが、APIの一部ではありません。純粋に説明目的で定義されています。APIの実装は、ここで説明されている方法で内部スロットを生成し操作するかのように振る舞わなければなりません。

レコード仕様タイプへの拡張として、記法「[[<name>]]」は、変数nameによって与えられる名前のフィールドを示します。nameはString値でなければなりません。例えば、変数sが値"a"を持つ場合、[[<s>]]はフィールド[[a]]を示します。

この仕様は、規範的オプションで区切られたブロックを使用して、ECMA 262のAnnex Bの意味を示します。つまり、規範的オプションのセクションは、ECMAScriptホストがウェブブラウザの場合に必須です。セクションの内容は規範的ですが、ECMAScriptホストがウェブブラウザでない場合はオプションです。

5.1 よく知られた組み込みオブジェクト

次の表は、Well-Known Intrinsic Objectsで定義されたよく知られた組み込みオブジェクトの表を拡張します。

Table 1: よく知られた組み込みオブジェクト(拡張)
組み込み名 グローバル名 ECMAScript言語の関連付け
%Intl% Intl Intlオブジェクト (8)
%Intl.Collator% Intl.Collator Intl.Collatorコンストラクター (10.1)
%Intl.DateTimeFormat% Intl.DateTimeFormat Intl.DateTimeFormatコンストラクター (11.1)
%Intl.DisplayNames% Intl.DisplayNames Intl.DisplayNamesコンストラクター (12.1)
%Intl.DurationFormat% Intl.DurationFormat Intl.DurationFormatコンストラクター (13.1)
%Intl.ListFormat% Intl.ListFormat Intl.ListFormatコンストラクター (14.1)
%Intl.Locale% Intl.Locale Intl.Localeコンストラクター (15.1)
%Intl.NumberFormat% Intl.NumberFormat Intl.NumberFormatコンストラクター (16.1)
%Intl.PluralRules% Intl.PluralRules Intl.PluralRulesコンストラクター (17.1)
%Intl.RelativeTimeFormat% Intl.RelativeTimeFormat Intl.RelativeTimeFormatコンストラクター (18.1)
%Intl.Segmenter% Intl.Segmenter Intl.Segmenterコンストラクター (19.1)
%IntlSegmentIteratorPrototype% セグメントイテレータオブジェクトのプロトタイプ (19.6.2)
%IntlSegmentsPrototype% セグメントオブジェクトのプロトタイプ (19.5.2)

6 ロケール、通貨、タイムゾーン、測定単位、番号体系、照合順序、およびカレンダーの識別

この節は、ロケール、通貨、タイムゾーン、測定単位、番号体系、照合順序、カレンダー、およびパターン文字列を識別するためにこの仕様で使用されるString値について述べる。

6.1 大文字小文字の区別とケースマッピング

ロケール、通貨、用字、およびタイムゾーンを識別するために使用されるString値は、ASCIIの大文字小文字を区別しない方法で解釈される。すなわち、コード単位0x0041から0x005A(Unicode文字LATIN CAPITAL LETTER AからLATIN CAPITAL LETTER Zに対応)を、対応するコード単位0x0061から0x007A(Unicode文字LATIN SMALL LETTER AからLATIN SMALL LETTER Zに対応)と同等として扱う(いずれも両端を含む)。その他のケースフォールディング同値性は適用されない。

Note
例えば、"ß" (U+00DF)は"SS" (U+0053, U+0053)に一致してはならず、またそれへマッピングされてはならない。"ı" (U+0131)は"I" (U+0049)に一致してはならず、またそれへマッピングされてはならない。

String値stringASCII-uppercaseは、string内のASCII小文字コード単位(0x0061から0x007Aまで、両端を含む)の各出現を、対応するASCII大文字コード単位(0x0041から0x005Aまで、両端を含む)に置き換え、他のすべてのコード単位を保持することによりstringから導出されるString値である。

String値stringASCII-lowercaseは、string内のASCII大文字コード単位(0x0041から0x005Aまで、両端を含む)の各出現を、対応するASCII小文字コード単位(0x0061から0x007Aまで、両端を含む)に置き換え、他のすべてのコード単位を保持することによりstringから導出されるString値である。

String値Aは、AのASCII-uppercaseがBのASCII-uppercaseとまったく同じコード単位列である場合、String値Bに対するASCII-case-insensitive matchである。Unicodeコードポイント列Aは、BCodePointsToString(A)に対するASCII-case-insensitive matchである場合、Bに対するASCII-case-insensitive matchである。

6.2 言語タグ

この仕様は、Unicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformanceで定義されるUnicode BCP 47ロケール識別子を使用してロケールを識別し、そのアルゴリズムはSection 3 Unicode Language and Locale Identifiersの文法で定義されるUnicodeロケール非終端記号を参照する。 そのような各識別子は言語タグとも呼ぶことができ、実際にはBCP 47でその用語が使用される意味で有効な言語タグである。 Unicode Technical Standard #35 Part 1 Core, Section 3.2.1 Canonical Unicode Locale Identifiersで規定される正準形式のロケール識別子は、「Unicode正規化済みロケール識別子」と呼ばれる。

ロケール識別子は、大文字小文字を区別しないUnicode Basic Latin英数字のサブタグ"-"(U+002D HYPHEN-MINUS)文字で区切ったものからなり、単一文字のサブタグは「singletonサブタグ」と呼ばれる。 Unicode Technical Standard #35 Part 1 Core, Section 3.6 Unicode BCP 47 U Extensionサブタグ列は広く使用され、「Unicodeロケール拡張シーケンス」という用語は、言語タグのうちunicode_locale_extensions Unicodeロケール非終端記号により一致させることができ、かつ"-x-…"私用サブタグ列の一部ではない最長のsubstringを表す。これは"-u-"で始まり、直後に続くsingletonサブタグでないすべてのサブタグを、それらの前の"-"区切り文字とともに含む。例えば、"en-US-u-fw-mon-x-u-ex-foobar"Unicodeロケール拡張シーケンス"-u-fw-mon"である。

すべての整形式言語タグは、この仕様で定義されるAPIでの使用に適しているが、実装は、それらを検証するためにUnicode Common Locale Data Repository(CLDR)データを使用することを要求されない。実装が十分なローカライズを伴ってサポートするロケール、したがって言語タグの集合は実装定義である。Intlコンストラクタは、要求された言語タグをそれぞれの実装がサポートするロケールへ対応付ける。

6.2.1 IsWellFormedLanguageTag ( locale )

The abstract operation IsWellFormedLanguageTag takes argument locale (String) and returns Boolean. localeunicode_bcp47_locale_idの整形式性制約に適合する整形式言語タグであるかどうかを判定する。localeが意味のある意味論を伝えるかどうかは考慮せず、エイリアス化されたサブタグとその推奨置換サブタグを区別せず、正準の大文字小文字やサブタグ順序も要求しない。 It performs the following steps when called:

  1. lowerLocalelocaleASCII-lowercaseとする。
  2. lowerLocaleunicode_locale_id Unicodeロケール非終端記号により一致させることができないならば、falseを返す。
  3. lowerLocaleUnicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformanceで述べられる後方互換性構文のいずれかを使用するならば、falseを返す。
  4. baseNameGetLocaleBaseName(lowerLocale)とする。
  5. variantsGetLocaleVariants(baseName)とする。
  6. variantsundefinedでないならば、
    1. variantsが重複サブタグを含むならば、falseを返す。
  7. extensionsbaseNameの後に続くlowerLocaleの接尾部とする。
  8. NOTE: pu_extensions Unicodeロケール非終端記号により一致する"-x-…"私用サブタグ列は無視されなければならないが、後続内容を伴わない孤立した末尾の"x"サブタグは、以下の検査には影響しない。
  9. puIndexStringIndexOf(extensions, "-x-", 0)とする。
  10. puIndexnot-foundでないならば、extensionsextensionsの0からpuIndexまでの部分文字列に設定する。
  11. extensionsが空のStringでないならば、
    1. extensionsが重複するsingletonサブタグを含むならば、falseを返す。
    2. transformExtensionを、transformed_extensions Unicodeロケール非終端記号により一致するextensionsの最長のsubstringとする。そのようなsubstringがない場合は、trueを返す。
    3. Assert: transformExtensionの0から3までの部分文字列は"-t-"である。
    4. tPrefixtransformExtensionの3からの部分文字列とする。
    5. tlangを、tlang Unicodeロケール非終端記号により一致するtPrefixの最長の接頭部とする。そのような接頭部がない場合は、trueを返す。
    6. tlangVariantsGetLocaleVariants(tlang)とする。
    7. tlangVariantsundefinedでないならば、
      1. tlangVariantsが重複サブタグを含むならば、falseを返す。
  12. trueを返す。

6.2.2 CanonicalizeUnicodeLocaleId ( locale )

The abstract operation CanonicalizeUnicodeLocaleId takes argument locale (言語タグ) and returns Unicode正規化済みロケール識別子. localeの正準かつ大文字小文字を正規化した形式を返す。 It performs the following steps when called:

  1. localeIdを、Unicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalizationに従ってlocaleを正準形式へ変換するためにProcessing LocaleIdsアルゴリズムを実行した結果のString値とする。
  2. localeIdUnicodeロケール拡張シーケンスであるsubstringを含むならば、
    1. extensionを、localeId内のUnicodeロケール拡張シーケンスsubstringからなるString値とする。
    2. newExtension"-u"とする。
    3. componentsUnicodeExtensionComponents(extension)とする。
    4. components.[[Attributes]]の各要素attrについて、次を行う:
      1. newExtensionnewExtension"-"、およびattrの文字列連結に設定する。
    5. components.[[Keywords]]の各Record { [[Key]], [[Value]] } keywordについて、次を行う:
      1. newExtensionnewExtension"-"、およびkeyword.[[Key]]の文字列連結に設定する。
      2. keyword.[[Value]]が空のStringでないならば、
        1. newExtensionnewExtension"-"、およびkeyword.[[Value]]の文字列連結に設定する。
    6. Assert: newExtension"-u"でない。
    7. localeIdを、substring extensionの最初の出現をnewExtensionで置き換えたlocaleIdのコピーに設定する。
  3. localeIdを返す。
Note
手順2は、返される言語タグ内のUnicodeロケール拡張シーケンスが次を含むことを保証する:
  • 入力内で重複した任意の属性のうち最初のインスタンスのみ、および
  • 入力内の所与のキーについて最初のkeywordのみ。

6.2.3 DefaultLocale ( )

The implementation-defined abstract operation DefaultLocale takes no arguments and returns Unicode正規化済みロケール識別子. 返されるString値は、ホスト環境の現在のロケールに対する整形式(6.2.1)かつ正規化済み(6.2.2)の言語タグを表す。これはUnicodeロケール拡張シーケンスを含んではならない。

Note
返される値はフィンガープリンティングベクトルとなる可能性がある。ブラウザー環境では、追加の識別情報を提供することを避けるため、navigator.languageと一致すべきである。

6.3 通貨コード

この仕様は、ISO 4217で定義される3文字通貨コードを使用して通貨を識別する。それらの正準形式は大文字である。

すべての整形式3文字ISO 4217通貨コードが許容される。ただし、ローカライズされた通貨記号が利用可能な通貨コードと言語タグの組み合わせの集合は実装依存である。ローカライズされた通貨記号が利用可能でない場合、ISO 4217通貨コードが整形に使用される。

6.3.1 IsWellFormedCurrencyCode ( currency )

The abstract operation IsWellFormedCurrencyCode takes argument currency (String) and returns Boolean. currency引数が整形式3文字ISO 4217通貨コードを表すことを検証する。 It performs the following steps when called:

  1. currencyの長さが3でないならば、falseを返す。
  2. normalizedcurrencyASCII-uppercaseとする。
  3. normalizedが0x0041から0x005A(Unicode文字LATIN CAPITAL LETTER AからLATIN CAPITAL LETTER Zに対応)の範囲外のコード単位を含むならば、falseを返す。
  4. trueを返す。

6.4 AvailableCanonicalCurrencies ( )

The implementation-defined abstract operation AvailableCanonicalCurrencies takes no arguments and returns StringのList. 返されるListは辞書式コード単位順序に従ってソートされ、実装がIntl.DisplayNamesおよびIntl.NumberFormatオブジェクトの機能を提供する通貨を識別する、一意で整形式かつ大文字に正規化された3文字ISO 4217通貨コードを含む。

6.5 IANA Time Zone Databaseの使用

この仕様を採用する実装は、タイムゾーンを認識していなければならない。すなわち、利用可能な名前付きタイムゾーン識別子、およびECMAScriptの計算と整形で使用されるデータを提供するために、IANA Time Zone Database https://www.iana.org/time-zones/を使用しなければならない。 この節は、タイムゾーンを認識する実装によってIANA Time Zone Databaseがどのように使用されるべきかを定義する。 Stringは、IANA Time Zone Database内のZone名またはLink名でない限り、利用可能な名前付きタイムゾーン識別子であってはならない。 ECMAScript組込みオブジェクトによって返される利用可能な名前付きタイムゾーン識別子は、IANA Time Zone Databaseで見られる大文字小文字を使用しなければならない。

IANA Time Zone Database内の各Zoneはprimary time zone identifierでなければならず、IANA Time Zone Database内の各Link名は、AvailableNamedTimeZoneIdentifiersで実装される次の例外を伴って、対応するZone名に解決されるnon-primary time zone identifierでなければならない:

  • 歴史的理由により、"UTC"primary time zone identifierでなければならない。 "Etc/UTC""Etc/GMT"、および"GMT"、ならびにそれらのいずれかに解決されるすべてのLink名は、"UTC"に解決されるnon-primary time identifierでなければならない。
  • ファイルzone.tabの“TZ”列に存在する任意のLink名はprimary time zone identifierでなければならない。 例えば、"Europe/Prague""Europe/Bratislava"はいずれもprimary time zone identifierでなければならない。 この要件は、各ISO 3166-1 Alpha-2国コードについて少なくとも1つのprimary time zone identifierを保証し、ある国のタイムゾーン規則への将来の変更が、別の国のタイムゾーンを使用するECMAScriptプログラムに影響しないことを保証する。ただし、それらの国の領土境界も変更された場合を除く。
  • ファイルzone.tabの“TZ”列に列挙されておらず、かつ単一のISO 3166-1 Alpha-2国コードの領土内に完全に含まれる地理的領域を表す任意のLink名は、同じ国コードの領土内に完全に含まれる地理的領域も表すprimary identifierに解決されなければならない。 例えば、"Atlantic/Jan_Mayen""Arctic/Longyearbyen"に解決されなければならない。
Note

IANA Time Zone Databaseは、どの利用可能な名前付きタイムゾーン識別子がprimaryであるかに影響するビルドオプションを提供する。 デフォルトのビルドオプションは異なる国のタイムゾーンを統合する。例えば、"Atlantic/Reykjavik"はZone "Africa/Abidjan"へのLinkとしてビルドされる。 地理的および政治的に異なる場所は、IANA Time Zone Databaseの将来のバージョンで異なるタイムゾーン規則を導入する可能性が高い。 上記の例外は、これらの将来互換性の問題を緩和する役割を果たす。

Unicode Common Locale Data Repository(CLDR)は、利用可能な名前付きタイムゾーン識別子がprimaryかnon-primaryかを決定する際に、上記の例外のほとんどを実装している。 CLDRデータの使用は実装間の一貫性のために推奨されるが、要求されない。 CLDRに基づかない実装でも、timezone.xml内のCLDRの識別子データを使用できる。 実装は、例えばPACKRATDATA=backzone PACKRATLIST=zone.tabなどのビルドオプションを使用し、上記の要件への準拠を保証するために必要な後処理を行うことで、IANA Time Zone Databaseを直接ビルドしてもよい。

IANA Time Zone Databaseは通常、年に5回から10回更新される。 これらの更新は新しいZone名またはLink名を追加したり、ZoneをLinkに変更したり、任意のZoneに関連付けられたUTCオフセットおよび遷移を変更したりすることがある。 実装は、できるだけ早くIANA Time Zone Databaseの更新を含めることが推奨される。 このような迅速な対応により、ECMAScriptプログラムがタイムゾーン依存の計算を正確に実行でき、外部入力またはホスト環境によって提供される新しく追加された利用可能な名前付きタイムゾーン識別子を使用できることが保証される。

IANA Time Zone Databaseの保守者は安定性を目指しているが、まれに(平均して年1回未満)Zoneが新しいZoneに置き換えられることがある。 例えば、2022年に"Europe/Kiev"は、新しい"Europe/Kyiv" Zoneに解決されるLinkへ非推奨化された。 非推奨のLinkはrenamed time zone identifierと呼ばれ、新しく追加されたZoneはreplacement time zone identifierと呼ばれる。

これらのまれな変更による混乱を減らすため、実装は各replacement time zone identifierを、既存のrenamed time zone identifierに解決されるnon-primary time zone identifierとして最初に追加すべきである。 これにより、ECMAScriptプログラムは両方の識別子を認識できるが、ECMAScriptプログラムがまだそれを認識していない別のシステムへreplacement time zone identifierを送信する可能性も低減される。 rename waiting periodの後、実装は新しいZoneをprimary time zone identifierへ昇格させると同時に、renamed time zone identifierをnon-primaryへ降格すべきである。 他のシステムが更新されるための十分な時間を提供するため、推奨されるrename waiting periodは2年である。 ただし、これは厳密でも動的でもある必要はない。 代わりに、実装はタイムゾーンデータを更新する通常のリリースプロセスの一部として、待機期間の後にreplacement time zone identifierをprimaryにすべきである。

待機期間は、新しいZoneが既存のZoneを置き換えるために追加された場合にのみ適用されるべきである。 既存のZoneとLinkが入れ替えられた場合、名前変更は発生しておらず、待機期間は不要である。

実装がagentの生存期間中にタイムゾーン情報を改訂する場合、利用可能な名前付きタイムゾーン識別子のリスト、任意の利用可能な名前付きタイムゾーン識別子に関連付けられたprimary time zone identifier、および任意の利用可能な名前付きタイムゾーン識別子に関連付けられたUTCオフセットと遷移は、そのagentによって以前に観測された結果と一貫していることが要求される。 この要件をサポートする複雑さのため、実装は各agentの生存期間中、完全に一貫したIANA Time Zone Databaseのコピーを維持することが推奨される。

この節は21.4.1.19を補完するが、置き換えるものではない。

6.5.1 AvailableNamedTimeZoneIdentifiers ( )

The implementation-defined abstract operation AvailableNamedTimeZoneIdentifiers takes no arguments and returns Time Zone Identifier RecordList. その結果は、この実装内のすべての利用可能な名前付きタイムゾーン識別子、および各利用可能な名前付きタイムゾーン識別子に対応するprimary time zone identifierを記述する。 Listは各Time Zone Identifier Record[[Identifier]]フィールドに従って順序付けられる。

この定義は、21.4.1.23で提供される定義を置き換える。

  1. identifiersを、IANA Time Zone Database内の各Zone名またはLink名のString値を含むListとする。
  2. Assert: identifiersのいかなる要素も、他のいかなる要素に対してもASCII-case-insensitive matchではない。
  3. identifiersを辞書式コード単位順序に従ってソートする。
  4. resultを新しい空のListとする。
  5. identifiersの各要素identifierについて、次を行う:
    1. primaryidentifierとする。
    2. identifierがIANA Time Zone Database内のLink名であり、かつidentifierがIANA Time Zone Databaseのzone.tabの“TZ”列に存在しないならば、
      1. zoneを、IANA Time Zone DatabaseでLink名を解決する規則に従ってidentifierが解決されるZone名とする。
      2. zone"Etc/"で始まるならば、
        1. primaryzoneに設定する。
      3. そうでなければ、
        1. identifierCountryCodeを、identifierに対応する地理的領域を領土に含むISO 3166-1 Alpha-2国コードとする。
        2. zoneCountryCodeを、zoneに対応する地理的領域を領土に含むISO 3166-1 Alpha-2国コードとする。
        3. identifierCountryCodezoneCountryCodeであるならば、
          1. primaryzoneに設定する。
        4. そうでなければ、
          1. countryCodeLineCountを、IANA Time Zone Databaseのファイルzone.tab内で“country-code”列がidentifierCountryCodeである行の数とする。
          2. countryCodeLineCountが1ならば、
            1. countryCodeLineを、IANA Time Zone Databaseのファイルzone.tab内で“country-code”列がidentifierCountryCodeである行とする。
            2. primarycountryCodeLineの“TZ”列の内容に設定する。
          3. そうでなければ、
            1. backzoneundefinedとする。
            2. backzoneLinkLinesを、IANA Time Zone Databaseのファイルbackzone内で"Link "または"#PACKRATLIST zone.tab Link "のいずれかで始まる行のListとする。
            3. backzoneLinkLinesの各要素lineについて、次を行う:
              1. iStringIndexOf(line, "Link ", 0)とする。
              2. linelinei + 5からの部分文字列に設定する。
              3. backzoneAndLinkStringSplitToList(line, " ")とする。
              4. Assert: backzoneAndLinkは少なくとも2つの要素を持ち、backzoneAndLink[0]とbackzoneAndLink[1]はいずれも利用可能な名前付きタイムゾーン識別子である。
              5. backzoneAndLink[1]がidentifierであるならば、
                1. Assert: backzoneundefinedである。
                2. backzonebackzoneAndLink[0]に設定する。
            4. Assert: backzoneundefinedでない。
            5. primarybackzoneに設定する。
    3. primary"Etc/UTC""Etc/GMT"、または"GMT"のいずれかならば、primary"UTC"に設定する。
    4. primaryreplacement time zone identifierであり、そのrename waiting periodが終了していないならば、
      1. renamedIdentifierを、primaryが置き換えたrenamed time zone identifierとする。
      2. primaryrenamedIdentifierに設定する。
    5. recordTime Zone Identifier Record { [[Identifier]]: identifier, [[PrimaryIdentifier]]: primary }とする。
    6. recordresultに追加する。
  6. Assert: resultは、utcRecord.[[Identifier]]"UTC"であり、かつutcRecord.[[PrimaryIdentifier]]"UTC"であるTime Zone Identifier Record utcRecordを含む。
  7. resultを返す。
Note 1

上記の、Linkをprimary time zone identifierへ解決するアルゴリズムは、International Components for Unicode(ICU)におけるicu::TimeZone::getIanaID()の挙動、およびUnicode Common Locale Data Repository(CLDR)におけるタイムゾーン識別子データの保守プロセスに対応することを意図している。

このアルゴリズムは、IANA Time Zone Databaseのファイルzone.tabおよびbackzoneからのデータを使用し、ISO 3166-1 Alpha-2国コードの境界を越えることなく、Linkをprimary time zone identifierへ解決する。 Linkの国コードがzone.tab内に1行しか持たない場合、その行がprimary time zone identifierを決定する。 しかし、その国コードがzone.tab内に複数行を持つ場合、正しいprimary time zone identifierを識別するためにbackzone内の履歴的マッピングを使用しなければならない。

例えば、IANA Time Zone Databaseのデフォルトビルドオプションが"Pacific/Truk"(国コード"FM"内)を"Pacific/Port_Moresby"(国コード"PG"内)へのLinkとして識別する場合に"Pacific/Truk"を解決するには、zone.tabの“country-code”列で"FM"に対応する行を確認しなければならない。 そのような行が1つだけであれば、その行の“TZ”列が"Pacific/Truk"に関連付けられたprimary time zone identifierを決定する。 しかし、zone.tab内に複数の"FM"行がある場合、backzoneを調べる必要があり、"Link Pacific/Chuuk Pacific/Truk"のような行は、"Pacific/Chuuk"をprimary time zone identifierとして使用する結果となる。

zone.tabはマッピングデータの推奨される情報源であることに注意。backzoneのマッピングはまれにISO 3166-1 Alpha-2国コードの境界を越えることがあるためである。 例えば、"Atlantic/Jan_Mayen"(国コード"SJ"内)は、backzone内で"Europe/Oslo"(国コード"NO"内)にマッピングされている。 IANA Time Zone Databaseの2024aリリース時点で、"Atlantic/Jan_Mayen"はこれが発生する唯一の事例である。

Note 2
IANA Time Zone Database内のタイムゾーン識別子は時間とともに変化する可能性がある。 最低限、実装は、周囲のagentの生存期間中、AvailableNamedTimeZoneIdentifiersの結果への変更をGetAvailableNamedTimeZoneIdentifierによって許可される変更に制限することが推奨される。 これらの推奨事項をサポートする複雑さのため、AvailableNamedTimeZoneIdentifiersの結果は周囲のagentの生存期間中同じままであることが推奨される。

6.5.2 GetAvailableNamedTimeZoneIdentifier ( timeZoneIdentifier )

The abstract operation GetAvailableNamedTimeZoneIdentifier takes argument timeZoneIdentifier (String) and returns Time Zone Identifier Recordまたはempty. timeZoneIdentifierが利用可能な名前付きタイムゾーン識別子であるならば、AvailableNamedTimeZoneIdentifiersが返すList内のRecordの1つを返す。 そうでなければ、emptyが返される。 It performs the following steps when called:

  1. AvailableNamedTimeZoneIdentifiers()の各要素recordについて、次を行う:
    1. record.[[Identifier]]timeZoneIdentifierに対するASCII-case-insensitive matchであるならば、recordを返す。
  2. emptyを返す。
Note
任意のtimeZoneIdentifier、またはそれに対するASCII-case-insensitive matchである任意の値について、結果のTime Zone Identifier Recordが周囲のagentの生存期間中、同じフィールド値を含むことが要求される。 さらに、周囲のagentの生存期間中、タイムゾーン識別子がprimaryからnon-primaryへ動的に変化しないことが要求される。つまり、timeZoneIdentifierがGetAvailableNamedTimeZoneIdentifierの以前の呼び出し結果の[[PrimaryIdentifier]]フィールドに対するASCII-case-insensitive matchである場合、GetAvailableNamedTimeZoneIdentifier(timeZoneIdentifier)は[[Identifier]][[PrimaryIdentifier]]であるTime Zone Identifier Recordを返さなければならない。 これらの要件をサポートする複雑さのため、AvailableNamedTimeZoneIdentifiersの結果(したがってGetAvailableNamedTimeZoneIdentifierも)は、周囲のagentの生存期間中同じままであることが推奨される。

6.5.3 AvailablePrimaryTimeZoneIdentifiers ( )

The abstract operation AvailablePrimaryTimeZoneIdentifiers takes no arguments and returns StringのList. 返されるListは、IANA Time Zone Database内のサポートされるZone名およびLink名のソート済みListである。 It performs the following steps when called:

  1. recordsAvailableNamedTimeZoneIdentifiers()とする。
  2. resultを新しい空のListとする。
  3. recordsの各要素timeZoneIdentifierRecordについて、次を行う:
    1. timeZoneIdentifierRecord.[[Identifier]]timeZoneIdentifierRecord.[[PrimaryIdentifier]]であるならば、
      1. timeZoneIdentifierRecord.[[Identifier]]resultに追加する。
  4. resultを返す。

6.5.4 StringSplitToList ( string, separator )

The abstract operation StringSplitToList takes arguments string (String) and separator (String) and returns StringのList. 返されるListは、stringの互いに重ならないすべての部分文字列のうち、separatorを含まないが、separatorの出現が直前および/または直後にあるものを含む。 そのような各substringは、separatorの隣接する出現の間、stringのまさに先頭にあるseparatorの前、またはstringのまさに末尾にあるseparatorの後では空のStringになるが、それ以外では空にならない。 It performs the following steps when called:

  1. Assert: stringは空のStringでない。
  2. Assert: separatorは空のStringでない。
  3. separatorLengthseparatorの長さとする。
  4. substringsを新しい空のListとする。
  5. iを0とする。
  6. jStringIndexOf(string, separator, 0)とする。
  7. jnot-foundでない間、繰り返す:
    1. substringstringiからjまでの部分文字列とする。
    2. substringsubstringsに追加する。
    3. ij + separatorLengthに設定する。
    4. jStringIndexOf(string, separator, i)に設定する。
  8. substringstringiからの部分文字列とする。
  9. substringsubstringsに追加する。
  10. substringsを返す。

6.6 測定単位識別子

この仕様は、Unicode Technical Standard #35 Part 2 General, Section 6.2 Unit Identifiersで定義されるcore unit identifier(または同等にcore unit ID)を使用して測定単位を識別する。それらの正準形式は、Unicode Basic Latin小文字(U+0061 LATIN SMALL LETTER AからU+007A LATIN SMALL LETTER Z)だけを含み、0個以上の中間ハイフン(U+002D HYPHEN-MINUS)を持つ文字列である。

限定されたcore unit identifierの集合のみが認可されている。 認可されていないcore unit identifierを使用しようとすると、RangeErrorとなる。

6.6.1 IsWellFormedUnitIdentifier ( unitIdentifier )

The abstract operation IsWellFormedUnitIdentifier takes argument unitIdentifier (String) and returns Boolean. unitIdentifier引数が、認可された単一単位、または2つの認可された単一単位の除算によって形成される複合単位のいずれかである整形式core unit identifierを表すことを検証する。 It performs the following steps when called:

  1. IsSanctionedSingleUnitIdentifier(unitIdentifier)がtrueならば、
    1. trueを返す。
  2. numeratorAndDenominatorStringSplitToList(unitIdentifier, "-per-")とする。
  3. numeratorAndDenominatorが正確に2つの要素を持たないならば、falseを返す。
  4. IsSanctionedSingleUnitIdentifier(numeratorAndDenominator[0])がfalseならば、falseを返す。
  5. IsSanctionedSingleUnitIdentifier(numeratorAndDenominator[1])がfalseならば、falseを返す。
  6. trueを返す。

6.6.2 IsSanctionedSingleUnitIdentifier ( unitIdentifier )

The abstract operation IsSanctionedSingleUnitIdentifier takes argument unitIdentifier (String) and returns Boolean. unitIdentifier引数が、この仕様の現在のバージョンで認可された単一単位識別子の中に含まれることを検証する。これはCommon Locale Data Repositoryのrelease 38 unit validity dataの部分集合であり、このListは時間とともに増える可能性がある。Unicode Technical Standard #35 Part 2 General, Section 6.2 Unit Identifiersで論じられているように、単一単位識別子は、他の単位識別子の乗算または除算から構成されていないcore unit identifierである。 It performs the following steps when called:

  1. unitIdentifierが下のTable 2に列挙されているならば、trueを返す。
  2. そうでなければ、falseを返す。
Table 2: ECMAScriptでの使用が認可された単一単位
単一単位識別子
acre
bit
byte
celsius
centimeter
day
degree
fahrenheit
fluid-ounce
foot
gallon
gigabit
gigabyte
gram
hectare
hour
inch
kilobit
kilobyte
kilogram
kilometer
liter
megabit
megabyte
meter
microsecond
mile
mile-scandinavian
milliliter
millimeter
millisecond
minute
month
nanosecond
ounce
percent
petabyte
pound
second
stone
terabit
terabyte
week
yard
year

6.6.3 AvailableCanonicalUnits ( )

The abstract operation AvailableCanonicalUnits takes no arguments and returns StringのList. 返されるListは辞書式コード単位順序に従ってソートされ、Table 2の各行(ヘッダ行を除く)に列挙されるsimple unit identifierの一意な値からなる。

6.7 番号体系識別子

この仕様は、Unicode Technical Standard #35 Part 3 Numbers, Section 1 Numbering Systemsによって参照される名前に対応する番号体系識別子を使用して番号体系を識別する。それらの正準形式は、Unicode Basic Latin小文字(U+0061 LATIN SMALL LETTER AからU+007A LATIN SMALL LETTER Z)だけを含む文字列である。

6.7.1 AvailableCanonicalNumberingSystems ( )

The implementation-defined abstract operation AvailableCanonicalNumberingSystems takes no arguments and returns StringのList. 返されるListは辞書式コード単位順序に従ってソートされ、実装がIntl.DateTimeFormat、Intl.NumberFormat、およびIntl.RelativeTimeFormatオブジェクトの機能を提供する番号体系を識別する一意な正準番号体系識別子を含む。このListは、Table 30の各行(ヘッダ行を除く)のNumbering System値を含まなければならない。

6.8 照合順序型

この仕様は、Unicode Technical Standard #35 Part 5 Collation, Section 3.1 Collation Typesで定義される照合順序型を使用して照合順序を識別する。それらの正準形式は、Unicode Basic Latin小文字(U+0061 LATIN SMALL LETTER AからU+007A LATIN SMALL LETTER Z)だけを含み、0個以上の中間ハイフン(U+002D HYPHEN-MINUS)を持つ文字列である。

6.8.1 AvailableCanonicalCollations ( )

The implementation-defined abstract operation AvailableCanonicalCollations takes no arguments and returns StringのList. 返されるListは辞書式コード単位順序に従ってソートされ、実装がIntl.Collatorオブジェクトの機能を提供する照合順序を識別する一意な正準照合順序型を含む。

6.9 カレンダー型

この仕様は、Unicode Technical Standard #35 Part 4 Dates, Section 2 Calendar Elementsで定義されるカレンダー型を使用してカレンダーを識別する。それらの正準形式は、Unicode Basic Latin小文字(U+0061 LATIN SMALL LETTER AからU+007A LATIN SMALL LETTER Z)だけを含み、0個以上の中間ハイフン(U+002D HYPHEN-MINUS)を持つ文字列である。

6.9.1 AvailableCalendars ( )

The implementation-defined abstract operation AvailableCalendars takes no arguments and returns StringのList. 返されるListは辞書式コード単位順序に従ってソートされ、実装がIntl.DateTimeFormatオブジェクトの機能を提供するカレンダーを識別する、正準形式(6.9)の一意なカレンダー型を含み、それらのエイリアス(例えば、"islamicc""islamic-civil"の両方またはいずれも含まない)も含む。このList"iso8601"を含まなければならない。

6.10 パターン文字列型

Pattern Stringは、形式"{key}"の部分文字列を0個以上含むString値であり、keyはASCII word charactersの要素のみからなる任意の空でない列であってよい。抽象パターン文字列の構文は実装詳細であり、ECMA-402の利用者には公開されない。

7 ECMAScript 標準組み込みオブジェクトの要件

本書で特に指定されていない限り、この標準で記述されているオブジェクト、関数、コンストラクターは、ECMAScript Standard Built-in Objects に指定された標準組み込み ECMAScript オブジェクトの一般的な要件および制限の対象となります。

8 Intlオブジェクト

Intlオブジェクトは、次のとおりである:

8.1 Intlオブジェクトの値プロパティ

8.1.1 Intl [ %Symbol.toStringTag% ]

%Symbol.toStringTag%プロパティの初期値はString値"Intl"である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }を持つ。

8.2 Intlオブジェクトのコンストラクタプロパティ

Intl.Localeを除き、次の各コンストラクタは、ロケールに依存するサービスを提供するオブジェクトを作成するサービスコンストラクタである。

8.2.1 Intl.Collator ( . . . )

10を参照。

8.2.2 Intl.DateTimeFormat ( . . . )

11を参照。

8.2.3 Intl.DisplayNames ( . . . )

12を参照。

8.2.4 Intl.DurationFormat ( . . . )

13を参照。

8.2.5 Intl.ListFormat ( . . . )

14を参照。

8.2.6 Intl.Locale ( . . . )

15を参照。

8.2.7 Intl.NumberFormat ( . . . )

16を参照。

8.2.8 Intl.PluralRules ( . . . )

17を参照。

8.2.9 Intl.RelativeTimeFormat ( . . . )

18を参照。

8.2.10 Intl.Segmenter ( . . . )

19を参照。

8.3 Intlオブジェクトの関数プロパティ

8.3.1 Intl.getCanonicalLocales ( locales )

getCanonicalLocalesメソッドが引数localesとともに呼び出されるとき、次の手順が実行される:

  1. localeListを? CanonicalizeLocaleList(locales)とする。
  2. CreateArrayFromList(localeList)を返す。

8.3.2 Intl.supportedValuesOf ( key )

supportedValuesOfメソッドが引数keyとともに呼び出されるとき、次の手順が実行される:

  1. key を ? ToString(key) に設定する。
  2. key"calendar" なら、
    1. list を新しい空の List とする。
    2. AvailableCalendars() の各要素 identifier について、次を行う。
      1. canonicalCanonicalizeUValue("ca", identifier) とする。
      2. identifiercanonical なら、
        1. identifierlist に追加する。
  3. そうでなく key"collation" なら、
    1. listAvailableCanonicalCollations( ) とする。
  4. そうでなく key"currency" なら、
    1. listAvailableCanonicalCurrencies( ) とする。
  5. そうでなく key"numberingSystem" なら、
    1. listAvailableCanonicalNumberingSystems( ) とする。
  6. そうでなく key"timeZone" なら、
    1. listAvailablePrimaryTimeZoneIdentifiers( ) とする。
  7. そうでなく key"unit" なら、
    1. listAvailableCanonicalUnits( ) とする。
  8. そうでなければ、
    1. RangeError 例外を投げる。
  9. CreateArrayFromList( list ) を返す。

9 ロケールおよびパラメータのネゴシエーション

サービスコンストラクタは、locales引数およびoptions引数によって表される要求を、実装の実際の能力と照合してネゴシエートするために共通のパターンを使用する。その共通の挙動は、能力を記述する内部スロット、これらの内部スロットを使用する抽象操作、および以下で定義される特殊なデータ型によってここで説明される。

Available Locales Listは、任意の順序で並ぶ重複のない言語タグListであり、それぞれが整形式であり、正規化済みであり、Unicodeロケール拡張シーケンスを欠く。これは、実装が特定の文脈内で機能を提供するすべてのロケールを表す。

Language Priority Listは、優先度の降順でロケールの選好列を表す、整形式かつ正規化済み言語タグListである。これは、RFC 4647 section 2.3においてBCP 47で定義される同名の用語に対応するが、"*"要素を禁止し、正規化済みの内容のみを含む。

Resolution Option Descriptorは、フィールド[[Key]](文字列、通常は[[RelevantExtensionKeys]] Listの要素)および[[Property]](文字列)を持ち、必要に応じて[[Type]]booleanまたはstring)と[[Values]]emptyまたはECMAScript言語値のList)のいずれかまたは両方も持つRecordである。これは、オブジェクト構築中にロケール解決に関連するオプションを読み取る方法を記述する。

9.1 サービスコンストラクタの内部スロット

サービスコンストラクタは、次の内部スロットを持つ:

  • [[AvailableLocales]]Available Locales Listである。これはDefaultLocaleによって返される値を含まなければならない。さらに、複数のサブタグを持つ各要素について、ResolveLocaleからの潜在的なフォールバックとして機能するように、同じ言語サブタグと、同じ後続サブタグの真部分集合(すなわち、1つ以上を省略したもの)を持つ、より狭くない言語タグも含まなければならない。特に、言語サブタグ、用字サブタグ、および地域サブタグを持つ各要素には、同じ言語サブタグおよび地域サブタグのみからなり、用字サブタグを欠く別の要素が伴わなければならない。例えば、
    • [[AvailableLocales]]"de-DE"を含む場合、それは"de"も含まなければならない(これは"de-AT""de-CH"などの要求ロケールを満たすために選択される可能性がある)。
    • [[AvailableLocales]]"az-Latn-AZ"を含む場合、それは"az-AZ"も含まなければならない(これは"az-Cyrl"が利用不可である場合に"az-Cyrl-AZ"などの要求ロケールを満たすために選択される可能性がある)。
  • [[RelevantExtensionKeys]]は、構築されるオブジェクトの機能に関連する、Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitionsで定義されるUnicodeロケール拡張シーケンスキーのListである。
  • [[ResolutionOptionDescriptors]]は、オブジェクト構築中にオプションを読み取るために使用されるResolution Option DescriptorListである。
  • [[SortLocaleData]]および[[SearchLocaleData]](Intl.Collatorの場合)ならびに[[LocaleData]](その他すべてのサービスコンストラクタの場合)はRecordである。そのサービスコンストラクタに固有のフィールドに加えて、そのような各Record[[AvailableLocales]]に含まれる各ロケールのフィールドを持つ。そのような各ロケール名付きフィールドの値はRecordであり、その中で[[RelevantExtensionKeys]]の各要素は、対応するUnicodeロケール拡張シーケンスキーについて、関連するロケールで実装がサポートするtype値を表す空でないStringのListである値を持つフィールド名を識別し、最初の要素はそのロケールにおけるそのキーのデフォルト値を提供する。
Note
例えば、DateTimeFormatの実装は、その[[AvailableLocales]]内部スロットに言語タグ"fa-IR"を含めることがあり、(11.2.3に従って)その[[RelevantExtensionKeys]]内部スロットにキー"ca""hc"、および"nu"を含めなければならない。 そのロケールのデフォルトカレンダーは通常"persian"であるが、実装は"gregory""islamic"、および"islamic-civil"もサポートすることがある。 したがって、DateTimeFormatの[[LocaleData]]内部スロット内のRecordは、値が{ [[ca]]: « "persian", "gregory", "islamic", "islamic-civil" », [[hc]]: « … », [[nu]]: « … » }のようなRecordである[[fa-IR]]フィールドを、同じ値の形状を持つがList内の要素が異なる他のロケール名付きフィールドとともに含むことになる。

9.2 抽象操作

9.2.1 CanonicalizeLocaleList ( locales )

The abstract operation CanonicalizeLocaleList takes argument locales (ECMAScript言語値) and returns Language Priority Listを含む通常完了またはthrow完了. It performs the following steps when called:

  1. localesundefinedならば、
    1. 新しい空のListを返す。
  2. seenを新しい空のListとする。
  3. localesがStringである、またはlocalesがObjectであり、かつlocales[[InitializedLocale]]内部スロットを持つならば、
    1. localesObjCreateArrayFromListlocales »)とする。
  4. そうでなければ、
    1. localesObjを? ToObject(locales)とする。
  5. lengthを? LengthOfArrayLike(localesObj)とする。
  6. kを0とする。
  7. k < lengthである間、繰り返す:
    1. propertyKeyを! ToString(𝔽(k))とする。
    2. existsを? HasProperty(localesObj, propertyKey)とする。
    3. existstrueならば、
      1. elementを? Get(localesObj, propertyKey)とする。
      2. elementがStringでもObjectでもないならば、TypeError例外を投げる。
      3. elementがObjectであり、かつelement[[InitializedLocale]]内部スロットを持つならば、
        1. tagelement.[[Locale]]とする。
      4. そうでなければ、
        1. tagを? ToString(element)とする。
      5. IsWellFormedLanguageTag(tag)がfalseならば、RangeError例外を投げる。
      6. canonicalizedTagCanonicalizeUnicodeLocaleId(tag)とする。
      7. seencanonicalizedTagを含まないならば、canonicalizedTagseenに追加する。
    4. kk + 1に設定する。
  8. seenを返す。
Note 1
非規範的要約:この抽象操作はlocales引数を配列として解釈し、その要素をListへコピーし、要素を整形式言語タグとして検証して正規化し、重複を省略する。
Note 2
elementがStringまたはObjectであることを要求することは、Number値NaNがMin Nan Chineseを表す言語タグ"nan"として解釈されないことを意味する。

9.2.2 CanonicalizeUValue ( ukey, uvalue )

The abstract operation CanonicalizeUValue takes arguments ukey (Unicode Technical Standard #35 Part 1 Core Section 3.6.1 Key and Type Definitionsで定義されるUnicodeロケール拡張シーケンスキー) and uvalue (String) and returns String. 返されるStringは、ukeyの値としてのuvalueの正準かつ大文字小文字を正規化した形式である。 It performs the following steps when called:

  1. lowerValueuvalueASCII-lowercaseとする。
  2. canonicalizedを、Unicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalization Section 5 Canonicalizing Syntax, Processing LocaleIdsに従って、キーukeyの値としてlowerValueを正規化した結果のString値とする。
  3. NOTE: 実装は、Common Locale Data Repository(https://cldr.unicode.org/で入手可能)によって提供されるcommon/bcp47内の'u'拡張データを使用することが推奨される。
  4. canonicalizedを返す。

9.2.3 LookupMatchingLocaleByPrefix ( availableLocales, requestedLocales )

The abstract operation LookupMatchingLocaleByPrefix takes arguments availableLocales (Available Locales List) and requestedLocales (Language Priority List) and returns フィールド[[locale]]Unicode正規化済みロケール識別子)および[[extension]]Unicodeロケール拡張シーケンスまたはempty)を持つRecordまたはundefined. Unicodeロケール拡張シーケンスを無視して、RFC 4647 section 3.4においてBCP 47で定義されるlookupアルゴリズムを使用し、requestedLocalesを満たすためのavailableLocalesの最良の要素を決定する。非デフォルトの一致が見つかった場合、availableLocalesからの一致する言語タグを含む[[locale]]フィールドと、requestedLocalesの対応する要素のUnicodeロケール拡張シーケンス(要求された言語タグにそのようなシーケンスがない場合はempty)を含む[[extension]]フィールドを持つRecordを返す。 It performs the following steps when called:

  1. requestedLocalesの各要素localeについて、次を行う:
    1. extensionemptyとする。
    2. localeUnicodeロケール拡張シーケンスを含むならば、
      1. extensionlocaleUnicodeロケール拡張シーケンスに設定する。
      2. localeを、任意のUnicodeロケール拡張シーケンスが削除されたlocaleであるString値に設定する。
    3. prefixlocaleとする。
    4. prefixが空のStringでない間、繰り返す:
      1. availableLocalesprefixを含むならば、Record { [[locale]]: prefix, [[extension]]: extension }を返す。
      2. prefix"-"(コード単位0x002D HYPHEN-MINUS)を含むならばposprefix内の"-"の最後の出現のインデックスとし、そうでなければposを0とする。
      3. pos ≥ 2であり、かつprefixpos - 2からpos - 1までの部分文字列が"-"である間、繰り返す:
        1. pospos - 2に設定する。
      4. prefixprefixの0からposまでの部分文字列に設定する。
  2. undefinedを返す。
Note
要求されたロケールがUnicode Technical Standard #35 Part 1 Core BCP 47 T Extensionサブタグ列を含む場合、このアルゴリズム内の切り詰めは一時的に無効な言語タグを生成することがある。ただし、availableLocalesは有効な言語タグのみを含むため、それらはいずれも返されない。

9.2.4 LookupMatchingLocaleByBestFit ( availableLocales, requestedLocales )

The implementation-defined abstract operation LookupMatchingLocaleByBestFit takes arguments availableLocales (Available Locales List) and requestedLocales (Language Priority List) and returns フィールド[[locale]]Unicode正規化済みロケール識別子)および[[extension]]Unicodeロケール拡張シーケンスまたはempty)を持つRecord、またはundefined. Unicodeロケール拡張シーケンスを無視して、requestedLocalesを満たすためのavailableLocalesの最良の要素を決定する。アルゴリズムは実装依存であるが、要求されたロケールの典型的な利用者が、LookupMatchingLocaleByPrefixアルゴリズムによって生成されるものと少なくとも同程度によいと考える結果を生成すべきである。非デフォルトの一致が見つかった場合、availableLocalesからの一致する言語タグを含む[[locale]]フィールドと、requestedLocalesの対応する要素のUnicodeロケール拡張シーケンス(要求された言語タグにそのようなシーケンスがない場合はempty)を含む[[extension]]フィールドを持つRecordを返す。

9.2.5 UnicodeExtensionComponents ( extension )

The abstract operation UnicodeExtensionComponents takes argument extension (Unicodeロケール拡張シーケンス) and returns フィールド[[Attributes]]および[[Keywords]]を持つRecord. extensionを、一意な属性のListと、一意なキーを持つkeywordListへ分解する。属性またはkeywordキーの最初以降の反復出現はすべて無視される。 It performs the following steps when called:

  1. Assert: extensionASCII-lowercaseextension である。
  2. Assert: extension の 0 から 3 までの部分文字列は "-u-" である。
  3. attributes を新しい空の List とする。
  4. keywords を新しい空の List とする。
  5. keywordundefined とする。
  6. sizeextension の長さとする。
  7. k を 3 とする。
  8. k < size の間、繰り返す。
    1. eStringIndexOf(extension, "-", k) とする。
    2. enot-found なら lengthsize - k とする。そうでなければ lengthe - k とする。
    3. subtagextensionk から k + length までの部分文字列とする。
    4. NOTE: keyword は、一連のサブタグであり、その最初のものは長さ 2 の key で、後続するものがあれば長さが 3 から 8 までの閉区間内にあり、それらは間にある "-" 区切りとともに collectively value を構成する。attribute は、すべての keywords に先行する、長さが 3 から 8 までの閉区間内にある単一のサブタグである。
    5. Assert: length ≥ 2 である。
    6. keywordundefined で、かつ length ≠ 2 なら、
      1. subtagattributes の要素でないなら、subtagattributes に追加する。
    7. そうでなく length = 2 なら、
      1. keywordRecord { [[Key]]: subtag, [[Value]]: 空の String } に設定する。
      2. keywords[[Key]]keyword.[[Key]] である要素を含まないなら、keywordkeywords に追加する。
    8. そうでなく keyword.[[Value]] が空の String なら、
      1. keyword.[[Value]]subtag に設定する。
    9. そうでなければ、
      1. keyword.[[Value]]keyword.[[Value]]"-"、および subtag の文字列連結に設定する。
    10. kk + length + 1 に設定する。
  9. Record { [[Attributes]]: attributes, [[Keywords]]: keywords } を返す。

9.2.6 InsertUnicodeExtensionAndCanonicalize ( locale, attributes, keywords )

The abstract operation InsertUnicodeExtensionAndCanonicalize takes arguments locale (言語タグ), attributes (StringのList), and keywords (RecordList) and returns Unicode正規化済みロケール識別子. attributesおよびkeywordsUnicodeロケール拡張シーケンスとしてlocaleへ組み込み、正規化された結果を返す。 It performs the following steps when called:

  1. Assert: localeUnicodeロケール拡張シーケンスを含まない。
  2. extension"-u"とする。
  3. attributesの各要素attrについて、次を行う:
    1. extensionextension"-"、およびattrの文字列連結に設定する。
  4. keywordsの各Record { [[Key]], [[Value]] } keywordについて、次を行う:
    1. extensionextension"-"、およびkeyword.[[Key]]の文字列連結に設定する。
    2. keyword.[[Value]]が空のStringでないならば、extensionextension"-"、およびkeyword.[[Value]]の文字列連結に設定する。
  5. extension"-u"ならば、CanonicalizeUnicodeLocaleId(locale)を返す。
  6. privateIndexStringIndexOf(locale, "-x-", 0)とする。
  7. privateIndexnot-foundならば、
    1. newLocalelocaleextensionの文字列連結とする。
  8. そうでなければ、
    1. preExtensionlocaleの0からprivateIndexまでの部分文字列とする。
    2. postExtensionlocaleprivateIndexからの部分文字列とする。
    3. newLocalepreExtensionextension、およびpostExtensionの文字列連結とする。
  9. Assert: IsWellFormedLanguageTag(newLocale)はtrueである。
  10. CanonicalizeUnicodeLocaleId(newLocale)を返す。

9.2.7 ResolveLocale ( availableLocales, requestedLocales, options, relevantExtensionKeys, localeData )

The abstract operation ResolveLocale takes arguments availableLocales (Available Locales List), requestedLocales (Language Priority List), options (Record), relevantExtensionKeys (StringのList), and localeData (Record) and returns Record. RFC 4647 section 3においてBCP 47で定義される"lookup"を実行し、Unicodeロケール拡張シーケンスを無視して、options.[[localeMatcher]]によって指定されるLookupMatchingLocaleByBestFitアルゴリズムまたはLookupMatchingLocaleByPrefixアルゴリズムのいずれかを使用し、requestedLocalesを満たすためのavailableLocalesの最良の要素を決定し、localeDataからの対応するデータおよびrelevantExtensionKeysの各要素に対する解決済み値(一致したロケールのデータをデフォルトとし、存在する場合は要求されたUnicodeロケール拡張シーケンスからのデータにより、さらに存在する場合はoptionsからのデータにより置き換えられる)も含む一致の表現を返す。requestedLocalesから一致した要素がUnicodeロケール拡張シーケンスを含む場合、それは返されるRecord[[Locale]]フィールド内の言語タグへコピーされるが、relevantExtensionKeys内に含まれないkey値、またはoptionsからの異なる値によって置き換えられたtype値を持つkeyword Unicodeロケール非終端記号は省略される。 It performs the following steps when called:

  1. matcheroptions.[[localeMatcher]] とする。
  2. matcher"lookup" なら、
    1. matchLookupMatchingLocaleByPrefix(availableLocales, requestedLocales) とする。
  3. そうでなければ、
    1. matchLookupMatchingLocaleByBestFit(availableLocales, requestedLocales) とする。
  4. matchundefined なら、matchRecord { [[locale]]: DefaultLocale(), [[extension]]: empty } に設定する。
  5. foundLocalematch.[[locale]] とする。
  6. foundLocaleDatalocaleData.[[<foundLocale>]] とする。
  7. Assert: foundLocaleDataRecord である。
  8. result を新しい Record とする。
  9. result.[[LocaleData]]foundLocaleData に設定する。
  10. match.[[extension]]empty でないなら、
    1. componentsUnicodeExtensionComponents(match.[[extension]]) とする。
    2. keywordscomponents.[[Keywords]] とする。
  11. そうでなければ、
    1. keywords を新しい空の List とする。
  12. supportedKeywords を新しい空の List とする。
  13. relevantExtensionKeys の各要素 key について、次を行う。
    1. keyLocaleDatafoundLocaleData.[[<key>]] とする。
    2. Assert: keyLocaleDataList である。
    3. valuekeyLocaleData[0] とする。
    4. Assert: value は String または null である。
    5. supportedKeywordempty とする。
    6. keywords[[Key]]key である要素を含むなら、
      1. entry[[Key]]key である keywords の要素とする。
      2. requestedValueentry.[[Value]] とする。
      3. requestedValue が空の String でないなら、
        1. keyLocaleDatarequestedValue を含むなら、
          1. valuerequestedValue に設定する。
          2. supportedKeywordRecord { [[Key]]: key, [[Value]]: value } に設定する。
      4. そうでなく keyLocaleData"true" を含むなら、
        1. value"true" に設定する。
        2. supportedKeywordRecord { [[Key]]: key, [[Value]]: 空の String } に設定する。
    7. Assert: options はフィールド [[<key>]] を持つ。
    8. optionsValueoptions.[[<key>]] とする。
    9. Assert: optionsValue は String、または undefined もしくは null のいずれかである。
    10. optionsValue が String なら、
      1. ukeykeyASCII-lowercase とする。
      2. optionsValueCanonicalizeUValue(ukey, optionsValue) に設定する。
      3. optionsValue が空の String なら、
        1. optionsValue"true" に設定する。
    11. SameValue(optionsValue, value) が false で、かつ keyLocaleDataoptionsValue を含むなら、
      1. valueoptionsValue に設定する。
      2. supportedKeywordempty に設定する。
    12. supportedKeywordempty でないなら、supportedKeywordsupportedKeywords に追加する。
    13. result.[[<key>]] を value に設定する。
  14. supportedKeywords が空でないなら、
    1. supportedAttributes を新しい空の List とする。
    2. foundLocaleInsertUnicodeExtensionAndCanonicalize(foundLocale, supportedAttributes, supportedKeywords) に設定する。
  15. result.[[Locale]]foundLocale に設定する。
  16. result を返す。

9.2.8 ResolveOptions ( ctor, localeData, locales, options [ , specialBehaviours [ , modifyResolutionOptions ] ] )

The abstract operation ResolveOptions takes arguments ctor (サービスコンストラクタ), localeData (Record), locales (ECMAScript言語値), and options (ECMAScript言語値) and optional arguments specialBehaviours (enumList) and modifyResolutionOptions (1つのパラメータを持つAbstract Closure) and returns フィールド[[Options]](Object)、[[ResolvedLocale]]Record)、および[[ResolutionOptions]]Record)を持つRecordを含む通常完了、またはthrow完了. ctorの入力を読み取り、それらをロケールへ解決する。 It performs the following steps when called:

  1. requestedLocalesを? CanonicalizeLocaleList(locales)とする。
  2. specialBehavioursが存在し、require-optionsを含み、かつoptionsundefinedならば、TypeError例外を投げる。
  3. specialBehavioursが存在し、coerce-optionsを含むならば、optionsを? CoerceOptionsToObject(options)に設定する。そうでなければ、optionsを? GetOptionsObject(options)に設定する。
  4. matcherを? GetOption(options, "localeMatcher", string, « "lookup", "best fit" », "best fit")とする。
  5. optRecord { [[localeMatcher]]: matcher }とする。
  6. ctor.[[ResolutionOptionDescriptors]]の各Resolution Option Descriptor descについて、次を行う:
    1. desc[[Type]]フィールドを持つならばtypedesc.[[Type]]とする。そうでなければtypestringとする。
    2. desc[[Values]]フィールドを持つならばvaluesdesc.[[Values]]とする。そうでなければvaluesemptyとする。
    3. valueを? GetOption(options, desc.[[Property]], type, values, undefined)とする。
    4. valueundefinedでないならば、
      1. valueを! ToString(value)に設定する。
      2. valuetype Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
    5. keydesc.[[Key]]とする。
    6. opt.[[<key>]]をvalueに設定する。
  7. modifyResolutionOptionsが存在するならば、! modifyResolutionOptions(opt)を実行する。
  8. resolutionResolveLocale(ctor.[[AvailableLocales]], requestedLocales, opt, ctor.[[RelevantExtensionKeys]], localeData)とする。
  9. Record { [[Options]]: options, [[ResolvedLocale]]: resolution, [[ResolutionOptions]]: opt }を返す。

9.2.9 FilterLocales ( availableLocales, requestedLocales, options )

The abstract operation FilterLocales takes arguments availableLocales (Available Locales List), requestedLocales (Language Priority List), and options (ECMAScript言語値) and returns Unicode正規化済みロケール識別子Listを含む通常完了またはthrow完了. RFC 4647 section 3においてBCP 47で定義される"filtering"を実行し、optionsで指定されるLookupMatchingLocaleByBestFitアルゴリズムまたはLookupMatchingLocaleByPrefixアルゴリズムのいずれかを使用するときにavailableLocalesが一致するロケールを含むrequestedLocalesの要素を返し、それらの相対順序を保持する。 It performs the following steps when called:

  1. optionsを? CoerceOptionsToObject(options)に設定する。
  2. matcherを? GetOption(options, "localeMatcher", string, « "lookup", "best fit" », "best fit")とする。
  3. subsetを新しい空のListとする。
  4. requestedLocalesの各要素localeについて、次を行う:
    1. matcher"lookup"ならば、
      1. matchLookupMatchingLocaleByPrefix(availableLocales, « locale »)とする。
    2. そうでなければ、
      1. matchLookupMatchingLocaleByBestFit(availableLocales, « locale »)とする。
    3. matchundefinedでないならば、localesubsetに追加する。
  5. CreateArrayFromList(subset)を返す。

9.2.10 CoerceOptionsToObject ( options )

The abstract operation CoerceOptionsToObject takes argument options (ECMAScript言語値) and returns Objectを含む通常完了またはthrow完了. optionsGetOptionでの使用に適したObjectへ強制変換し、デフォルトでは空のObjectにする。 これは非nullプリミティブ値をオブジェクトへ強制変換するため、新しい機能ではGetOptionsObjectを優先してその使用は推奨されない。 It performs the following steps when called:

  1. optionsundefinedならば、
    1. OrdinaryObjectCreate(null)を返す。
  2. ToObject(options)を返す。

9.2.11 GetOption ( options, propertyKey, type, values, default )

The abstract operation GetOption takes arguments options (Object), propertyKey (プロパティキー), type (booleanまたはstring), values (emptyまたはECMAScript言語値のList), and default (requiredまたはECMAScript言語値) and returns ECMAScript言語値を含む通常完了またはthrow完了. optionsの指定されたプロパティの値を抽出し、それを要求されたtypeへ変換し、valuesemptyでない場合にその値がvaluesによって許可されるかを検査し、値がundefinedである場合はdefaultを代入する。 It performs the following steps when called:

  1. valueを? Get(options, propertyKey)とする。
  2. valueundefinedならば、
    1. defaultrequiredならば、TypeError例外を投げる。
    2. defaultを返す。
  3. typebooleanならば、
    1. valueToBoolean(value)に設定する。
  4. そうでなければ、
    1. Assert: typestringである。
    2. valueを? ToString(value)に設定する。
  5. valuesemptyでなく、かつvaluesvalueを含まないならば、RangeError例外を投げる。
  6. valueを返す。

9.2.12 GetBooleanOrStringNumberFormatOption ( options, propertyKey, stringValues, fallback )

The abstract operation GetBooleanOrStringNumberFormatOption takes arguments options (Object), propertyKey (プロパティキー), stringValues (StringのList), and fallback (ECMAScript言語値) and returns Boolean、String、またはfallbackのいずれかを含む通常完了、またはthrow完了. 提供されたoptionsオブジェクトからpropertyKeyという名前のプロパティの値を抽出する。その値がundefinedならばfallbackを返し、その値がtrueならばtrueを返し、その値がfalseへ強制変換されるならばfalseを返し、そうでなければそれをStringへ強制変換して、それがstringValuesによって許可されている場合にその結果を返す。 It performs the following steps when called:

  1. valueを? Get(options, propertyKey)とする。
  2. valueundefinedならば、fallbackを返す。
  3. valuetrueならば、trueを返す。
  4. ToBoolean(value)がfalseならば、falseを返す。
  5. valueを? ToString(value)に設定する。
  6. stringValuesvalueを含まないならば、RangeError例外を投げる。
  7. valueを返す。

9.2.13 DefaultNumberOption ( value, minimum, maximum, fallback )

The abstract operation DefaultNumberOption takes arguments value (ECMAScript言語値), minimum (整数), maximum (整数), and fallback (整数またはundefined) and returns 整数またはundefinedのいずれかを含む通常完了、またはthrow完了. valueを整数へ変換し、それが許可範囲内にあるかを検査し、必要に応じてfallback値を埋める。 It performs the following steps when called:

  1. valueundefinedならば、fallbackを返す。
  2. valueを? ToNumber(value)に設定する。
  3. valueが有限でない、または(value) < minimum、または(value) > maximumならば、RangeError例外を投げる。
  4. floor((value))を返す。

9.2.14 GetNumberOption ( options, propertyKey, minimum, maximum, fallback )

The abstract operation GetNumberOption takes arguments options (Object), propertyKey (String), minimum (整数), maximum (整数), and fallback (整数またはundefined) and returns 整数またはundefinedのいずれかを含む通常完了、またはthrow完了. 提供されたoptionsオブジェクトからpropertyKeyという名前のプロパティの値を抽出し、それを整数へ変換し、それが許可範囲内にあるかを検査し、必要に応じてfallback値を埋める。 It performs the following steps when called:

  1. valueを? Get(options, propertyKey)とする。
  2. DefaultNumberOption(value, minimum, maximum, fallback)を返す。

9.2.15 PartitionPattern ( pattern )

The abstract operation PartitionPattern takes argument pattern (Pattern String) and returns フィールド[[Type]](String)および[[Value]](Stringまたはundefined)を持つRecordList. [[Value]]フィールドは、[[Type]]"literal"である場合はString値となり、そうでない場合はundefinedとなる。 It performs the following steps when called:

  1. resultを新しい空のListとする。
  2. placeholderEndを-1とする。
  3. placeholderStartStringIndexOf(pattern, "{", 0)とする。
  4. placeholderStartnot-foundでない間、繰り返す:
    1. literalpatternplaceholderEnd + 1からplaceholderStartまでの部分文字列とする。
    2. literalが空のStringでないならば、
      1. Record { [[Type]]: "literal", [[Value]]: literal }をresultに追加する。
    3. placeholderEndStringIndexOf(pattern, "}", placeholderStart)に設定する。
    4. Assert: placeholderEndnot-foundでなく、かつplaceholderStart < placeholderEndである。
    5. placeholderNamepatternplaceholderStart + 1からplaceholderEndまでの部分文字列とする。
    6. Record { [[Type]]: placeholderName, [[Value]]: undefined }をresultに追加する。
    7. placeholderStartStringIndexOf(pattern, "{", placeholderEnd)に設定する。
  5. tailpatternplaceholderEnd + 1からの部分文字列とする。
  6. tailが空のStringでないならば、
    1. Record { [[Type]]: "literal", [[Value]]: tail }をresultに追加する。
  7. resultを返す。

10 コレーターオブジェクト

10.1 Intl.Collator コンストラクター

Intl.Collator コンストラクター:

  • %Intl.Collator%である。
  • Intl オブジェクトの "Collator" プロパティの初期値である。

Intl オブジェクトのすべてのサービスコンストラクタープロパティに共通する動作は 9.1 で規定されている。

10.1.1 Intl.Collator ( [ locales [ , options ] ] )

Intl.Collator 関数がオプション引数 localesoptions で呼び出された場合、次の手順を実行する:

  1. NewTarget が undefined なら、newTarget をアクティブな関数オブジェクトとし、そうでなければ newTarget を NewTarget とする。
  2. internalSlotsList を « [[InitializedCollator]], [[Locale]], [[Usage]], [[Collation]], [[Numeric]], [[CaseFirst]], [[Sensitivity]], [[IgnorePunctuation]], [[BoundCompare]] » とする。
  3. collator を ? OrdinaryCreateFromConstructor(newTarget, "%Intl.Collator.prototype%", internalSlotsList) とする。
  4. 注: locale データのソースは ResolveOptions"usage" プロパティに依存するが、次の2つのステップはその参照よりも観測可能に先行しなければならず、ResolveOptions 内で観測可能に繰り返してはならない。
  5. requestedLocales を ? CanonicalizeLocaleList(locales) とする。
  6. options を ? CoerceOptionsToObject(options) とする。
  7. usage を ? GetOption(options, "usage", string, « "sort", "search" », "sort") とする。
  8. collator.[[Usage]]usage を設定する。
  9. usage"sort" なら
  10. localeData%Intl.Collator%.[[SortLocaleData]] とする。
  11. それ以外の場合、
  12. localeData%Intl.Collator%.[[SearchLocaleData]] とする。
  13. optionsResolution を ? ResolveOptions(%Intl.Collator%, localeData, CreateArrayFromList(requestedLocales), options) とする。
  14. resolvedLocaleoptionsResolution.[[ResolvedLocale]] とする。
  15. collator.[[Locale]]resolvedLocale .[[Locale]] を設定する。
  16. resolvedLocale .[[co]]null なら collation"default" とし、そうでなければ collationresolvedLocale .[[co]] とする。
  17. collator.[[Collation]]collation を設定する。
  18. collator.[[Numeric]]SameValue(resolvedLocale .[[kn]], "true") を設定する。
  19. collator.[[CaseFirst]]resolvedLocale .[[kf]] を設定する。
  20. resolvedLocaleDataresolvedLocale .[[LocaleData]] とする。
  21. usage"sort" なら defaultSensitivity"variant" とし、そうでなければ defaultSensitivityresolvedLocaleData.[[sensitivity]] とする。
  22. collator.[[Sensitivity]] に ? GetOption(options, "sensitivity", string, « "base", "accent", "case", "variant" », defaultSensitivity) を設定する。
  23. defaultIgnorePunctuationresolvedLocaleData.[[ignorePunctuation]] とする。
  24. collator.[[IgnorePunctuation]] に ? GetOption(options, "ignorePunctuation", boolean, empty, defaultIgnorePunctuation) を設定する。
  25. collator を返す。
Note
"search" オプション値に関連付けられた照合は、文字列の一致を見つけるためだけに使用すべきであり、この照合は特定の順序であることが保証されていません。この動作は Unicode Technical Standard #35 Part 1 Core, Unicode Collation Identifier および Unicode Technical Standard #10 Unicode Collation Algorithm, Searching and Matching で説明されています。

10.2 Intl.Collator コンストラクターのプロパティ

Intl.Collator コンストラクター:

  • [[Prototype]] 内部スロットの値は %Function.prototype% である。
  • 次のプロパティを持つ:

10.2.1 Intl.Collator.prototype

Intl.Collator.prototype の値は %Intl.Collator.prototype% である。

このプロパティの属性は { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } である。

10.2.2 Intl.Collator.supportedLocalesOf ( locales [ , options ] )

supportedLocalesOf メソッドが localesoptions を引数に呼び出された場合、次の手順を実行する:

  1. availableLocales%Intl.Collator%.[[AvailableLocales]] とする。
  2. requestedLocales を ? CanonicalizeLocaleList(locales) とする。
  3. FilterLocales(availableLocales, requestedLocales, options) を返す。

10.2.3 内部スロット

[[AvailableLocales]] 内部スロットの値は 9.1 で説明された制約内で実装依存である。[[RelevantExtensionKeys]] 内部スロットの値は、要素 "co" を含むリストでなければならず、* "kf" * および * "kn" * のいずれかまたはすべてを含むことができ、他の要素を含んではならない。

Note
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions では照合に関連する10個のロケール拡張キーが説明されている: "co" はコレーターの用途と特殊化、"ka" は代替処理、"kb" は後方2次重み、"kc" はケースレベル、"kf" はケースファースト、"kh" はひらがな4次、"kk" は正規化、"kn" は数値、"kr" は並べ替え、"ks" は照合強度、"vt" は可変トップ。Collator では、用途は options オブジェクトの "usage" プロパティで指定し、代替処理は "ignorePunctuation" プロパティで指定し、ケースレベルと強度は "sensitivity" プロパティで指定する。言語タグ"co" キーは照合の特殊化のみサポートされ、"kb", "kh", "kk", "kr", "vt" キーはこのバージョンの Internationalization API では許可されていない。残りのキーのサポートは実装依存である。

[[ResolutionOptionDescriptors]] 内部スロットの値は « { [[Key]]: "co", [[Property]]: "collation" }, { [[Key]]: "kn", [[Property]]: "numeric", [[Type]]: boolean }, { [[Key]]: "kf", [[Property]]: "caseFirst", [[Values]]: « "upper", "lower", "false" » } » である。

[[SortLocaleData]] および [[SearchLocaleData]] 内部スロットの値は 9.1 で説明された制約内で実装依存であり、さらに次の追加制約がすべてのロケール値 locale に対して適用される:

  • [[SortLocaleData]].[[<locale>]].[[co]] および [[SearchLocaleData]].[[<locale>]].[[co]] の最初の要素は null でなければならない。
  • "standard" および "search" の値は、いずれの [[SortLocaleData]].[[<locale>]].[[co]] および [[SearchLocaleData]].[[<locale>]].[[co]] リストにも使用してはならない。
  • [[SearchLocaleData]].[[<locale>]] は "base", "accent", "case", "variant" のいずれかの文字列値を持つ [[sensitivity]] フィールドを持たなければならない。
  • [[SearchLocaleData]].[[<locale>]] および [[SortLocaleData]].[[<locale>]] は Boolean 値を持つ [[ignorePunctuation]] フィールドを持たなければならない。

10.3 Intl.Collator プロトタイプオブジェクトのプロパティ

Intl.Collator プロトタイプオブジェクト:

  • %Intl.Collator.prototype%である。
  • 通常のオブジェクトである。
  • Intl.Collator インスタンスではなく、[[InitializedCollator]] 内部スロットや他の Intl.Collator インスタンスオブジェクトの内部スロットを持たない。
  • [[Prototype]] 内部スロットの値は %Object.prototype% である。

10.3.1 Intl.Collator.prototype.constructor

Intl.Collator.prototype.constructor の初期値は %Intl.Collator% である。

10.3.2 Intl.Collator.prototype.resolvedOptions ( )

この関数はオブジェクトの初期化時に計算されたロケールとオプションにアクセスするためのものである。

  1. collatorthis 値とする。
  2. RequireInternalSlot(collator, [[InitializedCollator]]) を実行する。
  3. optionsOrdinaryObjectCreate(%Object.prototype%) とする。
  4. Table 3 の各行(ヘッダー行を除く)について、テーブル順に次を行う
  5. propertyKey を現在の行の Property 値とする。
  6. valuecollator の内部スロットのうち、現在の行の Internal Slot 値の名前を持つものの値とする。
  7. 現在の行に Extension Key 値がある場合、
  8. extensionKey を現在の行の Extension Key 値とする。
  9. %Intl.Collator%.[[RelevantExtensionKeys]]extensionKey を含まない場合、
  10. valueundefined に設定する。
  11. valueundefined でない場合、
  12. CreateDataPropertyOrThrow(options, propertyKey, value) を実行する。
  13. options を返す。
Table 3: Collator インスタンスの解決済みオプション
内部スロット プロパティ 拡張キー
[[Locale]] "locale"
[[Usage]] "usage"
[[Sensitivity]] "sensitivity"
[[IgnorePunctuation]] "ignorePunctuation"
[[Collation]] "collation"
[[Numeric]] "numeric" "kn"
[[CaseFirst]] "caseFirst" "kf"

10.3.3 get Intl.Collator.prototype.compare

この名前付きアクセサプロパティは、この Collator オブジェクトの並び順に従って2つの文字列を比較する関数を返す。

Intl.Collator.prototype.compare はアクセサプロパティであり、set アクセサ関数は undefined である。get アクセサ関数は次の手順を実行する:

  1. collatorthis 値とする。
  2. RequireInternalSlot(collator, [[InitializedCollator]]) を実行する。
  3. collator.[[BoundCompare]]undefined なら、
  4. func10.3.3.1 で定義された新しい組み込み関数オブジェクトとする。
  5. func.[[Collator]]collator を設定する。
  6. collator.[[BoundCompare]]func を設定する。
  7. collator.[[BoundCompare]] を返す。
Note
返される関数は collator にバインドされているため、Array.prototype.sort や他の関数に直接渡すことができる。

10.3.3.1 Collator 比較関数

Collator 比較関数は [[Collator]] 内部スロットを持つ匿名組み込み関数である。

Collator 比較関数 func が引数 xy で呼び出された場合、次の手順を実行する:

  1. collatorfunc.[[Collator]] とする。
  2. collator はオブジェクトであり、[[InitializedCollator]] 内部スロットを持つことをアサートする。
  3. x が指定されていない場合、xundefined とする。
  4. y が指定されていない場合、yundefined とする。
  5. xString を ? ToString(x) とする。
  6. yString を ? ToString(y) とする。
  7. CompareStrings(collator, xString, yString) を返す。

Collator 比較関数の "length" プロパティは 2𝔽 である。

10.3.3.2 CompareStrings ( collator, x, y )

The implementation-defined abstract operation CompareStrings takes arguments collator (an Intl.Collator), x (a String), and y (a String) and returns a Number, but not NaN. 返される数値は xy の実装依存のロケール感度の文字列比較結果を表す。 この結果は、collator の有効なロケールと照合オプションに従った文字列値の並び順に対応することを意図しており、xy より前の場合は負、後の場合は正、その他の場合はゼロ(相対的な順序なし)となる。 文字列値は ECMA-262 6.1.4 で説明されている UTF-16 コードユニット列として解釈され、文字列内のサロゲートペア(0xD800~0xDBFF のコードユニットの後に 0xDC00~0xDFFF のコードユニット)は対応するコードポイントとして解釈される。

以下の動作は、文字列の「基底文字」の並びをロケール感度で識別することに依存し、異なる基底文字は常に異なると比較される(それらを含む文字列も異なると比較される)。同じ基底文字のケースやダイアクリティカルマークなどの違いによる比較結果は、collator.[[Sensitivity]] により次のように異なる:

Table 4: Collator Sensitivity の効果
[[Sensitivity]] 説明 "a" vs. "á" "a" vs. "A"
"base" 同じ基底文字の文字は、ケースやダイアクリティカルマークの違いに関係なく異ならないと比較される。 等しい 等しい
"accent" 同じ基底文字の文字は、アクセントや他のダイアクリティカルマークの違いがある場合のみ異なると比較され、ケースの違いは無視される。 異なる 等しい
"case" 同じ基底文字の文字は、ケースの違いがある場合のみ異なると比較され、アクセントやダイアクリティカルマークの違いは無視される。 等しい 異なる
"variant" 同じ基底文字の文字は、ケースやダイアクリティカルマーク、その他の違いがある場合に異なると比較される。 異なる 異なる
Note 1
入力コードポイントから基底文字へのマッピングには、任意の収縮、拡張、衝突が含まれる場合があり、ダイアクリティカルマーク付き文字への特別な処理も適用されることがある。例えば、スウェーデン語では "ö" は "o" とは異なる基底文字であり、"v" と "w" は同じ基底文字とみなされる。スロバキア語では "ch" は単一の基底文字であり、英語では "æ" は "a" で始まり "e" で終わる基底文字列である。

collator.[[IgnorePunctuation]]true の場合、句読点は無視される(句読点だけが異なる文字列は等しいと比較される)。

ロケール拡張キーで設定可能なオプションの解釈については Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions を参照。

実際の戻り値は追加情報をエンコードできるよう実装依存であるが、この操作は任意の collator について、xy の関数として一貫した比較器となり、すべての文字列集合に対して全順序を定義することが要求される。また、Unicode 標準に従った正規等価性を認識し、区別可能な文字列が正規等価の場合は +0𝔽 を返すことが要求される。

Note 2
CompareStrings 抽象操作は Unicode Technical Standard #10: Unicode Collation Algorithm に従い、collator の有効なロケールと照合オプションのテーラリングを用いて実装することが推奨される。実装では Common Locale Data Repository(https://cldr.unicode.org/)のテーラリングを利用することが推奨される。
Note 3
同じ解決済みオプションを持つ Collator インスタンスでも、CompareStrings 抽象操作の動作は実装のバージョンによって異なる場合があることに注意すること。

10.3.4 Intl.Collator.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag% プロパティの初期値は文字列値 "Intl.Collator" である。

このプロパティの属性は { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } である。

10.4 Intl.Collator インスタンスのプロパティ

Intl.Collator インスタンスは %Intl.Collator.prototype% からプロパティを継承する通常のオブジェクトである。

Intl.Collator インスタンスは [[InitializedCollator]] 内部スロットを持つ。

Intl.Collator インスタンスは、Intl.Collator コンストラクター で計算される複数の内部スロットも持つ:

  • [[Locale]] は照合に使用されるロケールの言語タグを持つ文字列値である。
  • [[Usage]]"sort" または "search" のいずれかの文字列値であり、コレーターの用途を識別する。
  • [[Sensitivity]]"base", "accent", "case", "variant" のいずれかの文字列値であり、コレーターの感度を識別する。
  • [[IgnorePunctuation]] は Boolean 値であり、比較時に句読点を無視するかどうかを指定する。
  • [[Collation]] は照合に使用される Unicode Collation Identifier を表す文字列値であり、"standard" および "search" の値は許可されず、"default" の値は許可される。

Intl.Collator インスタンスは、Table 3 の内部スロット名に対応するキーが Intl.Collator の [[RelevantExtensionKeys]] 内部スロットに含まれている場合、次の内部スロットも持つ:

  • [[Numeric]] は Boolean 値であり、数値ソートを使用するかどうかを指定する。
  • [[CaseFirst]]"upper", "lower", "false" のいずれかの文字列値である。

最後に、Intl.Collator インスタンスは compare アクセサ (10.3.3) で返される関数をキャッシュする [[BoundCompare]] 内部スロットを持つ。

11 DateTimeFormat オブジェクト

11.1 Intl.DateTimeFormat コンストラクター

Intl.DateTimeFormat コンストラクターは次の通りである:

  • %Intl.DateTimeFormat% である。
  • Intl オブジェクトの "DateTimeFormat" プロパティの初期値である。

Intl オブジェクトのすべてのサービスコンストラクタープロパティに共通する挙動は、9.1 で規定される。

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

Intl.DateTimeFormat 関数が任意の引数 locales および options とともに呼び出されたとき、次の手順が実行される:

  1. NewTarget が undefined なら、newTarget をアクティブな関数オブジェクトとする。そうでなければ、newTarget を NewTarget とする。
  2. dateTimeFormat を ? CreateDateTimeFormat(newTarget, locales, options, any, date) とする。
  3. 実装が 4.3 Note 1 の規範的任意コンストラクターモードをサポートするなら、
    1. thisthis 値とする。
    2. ChainDateTimeFormat(dateTimeFormat, NewTarget, this) を返す。
  4. dateTimeFormat を返す。

11.1.1.1 ChainDateTimeFormat ( dateTimeFormat, newTarget, this )

The abstract operation ChainDateTimeFormat takes arguments dateTimeFormat (Intl.DateTimeFormat), newTarget (ECMAScript 言語値), and this (ECMAScript 言語値) and returns Object を含む正常完了、または throw 完了. It performs the following steps when called:

  1. newTargetundefined で、かつ ? OrdinaryHasInstance(%Intl.DateTimeFormat%, this) が true なら、
    1. DefinePropertyOrThrow(this, %Intl%.[[FallbackSymbol]], PropertyDescriptor { [[Value]]: dateTimeFormat, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }) を実行する。
    2. this を返す。
  2. dateTimeFormat を返す。

11.1.2 CreateDateTimeFormat ( newTarget, locales, options, required, defaults )

The abstract operation CreateDateTimeFormat takes arguments newTarget (コンストラクター), locales (ECMAScript 言語値), options (ECMAScript 言語値), required (datetime、または any), and defaults (datetime、または all) and returns DateTimeFormat オブジェクトを含む正常完了、または throw 完了. It performs the following steps when called:

  1. dateTimeFormat を ? OrdinaryCreateFromConstructor(newTarget, "%Intl.DateTimeFormat.prototype%", « [[InitializedDateTimeFormat]], [[Locale]], [[Calendar]], [[NumberingSystem]], [[TimeZone]], [[HourCycle]], [[DateStyle]], [[TimeStyle]], [[DateTimeFormat]], [[BoundFormat]] ») とする。
  2. specialOptionsRecord { [[Hour12]]: undefined } とする。
  3. modifyResolutionOptions を、specialOptions を捕捉し、呼び出されたときに次の手順を実行する、パラメーター (options) を持つ新しい Abstract Closure とする:
    1. specialOptions.[[Hour12]]options.[[hour12]] に設定する。
    2. options からフィールド [[hour12]] を取り除く。
    3. specialOptions.[[Hour12]]undefined でないなら、options.[[hc]]null に設定する。
  4. optionsResolution を ? ResolveOptions(%Intl.DateTimeFormat%, %Intl.DateTimeFormat%.[[LocaleData]], locales, options, « coerce-options », modifyResolutionOptions) とする。
  5. hour12specialOptions.[[Hour12]] とする。
  6. optionsoptionsResolution.[[Options]] に設定する。
  7. resolvedLocaleoptionsResolution.[[ResolvedLocale]] とする。
  8. dateTimeFormat.[[Locale]]resolvedLocale.[[Locale]] に設定する。
  9. resolvedCalendarresolvedLocale.[[ca]] とする。
  10. dateTimeFormat.[[Calendar]]resolvedCalendar に設定する。
  11. dateTimeFormat.[[NumberingSystem]]resolvedLocale.[[nu]] に設定する。
  12. resolvedLocaleDataresolvedLocale.[[LocaleData]] とする。
  13. hour12true なら、
    1. hcresolvedLocaleData.[[hourCycle12]] とする。
  14. そうでなく hour12false なら、
    1. hcresolvedLocaleData.[[hourCycle24]] とする。
  15. そうでなければ、
    1. Assert: hour12undefined である。
    2. hcresolvedLocale.[[hc]] とする。
    3. hcnull なら、hcresolvedLocaleData.[[hourCycle]] に設定する。
  16. timeZone を ? Get(options, "timeZone") とする。
  17. timeZoneundefined なら、
    1. timeZoneSystemTimeZoneIdentifier() に設定する。
  18. そうでなければ、
    1. timeZone を ? ToString(timeZone) に設定する。
  19. IsTimeZoneOffsetString(timeZone) が true なら、
    1. parseResultParseText(StringToCodePoints(timeZone), UTCOffset) とする。
    2. Assert: parseResultParse Node である。
    3. parseResult が複数の MinuteSecond Parse Node を含むなら、RangeError 例外を投げる。
    4. offsetNanosecondsParseTimeZoneOffsetString(timeZone) とする。
    5. offsetMinutesoffsetNanoseconds / (6 × 1010) とする。
    6. Assert: offsetMinutes は整数である。
    7. timeZoneFormatOffsetTimeZoneIdentifier(offsetMinutes) に設定する。
  20. そうでなければ、
    1. timeZoneIdentifierRecordGetAvailableNamedTimeZoneIdentifier(timeZone) とする。
    2. timeZoneIdentifierRecordempty なら、RangeError 例外を投げる。
    3. timeZonetimeZoneIdentifierRecord.[[PrimaryIdentifier]] に設定する。
  21. dateTimeFormat.[[TimeZone]]timeZone に設定する。
  22. formatOptions を新しい Record とする。
  23. formatOptions.[[hourCycle]]hc に設定する。
  24. hasExplicitFormatComponentsfalse とする。
  25. Table 16 の各行について、ヘッダー行を除き、表の順序で、次を行う。
    1. propertyKey を現在の行の Property 列で与えられた名前とする。
    2. propertyKey"fractionalSecondDigits" なら、
      1. value を ? GetNumberOption(options, "fractionalSecondDigits", 1, 3, undefined) とする。
    3. そうでなければ、
      1. values を現在の行の Values 列で与えられた文字列を要素とする List とする。
      2. value を ? GetOption(options, propertyKey, string, values, undefined) とする。
    4. formatOptions.[[<propertyKey>]] を value に設定する。
    5. valueundefined でないなら、
      1. hasExplicitFormatComponentstrue に設定する。
  26. formatMatcher を ? GetOption(options, "formatMatcher", string, « "basic", "best fit" », "best fit") とする。
  27. dateStyle を ? GetOption(options, "dateStyle", string, « "full", "long", "medium", "short" », undefined) とする。
  28. dateTimeFormat.[[DateStyle]]dateStyle に設定する。
  29. timeStyle を ? GetOption(options, "timeStyle", string, « "full", "long", "medium", "short" », undefined) とする。
  30. dateTimeFormat.[[TimeStyle]]timeStyle に設定する。
  31. dateStyleundefined でない、または timeStyleundefined でないなら、
    1. hasExplicitFormatComponentstrue なら、
      1. TypeError 例外を投げる。
    2. requireddate で、かつ timeStyleundefined でないなら、
      1. TypeError 例外を投げる。
    3. requiredtime で、かつ dateStyleundefined でないなら、
      1. TypeError 例外を投げる。
    4. stylesresolvedLocaleData.[[styles]].[[<resolvedCalendar>]] とする。
    5. bestFormatDateTimeStyleFormat(dateStyle, timeStyle, styles) とする。
  32. そうでなければ、
    1. needDefaultstrue とする。
    2. requireddate または any なら、
      1. « "weekday", "year", "month", "day" » の各プロパティ名 propertyKey について、次を行う。
        1. valueformatOptions.[[<propertyKey>]] とする。
        2. valueundefined でないなら、needDefaultsfalse に設定する。
    3. requiredtime または any なら、
      1. « "dayPeriod", "hour", "minute", "second", "fractionalSecondDigits" » の各プロパティ名 propertyKey について、次を行う。
        1. valueformatOptions.[[<propertyKey>]] とする。
        2. valueundefined でないなら、needDefaultsfalse に設定する。
    4. needDefaultstrue で、かつ defaultsdate または all のいずれかなら、
      1. « "year", "month", "day" » の各プロパティ名 propertyKey について、次を行う。
        1. formatOptions.[[<propertyKey>]] を "numeric" に設定する。
    5. needDefaultstrue で、かつ defaultstime または all のいずれかなら、
      1. « "hour", "minute", "second" » の各プロパティ名 propertyKey について、次を行う。
        1. formatOptions.[[<propertyKey>]] を "numeric" に設定する。
    6. formatsresolvedLocaleData.[[formats]].[[<resolvedCalendar>]] とする。
    7. formatMatcher"basic" なら、
      1. bestFormatBasicFormatMatcher(formatOptions, formats) とする。
    8. そうでなければ、
      1. bestFormatBestFitFormatMatcher(formatOptions, formats) とする。
  33. dateTimeFormat.[[DateTimeFormat]]bestFormat に設定する。
  34. bestFormat がフィールド [[hour]] を持つなら、
    1. dateTimeFormat.[[HourCycle]]hc に設定する。
  35. dateTimeFormat を返す。

11.1.3 FormatOffsetTimeZoneIdentifier ( offsetMinutes )

The abstract operation FormatOffsetTimeZoneIdentifier takes argument offsetMinutes (整数) and returns String. UTC オフセットを分単位で、±HH:MM のように整形された UTC オフセット文字列へ整形する。 It performs the following steps when called:

  1. offsetMinutes ≥ 0 なら、sign をコード単位 0x002B (PLUS SIGN) とする。そうでなければ、sign をコード単位 0x002D (HYPHEN-MINUS) とする。
  2. absoluteMinutesabs(offsetMinutes) とする。
  3. hoursfloor(absoluteMinutes / 60) とする。
  4. minutesabsoluteMinutes modulo 60 とする。
  5. signToZeroPaddedDecimalString(hours, 2)、コード単位 0x003A (COLON)、および ToZeroPaddedDecimalString(minutes, 2) の文字列連結を返す。

11.2 Intl.DateTimeFormat コンストラクターのプロパティ

Intl.DateTimeFormat コンストラクターは次の通りである:

  • 値が %Function.prototype% である [[Prototype]] 内部スロットを持つ。
  • 次のプロパティを持つ:

11.2.1 Intl.DateTimeFormat.prototype

Intl.DateTimeFormat.prototype の値は %Intl.DateTimeFormat.prototype% である。

このプロパティは属性 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } を持つ。

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

supportedLocalesOf メソッドが引数 locales および options とともに呼び出されたとき、次の手順が実行される:

  1. availableLocales%Intl.DateTimeFormat%.[[AvailableLocales]] とする。
  2. requestedLocales を ? CanonicalizeLocaleList(locales) とする。
  3. FilterLocales(availableLocales, requestedLocales, options) を返す。

11.2.3 内部スロット

[[AvailableLocales]] 内部スロットの値は、9.1 で記述される制約内で実装定義である。

[[RelevantExtensionKeys]] 内部スロットの値は « "ca", "hc", "nu" » である。

Note 1
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions は、日付および時刻の整形に関連する 4 つのロケール拡張キーを説明している: カレンダー用の "ca"、時制用の "hc"、(整形された数値の) 数体系用の "nu"、およびタイムゾーン用の "tz" である。ただし DateTimeFormat では、タイムゾーンは options オブジェクトの "timeZone" プロパティを通じて指定される必要がある。

[[ResolutionOptionDescriptors]] 内部スロットの値は « { [[Key]]: "ca", [[Property]]: "calendar" }, { [[Key]]: "nu", [[Property]]: "numberingSystem" }, { [[Key]]: "hour12", [[Property]]: "hour12", [[Type]]: boolean }, { [[Key]]: "hc", [[Property]]: "hourCycle", [[Values]]: « "h11", "h12", "h23", "h24" » } » である。

[[LocaleData]] 内部スロットの値は、9.1 で記述される制約、およびすべてのロケール値 locale について次の追加制約の範囲内で、実装定義である:

  • [[LocaleData]].[[<locale>]].[[nu]] は、値 "native""traditio"、または "finance" を含まない List でなければならない。
  • [[LocaleData]].[[<locale>]].[[hc]] は « null, "h11", "h12", "h23", "h24" » でなければならない。
  • [[LocaleData]].[[<locale>]].[[hourCycle]] は Strings "h11""h12""h23"、または "h24" のいずれかでなければならない。
  • [[LocaleData]].[[<locale>]].[[hourCycle12]] は Strings "h11" または "h12" のいずれかでなければならない。
  • [[LocaleData]].[[<locale>]].[[hourCycle24]] は Strings "h23" または "h24" のいずれかでなければならない。
  • [[LocaleData]].[[<locale>]] は [[formats]] フィールドを持たなければならない。この [[formats]] フィールドの値は、各カレンダー値 calendar について [[<calendar>]] フィールドを持つ Record でなければならない。各 [[<calendar>]] フィールドの値は、DateTime Format RecordsList でなければならない。そのような List 内の複数の Records は、対応する値が少なくとも 1 つのフィールドで異なる限り、同じフィールドの部分集合を使用してよい。各ロケールについて、次の部分集合が利用可能でなければならない:
    • weekday, year, month, day, hour, minute, second, fractionalSecondDigits
    • weekday, year, month, day, hour, minute, second
    • weekday, year, month, day
    • year, month, day
    • year, month
    • month, day
    • month
    • hour, minute, second, fractionalSecondDigits
    • hour, minute, second
    • hour, minute
    • dayPeriod, hour, minute, second, fractionalSecondDigits
    • dayPeriod, hour, minute, second
    • dayPeriod, hour, minute
    • dayPeriod, hour
  • [[LocaleData]].[[<locale>]] は [[styles]] フィールドを持たなければならない。この [[styles]] フィールドの値は、各カレンダー値 calendar について [[<calendar>]] フィールドを持つ Record でなければならない。各 [[<calendar>]] フィールドの値は DateTime Styles Record でなければならない。

11.2.3.1 DateTime Format Records

DateTime Format Record は、Table 5 で定義されるフィールドを持つ。

Table 5: DateTime Format Record
フィールド名 値の型 説明
[[weekday]] Table 16 の Values 列にある [[Weekday]] 任意フィールド。[[pattern]] が部分文字列 "{weekday}" を含む場合に存在する。
[[era]] Table 16 の Values 列にある [[Era]] 任意フィールド。[[pattern]] が部分文字列 "{era}" を含む場合に存在する。
[[year]] Table 16 の Values 列にある [[Year]] 任意フィールド。[[pattern]] が部分文字列 "{year}""{yearName}"、または "{relatedYear}" の少なくとも 1 つを含む場合に存在する。
[[month]] Table 16 の Values 列にある [[Month]] 任意フィールド。[[pattern]] が部分文字列 "{month}" を含む場合に存在する。
[[day]] Table 16 の Values 列にある [[Day]] 任意フィールド。[[pattern]] が部分文字列 "{day}" を含む場合に存在する。
[[dayPeriod]] Table 16 の Values 列にある [[DayPeriod]] 任意フィールド。[[pattern]] が部分文字列 "{dayPeriod}" を含む場合に存在する。
[[hour]] Table 16 の Values 列にある [[Hour]] 任意フィールド。[[pattern]] が部分文字列 "{hour}" を含む場合に存在する。
[[minute]] Table 16 の Values 列にある [[Minute]] 任意フィールド。[[pattern]] が部分文字列 "{minute}" を含む場合に存在する。
[[second]] Table 16 の Values 列にある [[Second]] 任意フィールド。[[pattern]] が部分文字列 "{second}" を含む場合に存在する。
[[fractionalSecondDigits]] Table 16 の Values 列にある [[FractionalSecondDigits]] 任意フィールド。[[pattern]] が部分文字列 "{fractionalSecondDigits}" を含む場合に存在する。
[[timeZoneName]] Table 16 の Values 列にある [[TimeZoneName]] 任意フィールド。[[pattern]] が部分文字列 "{timeZoneName}" を含む場合に存在する。
[[pattern]] Pattern String レコードの日付および時刻書式コンポーネントフィールドのそれぞれについて、"{" で始まり、フィールド名が続き、"}" が続く部分文字列を Contains する。レコードが [[year]] フィールドを持つ場合、この文字列は部分文字列 "{yearName}" および "{relatedYear}" を含んでよい。
[[pattern12]] Pattern String 任意フィールド。[[hour]] フィールドが存在する場合に存在する。[[pattern]] フィールドの部分文字列に加えて、部分文字列 "{ampm}" または "{dayPeriod}" の少なくとも 1 つを含む。
[[rangePatterns]] DateTime Range Pattern Record このフィールド内のパターン文字列は [[pattern]] と同様である。
[[rangePatterns12]] DateTime Range Pattern Record 任意フィールド。[[hour]] フィールドが存在する場合に存在する。このフィールド内のパターン文字列は [[pattern12]] と同様である。

11.2.3.2 DateTime Range Pattern Records

DateTime Range Pattern Record は、Table 6 で定義されるフィールドを持つ。

Table 6: DateTime Range Pattern Record
フィールド名 値の型 説明
[[Default]] DateTime Range Pattern Format Record より具体的な範囲パターンが利用できない場合に使用される既定の範囲パターンを含む。
[[Era]] DateTime Range Pattern Format Record 任意フィールド。era が開始日と終了日の間で異なる最大のカレンダー要素である場合に使用される。
[[Year]] DateTime Range Pattern Format Record 任意フィールド。year が開始日と終了日の間で異なる最大のカレンダー要素である場合に使用される。
[[Month]] DateTime Range Pattern Format Record 任意フィールド。month が開始日と終了日の間で異なる最大のカレンダー要素である場合に使用される。
[[Day]] DateTime Range Pattern Format Record 任意フィールド。day が開始日と終了日の間で異なる最大のカレンダー要素である場合に使用される。
[[AmPm]] DateTime Range Pattern Format Record 任意フィールド。ante または post meridiem が開始日と終了日の間で異なる最大のカレンダー要素である場合に使用される。
[[DayPeriod]] DateTime Range Pattern Format Record 任意フィールド。day period が開始日と終了日の間で異なる最大のカレンダー要素である場合に使用される。
[[Hour]] DateTime Range Pattern Format Record 任意フィールド。hour が開始日と終了日の間で異なる最大のカレンダー要素である場合に使用される。
[[Minute]] DateTime Range Pattern Format Record 任意フィールド。minute が開始日と終了日の間で異なる最大のカレンダー要素である場合に使用される。
[[Second]] DateTime Range Pattern Format Record 任意フィールド。second が開始日と終了日の間で異なる最大のカレンダー要素である場合に使用される。
[[FractionalSecondDigits]] DateTime Range Pattern Format Record 任意フィールド。fractional seconds が開始日と終了日の間で異なる最大のカレンダー要素である場合に使用される。

11.2.3.3 DateTime Range Pattern Format Records

DateTime Range Pattern Format Record は、Table 7 で定義されるフィールドを持つ。

Table 7: DateTime Range Pattern Format Record
フィールド名 値の型 説明
[[weekday]] Table 16 の Values 列にある [[Weekday]] 任意フィールド。[[PatternParts]] 内の Pattern String が部分文字列 "{weekday}" を含む場合に存在する。
[[era]] Table 16 の Values 列にある [[Era]] 任意フィールド。[[PatternParts]] 内の Pattern String が部分文字列 "{era}" を含む場合に存在する。
[[year]] Table 16 の Values 列にある [[Year]] 任意フィールド。[[PatternParts]] 内の Pattern String が部分文字列 "{year}""{yearName}"、または "{relatedYear}" の少なくとも 1 つを含む場合に存在する。
[[month]] Table 16 の Values 列にある [[Month]] 任意フィールド。[[PatternParts]] 内の Pattern String が部分文字列 "{month}" を含む場合に存在する。
[[day]] Table 16 の Values 列にある [[Day]] 任意フィールド。[[PatternParts]] 内の Pattern String が部分文字列 "{day}" を含む場合に存在する。
[[dayPeriod]] Table 16 の Values 列にある [[DayPeriod]] 任意フィールド。[[PatternParts]] 内の Pattern String が部分文字列 "{dayPeriod}" を含む場合に存在する。
[[hour]] Table 16 の Values 列にある [[Hour]] 任意フィールド。[[PatternParts]] 内の Pattern String が部分文字列 "{hour}" を含む場合に存在する。
[[minute]] Table 16 の Values 列にある [[Minute]] 任意フィールド。[[PatternParts]] 内の Pattern String が部分文字列 "{minute}" を含む場合に存在する。
[[second]] Table 16 の Values 列にある [[Second]] 任意フィールド。[[PatternParts]] 内の Pattern String が部分文字列 "{second}" を含む場合に存在する。
[[fractionalSecondDigits]] Table 16 の Values 列にある [[FractionalSecondDigits]] 任意フィールド。[[PatternParts]] 内の Pattern String が部分文字列 "{fractionalSecondDigits}" を含む場合に存在する。
[[timeZoneName]] Table 16 の Values 列にある [[TimeZoneName]] 任意フィールド。[[PatternParts]] 内の Pattern String が部分文字列 "{timeZoneName}" を含む場合に存在する。
[[PatternParts]] DateTime Range Pattern Part RecordsList 各レコードは範囲パターンの一部を表す。

11.2.3.4 DateTime Range Pattern Part Records

DateTime Range Pattern Part Record は、Table 8 で定義されるフィールドを持つ。

Table 8: DateTime Range Pattern Part Record
フィールド名 値の型 説明
[[Source]] "shared""startRange"、または "endRange" 範囲の日付のうちどれを [[Pattern]] フィールドの値を用いて整形すべきかを示す。
[[Pattern]] Pattern String 通常の日付パターン文字列と同じ形式の String。

11.2.3.5 DateTime Styles Records

DateTime Styles Record は、Table 9 で定義されるフィールドを持つ。

Table 9: DateTime Styles Record
フィールド名 値の型
[[Date]] DateTime Style Record
[[Time]] DateTime Style Record
[[Connector]] DateTime Connector Record
[[DateTimeRangeFormat]] DateTime Date Range Record

11.2.3.6 DateTime Style Records

DateTime Style Record は、Table 10 で定義されるフィールドを持つ。

Table 10: DateTime Style Record
フィールド名 値の型 説明
[[full]] DateTime Format Record "full" スタイル用の書式レコード。
[[long]] DateTime Format Record "long" スタイル用の書式レコード。
[[medium]] DateTime Format Record "medium" スタイル用の書式レコード。
[[short]] DateTime Format Record "short" スタイル用の書式レコード。

11.2.3.7 DateTime Connector Records

DateTime Connector Record は、Table 11 で定義されるフィールドを持つ。すべてのコネクターパターン文字列は、文字列 "{0}" および "{1}" を含まなければならない。

Table 11: DateTime Connector Record
フィールド名 値の型 説明
[[full]] Pattern String 日付スタイルが "full" の場合のコネクターパターン。
[[long]] Pattern String 日付スタイルが "long" の場合のコネクターパターン。
[[medium]] Pattern String 日付スタイルが "medium" の場合のコネクターパターン。
[[short]] Pattern String 日付スタイルが "short" の場合のコネクターパターン。

11.2.3.8 DateTime Date Range Records

DateTime Date Range Record は、Table 12 で定義されるフィールドを持つ。

Table 12: DateTime Date Range Record
フィールド名 値の型 説明
[[full]] DateTime Time Range Record 日付スタイルが "full" の場合に使用される。
[[long]] DateTime Time Range Record 日付スタイルが "long" の場合に使用される。
[[medium]] DateTime Time Range Record 日付スタイルが "medium" の場合に使用される。
[[short]] DateTime Time Range Record 日付スタイルが "short" の場合に使用される。

11.2.3.9 DateTime Time Range Records

DateTime Time Range Record は、Table 13 で定義されるフィールドを持つ。

Table 13: DateTime Time Range Record
フィールド名 値の型 説明
[[full]] DateTime Style Range Record 時刻スタイルが "full" の場合に使用される。
[[long]] DateTime Style Range Record 時刻スタイルが "long" の場合に使用される。
[[medium]] DateTime Style Range Record 時刻スタイルが "medium" の場合に使用される。
[[short]] DateTime Style Range Record 時刻スタイルが "short" の場合に使用される。

11.2.3.10 DateTime Style Range Records

DateTime Style Range Record は、Table 14 で定義されるフィールドを持つ。

Table 14: DateTime Style Range Record
フィールド名 値の型 説明
[[rangePatterns]] DateTime Range Pattern Record 日付および時刻スタイルを組み合わせるための範囲パターン。
[[rangePatterns12]] DateTime Range Pattern Record 任意フィールド。12 時間形式の日付および時刻スタイルを組み合わせるための範囲パターン。
Note 2
例えば、実装は英語ロケールデータの一部として次の Record を含んでよい:
  • [[hour]]: "numeric"
  • [[minute]]: "numeric"
  • [[pattern]]: "{hour}:{minute}"
  • [[pattern12]]: "{hour}:{minute} {ampm}"
  • [[rangePatterns]]:
    • [[Hour]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
    • [[Minute]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
    • [[Default]]:
      • [[year]]: "2-digit"
      • [[month]]: "numeric"
      • [[day]]: "numeric"
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute}"}
  • [[rangePatterns12]]:
    • [[Hour]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " {ampm}"}
    • [[Minute]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " {ampm}"}
    • [[Default]]:
      • [[year]]: "2-digit"
      • [[month]]: "numeric"
      • [[day]]: "numeric"
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute} {ampm}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute} {ampm}"}
Note 3
実装は、Common Locale Data Repository が提供するロケールデータ (https://cldr.unicode.org/ で利用可能) を使用することが推奨される。

11.3 Intl.DateTimeFormat プロトタイプオブジェクトのプロパティ

Intl.DateTimeFormat プロトタイプオブジェクトは次の通りである:

  • %Intl.DateTimeFormat.prototype% である。
  • 通常のオブジェクトである。
  • Intl.DateTimeFormat インスタンスではなく、[[InitializedDateTimeFormat]] 内部スロットも、Intl.DateTimeFormat インスタンスオブジェクトの他の内部スロットも持たない。
  • 値が %Object.prototype% である [[Prototype]] 内部スロットを持つ。

11.3.1 Intl.DateTimeFormat.prototype.constructor

Intl.DateTimeFormat.prototype.constructor の初期値は %Intl.DateTimeFormat% である。

11.3.2 Intl.DateTimeFormat.prototype.resolvedOptions ( )

この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。

  1. dtfthis 値とする。
  2. 実装が 4.3 Note 1 の規範的任意コンストラクターモードをサポートするなら、
    1. dtf を ? UnwrapDateTimeFormat(dtf) に設定する。
  3. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]) を実行する。
  4. optionsOrdinaryObjectCreate(%Object.prototype%) とする。
  5. Table 15 の各行について、ヘッダー行を除き、表の順序で、次を行う。
    1. propertyKey を現在の行の Property 値とする。
    2. 現在の行に Internal Slot 値があるなら、
      1. value を、現在の行の Internal Slot 値を名前とする dtf の内部スロットの値とする。
    3. そうでなければ、
      1. formatdtf.[[DateTimeFormat]] とする。
      2. format がフィールド [[<propertyKey>]] を持ち、かつ dtf.[[DateStyle]]undefined で、かつ dtf.[[TimeStyle]]undefined なら、
        1. valueformat.[[<propertyKey>]] とする。
      3. そうでなければ、
        1. valueundefined とする。
    4. valueundefined でないなら、
      1. 現在の行に Conversion 値があるなら、
        1. conversion を現在の行の Conversion 値とする。
        2. conversionhour12 なら、
          1. value"h11" または "h12" なら、valuetrue に設定する。そうでなければ、valuefalse に設定する。
        3. そうでなければ、
          1. Assert: conversionnumber である。
          2. value𝔽(value) に設定する。
      2. CreateDataPropertyOrThrow(options, propertyKey, value) を実行する。
  6. options を返す。
Table 15: DateTimeFormat インスタンスの解決済みオプション
内部スロット プロパティ 変換
[[Locale]] "locale"
[[Calendar]] "calendar"
[[NumberingSystem]] "numberingSystem"
[[TimeZone]] "timeZone"
[[HourCycle]] "hourCycle"
[[HourCycle]] "hour12" hour12
"weekday"
"era"
"year"
"month"
"day"
"dayPeriod"
"hour"
"minute"
"second"
"fractionalSecondDigits" number
"timeZoneName"
[[DateStyle]] "dateStyle"
[[TimeStyle]] "timeStyle"

Web 互換性上の理由から、プロパティ "hourCycle" が設定されている場合、"hourCycle""h11" または "h12" のときは "hour12" プロパティを true に設定し、"hourCycle""h23" または "h24" のときは false に設定すべきである。

Note 1
このバージョンの API では、Intl.DateTimeFormat コンストラクターに提供された options オブジェクトに "timeZone" プロパティが提供されていない場合、"timeZone" プロパティはホスト環境のタイムゾーンの識別子になる。第 1 版では、この場合 "timeZone" プロパティは undefined のままにされていた。
Note 2
第 5 版より前のバージョンとの互換性のため、"hour12" プロパティは "hourCycle" プロパティに加えて設定される。

11.3.3 get Intl.DateTimeFormat.prototype.format

Intl.DateTimeFormat.prototype.format は、set アクセサー関数が undefined であるアクセサープロパティである。その get アクセサー関数は次の手順を実行する:

  1. dtfthis 値とする。
  2. 実装が 4.3 Note 1 の規範的任意コンストラクターモードをサポートするなら、
    1. dtf を ? UnwrapDateTimeFormat(dtf) に設定する。
  3. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]) を実行する。
  4. dtf.[[BoundFormat]]undefined なら、
    1. func を、DateTime Format Functions (11.5.4) で定義される新しい組み込み関数オブジェクトとする。
    2. func.[[DateTimeFormat]]dtf に設定する。
    3. dtf.[[BoundFormat]]func に設定する。
  5. dtf.[[BoundFormat]] を返す。
Note
返される関数は dtf に束縛されているため、Array.prototype.map または他の関数に直接渡すことができる。 これは、もはや新機能では従われない慣例の一部として歴史的な遺物と見なされるが、既存のプログラムとの互換性を維持するために保存されている。

11.3.4 Intl.DateTimeFormat.prototype.formatRange ( startDate, endDate )

formatRange メソッドが引数 startDate および endDate とともに呼び出されたとき、次の手順が実行される:

  1. dtfthis 値とする。
  2. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]) を実行する。
  3. startDateundefined または endDateundefined なら、TypeError 例外を投げる。
  4. x を ? ToNumber(startDate) とする。
  5. y を ? ToNumber(endDate) とする。
  6. FormatDateTimeRange(dtf, x, y) を返す。

11.3.5 Intl.DateTimeFormat.prototype.formatRangeToParts ( startDate, endDate )

formatRangeToParts メソッドが引数 startDate および endDate とともに呼び出されたとき、次の手順が実行される:

  1. dtfthis 値とする。
  2. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]) を実行する。
  3. startDateundefined または endDateundefined なら、TypeError 例外を投げる。
  4. x を ? ToNumber(startDate) とする。
  5. y を ? ToNumber(endDate) とする。
  6. FormatDateTimeRangeToParts(dtf, x, y) を返す。

11.3.6 Intl.DateTimeFormat.prototype.formatToParts ( date )

formatToParts メソッドが引数 date とともに呼び出されたとき、次の手順が実行される:

  1. dtfthis 値とする。
  2. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]) を実行する。
  3. dateundefined なら、
    1. x を ! Call(%Date.now%, undefined) とする。
  4. そうでなければ、
    1. x を ? ToNumber(date) とする。
  5. FormatDateTimeToParts(dtf, x) を返す。

11.3.7 Intl.DateTimeFormat.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag% プロパティの初期値は String "Intl.DateTimeFormat" である。

このプロパティは属性 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } を持つ。

11.4 Intl.DateTimeFormat インスタンスのプロパティ

Intl.DateTimeFormat インスタンスは、%Intl.DateTimeFormat.prototype% からプロパティを継承する通常のオブジェクトである。

Intl.DateTimeFormat インスタンスは [[InitializedDateTimeFormat]] 内部スロットを持つ。

Intl.DateTimeFormat インスタンスは、Intl.DateTimeFormat コンストラクター によって計算されるいくつかの内部スロットも持つ:

  • [[Locale]] は、整形に使用されるローカライズのロケールの言語タグを表す String である。
  • [[Calendar]] は、整形に使用される Unicode Calendar Identifier を表す String である。
  • [[NumberingSystem]] は、整形に使用される Unicode Number System Identifier を表す String である。
  • [[TimeZone]] は、整形に使用される String であり、利用可能な名前付きタイムゾーン識別子またはオフセットタイムゾーン識別子のいずれかである。
  • [[HourCycle]] は、12 時間形式 ("h11""h12") または 24 時間形式 ("h23""h24") のどちらを使用すべきかを示す String である。"h11" および "h23" はそれぞれ時 0 から始まり、11 および 23 まで進む。"h12" および "h24" は時 1 から始まり、12 および 24 まで進む。[[HourCycle]] は、[[DateTimeFormat]][[hour]] フィールドを持つ場合にのみ使用される。
  • [[DateStyle]][[TimeStyle]] はそれぞれ undefined"full""long""medium"、または "short" のいずれかである。
  • [[DateTimeFormat]]DateTime Format Record である。

最後に、Intl.DateTimeFormat インスタンスは、format アクセサー (11.3.3) によって返される関数をキャッシュする [[BoundFormat]] 内部スロットを持つ。

11.5 DateTimeFormat オブジェクトの抽象操作

いくつかの DateTimeFormat アルゴリズムは、次の表の値を使用する。この表は、日付および時刻書式のコンポーネントについて、内部スロット、プロパティ名、および許容値を提供する:

Table 16: 日付および時刻書式のコンポーネント
フィールド名 プロパティ
[[Weekday]] "weekday" "narrow", "short", "long"
[[Era]] "era" "narrow", "short", "long"
[[Year]] "year" "2-digit", "numeric"
[[Month]] "month" "2-digit", "numeric", "narrow", "short", "long"
[[Day]] "day" "2-digit", "numeric"
[[DayPeriod]] "dayPeriod" "narrow", "short", "long"
[[Hour]] "hour" "2-digit", "numeric"
[[Minute]] "minute" "2-digit", "numeric"
[[Second]] "second" "2-digit", "numeric"
[[FractionalSecondDigits]] "fractionalSecondDigits" 1, 2, 3
[[TimeZoneName]] "timeZoneName" "short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"

11.5.1 DateTimeStyleFormat ( dateStyle, timeStyle, styles )

The abstract operation DateTimeStyleFormat takes arguments dateStyle ("full""long""medium""short"、または undefined), timeStyle ("full""long""medium""short"、または undefined), and styles (DateTime Styles Record) and returns DateTime Format Record. styles は、何らかのロケール locale およびカレンダー calendar についての %Intl.DateTimeFormat%.[[LocaleData]].[[<locale>]].[[styles]].[[<calendar>]] からの Record である。これはパラメーターに基づいて、日付時刻整形のための適切な format Record を返す。 It performs the following steps when called:

#### ECMARKDOWN PARSE FAILED ####
        1. Assert: _dateStyle_ は *undefined* でない、または _timeStyle_ は *undefined* でない。
        1. _timeStyle_ が *undefined* でないなら、
          1. Assert: _timeStyle_ は *"full"*、*"long"*、*"medium"*、または *"short"* のいずれかである。
          1. _timeFormat_ を _styles_.[[Time]].[[<_timeStyle_>]] とする。
        1. _dateStyle_ が *undefined* でないなら、
          1. Assert: _dateStyle_ は *"full"*、*"long"*、*"medium"*、または *"short"* のいずれかである。
          1. _dateFormat_ を _styles_.[[Date]].[[<_dateStyle_>]] とする。
        1. _dateStyle_ が *undefined* でなく、かつ _timeStyle_ が *undefined* でないなら、
          1. _format_ を新しい DateTime Format Record とする。
          1. [[pattern]] および [[rangePatterns]] を除く _dateFormat_ のすべてのフィールドを _format_ に追加する。
          1. [[pattern]]、[[rangePatterns]]、[[pattern12]]、および存在する場合は [[rangePatterns12]] を除く _timeFormat_ のすべてのフィールドを _format_ に追加する。
          1. _connector_ を _styles_.[[Connector]].[[<_dateStyle_>]] とする。
          1. _pattern_ を、_connector_ 内の部分文字列 *"{0}"* を _timeFormat_.[[pattern]] に、部分文字列 *"{1}"* を _dateFormat_.[[pattern]] に置き換えた文字列とする。
          1. _format_.[[pattern]] を _pattern_ に設定する。
          1. _timeFormat_ が [[pattern12]] フィールドを持つなら、
            1. _pattern12_ を、_connector_ 内の部分文字列 *"{0}"* を _timeFormat_.[[pattern12]] に、部分文字列 *"{1}"* を _dateFormat_.[[pattern]] に置き換えた文字列とする。
            1. _format_.[[pattern12]] を _pattern12_ に設定する。
          1. _dateTimeRangeFormat_ を _styles_.[[DateTimeRangeFormat]].[[<_dateStyle_>]].[[<_timeStyle_>]] とする。
          1. _format_.[[rangePatterns]] を _dateTimeRangeFormat_.[[rangePatterns]] に設定する。
          1. _dateTimeRangeFormat_ が [[rangePatterns12]] フィールドを持つなら、
            1. _format_.[[rangePatterns12]] を _dateTimeRangeFormat_.[[rangePatterns12]] に設定する。
          1. _format_ を返す。
        1. _timeStyle_ が *undefined* でないなら、
          1. _timeFormat_ を返す。
        1. Assert: _dateStyle_ は *undefined* でない。
        1. _dateFormat_ を返す。
      

11.5.2 BasicFormatMatcher ( options, formats )

The abstract operation BasicFormatMatcher takes arguments options (Record) and formats (DateTime Format RecordsList) and returns DateTime Format Record. It performs the following steps when called:

  1. removalPenalty を 120 とする。
  2. additionPenalty を 20 とする。
  3. longLessPenalty を 8 とする。
  4. longMorePenalty を 6 とする。
  5. shortLessPenalty を 6 とする。
  6. shortMorePenalty を 3 とする。
  7. offsetPenalty を 1 とする。
  8. bestScore を -∞ とする。
  9. bestFormatundefined とする。
  10. formats の各要素 format について、次を行う。
    1. score を 0 とする。
    2. Table 16 の各行について、ヘッダー行を除き、表の順序で、次を行う。
      1. property を現在の行の Property 列で与えられた名前とする。
      2. options がフィールド [[<property>]] を持つなら、optionsPropoptions.[[<property>]] とする。そうでなければ optionsPropundefined とする。
      3. format がフィールド [[<property>]] を持つなら、formatPropformat.[[<property>]] とする。そうでなければ formatPropundefined とする。
      4. optionsPropundefined で、かつ formatPropundefined でないなら、
        1. scorescore - additionPenalty に設定する。
      5. そうでなく optionsPropundefined でなく、かつ formatPropundefined なら、
        1. scorescore - removalPenalty に設定する。
      6. そうでなく property"timeZoneName" なら、
        1. optionsProp"short" または "shortGeneric" なら、
          1. formatProp"shortOffset" なら、scorescore - offsetPenalty に設定する。
          2. そうでなく formatProp"longOffset" なら、scorescore - (offsetPenalty + shortMorePenalty) に設定する。
          3. そうでなく optionsProp"short" で、かつ formatProp"long" なら、scorescore - shortMorePenalty に設定する。
          4. そうでなく optionsProp"shortGeneric" で、かつ formatProp"longGeneric" なら、scorescore - shortMorePenalty に設定する。
          5. そうでなく optionsPropformatProp なら、scorescore - removalPenalty に設定する。
        2. そうでなく optionsProp"shortOffset" で、かつ formatProp"longOffset" なら、
          1. scorescore - shortMorePenalty に設定する。
        3. そうでなく optionsProp"long" または "longGeneric" なら、
          1. formatProp"longOffset" なら、scorescore - offsetPenalty に設定する。
          2. そうでなく formatProp"shortOffset" なら、scorescore - (offsetPenalty + longLessPenalty) に設定する。
          3. そうでなく optionsProp"long" で、かつ formatProp"short" なら、scorescore - longLessPenalty に設定する。
          4. そうでなく optionsProp"longGeneric" で、かつ formatProp"shortGeneric" なら、scorescore - longLessPenalty に設定する。
          5. そうでなく optionsPropformatProp なら、scorescore - removalPenalty に設定する。
        4. そうでなく optionsProp"longOffset" で、かつ formatProp"shortOffset" なら、
          1. scorescore - longLessPenalty に設定する。
        5. そうでなく optionsPropformatProp なら、
          1. scorescore - removalPenalty に設定する。
      7. そうでなく optionsPropformatProp なら、
        1. property"fractionalSecondDigits" なら、
          1. values を « 1, 2, 3 » とする。
        2. そうでなければ、
          1. values を « "2-digit", "numeric", "narrow", "short", "long" » とする。
        3. optionsPropIndexvalues 内の optionsProp のインデックスとする。
        4. formatPropIndexvalues 内の formatProp のインデックスとする。
        5. deltamax(min(formatPropIndex - optionsPropIndex, 2), -2) とする。
        6. delta = 2 なら、scorescore - longMorePenalty に設定する。
        7. そうでなく delta = 1 なら、scorescore - shortMorePenalty に設定する。
        8. そうでなく delta = -1 なら、scorescore - shortLessPenalty に設定する。
        9. そうでなく delta = -2 なら、scorescore - longLessPenalty に設定する。
    3. score > bestScore なら、
      1. bestScorescore に設定する。
      2. bestFormatformat に設定する。
  11. bestFormat を返す。

11.5.3 BestFitFormatMatcher ( options, formats )

The implementation-defined abstract operation BestFitFormatMatcher takes arguments options (Record) and formats (DateTime Format RecordsList) and returns DateTime Format Record. 選択されたロケールの典型的な利用者が、BasicFormatMatcher によって返されるものと少なくとも同程度に良いと認識するコンポーネント表現の集合を返す。

11.5.4 DateTime Format Functions

DateTime format function は、[[DateTimeFormat]] 内部スロットを持つ匿名の組み込み関数である。

DateTime format function func が任意の引数 date とともに呼び出されたとき、次の手順が実行される:

  1. dtffunc.[[DateTimeFormat]] とする。
  2. Assert: dtf は Object であり、dtf[[InitializedDateTimeFormat]] 内部スロットを持つ。
  3. date が提供されていない、または undefined なら、
    1. x を ! Call(%Date.now%, undefined) とする。
  4. そうでなければ、
    1. x を ? ToNumber(date) とする。
  5. FormatDateTime(dtf, x) を返す。

DateTime format function の "length" プロパティは 1𝔽 である。

11.5.5 FormatDateTimePattern ( dateTimeFormat, format, pattern, epochNanoseconds )

The abstract operation FormatDateTimePattern takes arguments dateTimeFormat (Intl.DateTimeFormat), format (DateTime Format Record または DateTime Range Pattern Format Record), pattern (Pattern String), and epochNanoseconds (BigInt) and returns フィールド [[Type]] (String) および [[Value]] (String) を持つ RecordsList. pattern に従い、また dateTimeFormat および format の実効ロケールと整形オプションに従って、エポック時刻 epochNanoseconds に対応する parts を作成する。 It performs the following steps when called:

  1. localedateTimeFormat.[[Locale]] とする。
  2. nfOptionsOrdinaryObjectCreate(null) とする。
  3. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", dateTimeFormat.[[NumberingSystem]]) を実行する。
  4. CreateDataPropertyOrThrow(nfOptions, "useGrouping", false) を実行する。
  5. nf を ! Construct(%Intl.NumberFormat%, « locale, nfOptions ») とする。
  6. nf2OptionsOrdinaryObjectCreate(null) とする。
  7. CreateDataPropertyOrThrow(nf2Options, "minimumIntegerDigits", 2𝔽) を実行する。
  8. CreateDataPropertyOrThrow(nf2Options, "numberingSystem", dateTimeFormat.[[NumberingSystem]]) を実行する。
  9. CreateDataPropertyOrThrow(nf2Options, "useGrouping", false) を実行する。
  10. nf2 を ! Construct(%Intl.NumberFormat%, « locale, nf2Options ») とする。
  11. format がフィールド [[fractionalSecondDigits]] を持つなら、
    1. fractionalSecondDigitsformat.[[fractionalSecondDigits]] とする。
    2. nf3OptionsOrdinaryObjectCreate(null) とする。
    3. CreateDataPropertyOrThrow(nf3Options, "minimumIntegerDigits", 𝔽(fractionalSecondDigits)) を実行する。
    4. CreateDataPropertyOrThrow(nf3Options, "numberingSystem", dateTimeFormat.[[NumberingSystem]]) を実行する。
    5. CreateDataPropertyOrThrow(nf3Options, "useGrouping", false) を実行する。
    6. nf3 を ! Construct(%Intl.NumberFormat%, « locale, nf3Options ») とする。
  12. localTimeToLocalTime(epochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]]) とする。
  13. patternPartsPartitionPattern(pattern) とする。
  14. result を新しい空の List とする。
  15. patternParts の各 Record { [[Type]], [[Value]] } patternPart について、次を行う。
    1. partTypepatternPart.[[Type]] とする。
    2. partType"literal" なら、
      1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] } を result に追加する。
    3. そうでなく partType"fractionalSecondDigits" なら、
      1. Assert: format はフィールド [[fractionalSecondDigits]] を持つ。
      2. valuelocalTime.[[Millisecond]] とする。
      3. valuefloor(value × 10( fractionalSecondDigits - 3 )) に設定する。
      4. formattedValueFormatNumeric(nf3, value) とする。
      5. Record { [[Type]]: "fractionalSecond", [[Value]]: formattedValue } を result に追加する。
    4. そうでなく partType"dayPeriod" なら、
      1. Assert: format はフィールド [[dayPeriod]] を持つ。
      2. fieldFormatformat.[[dayPeriod]] とする。
      3. formattedValue を、fieldFormat によって与えられる形式の localTime の day period を表す ILD String とする。
      4. Record { [[Type]]: partType, [[Value]]: formattedValue } を result に追加する。
    5. そうでなく partType"timeZoneName" なら、
      1. Assert: format はフィールド [[timeZoneName]] を持つ。
      2. fieldFormatformat.[[timeZoneName]] とする。
      3. valuedateTimeFormat.[[TimeZone]] とする。
      4. formattedValue を、fieldFormat によって与えられる形式の value を表す ILD String とする。その値は、fieldFormat"short""long""shortOffset"、または "longOffset" である場合、localTime[[InDST]] フィールドの値に依存してよい。実装がそのような fieldFormat のローカライズ表現を持たない場合は、value 自体を使用する。
      5. Record { [[Type]]: partType, [[Value]]: formattedValue } を result に追加する。
    6. そうでなく partTypeTable 16 の行の Property 列に一致するなら、
      1. Assert: format はフィールド [[<partType>]] を持つ。
      2. fieldFormatformat.[[<partType>]] とする。
      3. value を、一致する行の Internal Slot 列を名前とする localTime のフィールドの値とする。
      4. partType"year" で、かつ value ≤ 0 なら、value を 1 - value に設定する。
      5. partType"month" なら、valuevalue + 1 に設定する。
      6. partType"hour" で、かつ dateTimeFormat.[[HourCycle]]"h11" または "h12" なら、
        1. valuevalue modulo 12 に設定する。
        2. value = 0 で、かつ dateTimeFormat.[[HourCycle]]"h12" なら、value を 12 に設定する。
      7. partType"hour" で、かつ dateTimeFormat.[[HourCycle]]"h24" なら、
        1. value = 0 なら、value を 24 に設定する。
      8. fieldFormat"numeric" なら、
        1. formattedValueFormatNumeric(nf, value) とする。
      9. そうでなく fieldFormat"2-digit" なら、
        1. formattedValueFormatNumeric(nf2, value) とする。
        2. codePointsStringToCodePoints(formattedValue) とする。
        3. countcodePoints 内の要素数とする。
        4. count > 2 なら、
          1. tenscodePoints[count - 2] とする。
          2. onescodePoints[count - 1] とする。
          3. formattedValueCodePointsToStringtens, ones ») に設定する。
      10. そうでなく fieldFormat"narrow""short"、または "long" なら、
        1. formattedValue を、fieldFormat によって与えられる形式の value を表す ILD String とする。partType"month" なら、その値は format[[day]] フィールドを持つかどうかに依存してよい。実装がそのような fieldFormat のローカライズ表現を持たない場合は、value 自体を使用する。
      11. Record { [[Type]]: partType, [[Value]]: formattedValue } を result に追加する。
    7. そうでなく partType"ampm" なら、
      1. valuelocalTime.[[Hour]] とする。
      2. value > 11 なら、formattedValue"post meridiem" を表す ILD String とする。そうでなければ、formattedValue"ante meridiem" を表す ILD String とする。
      3. Record { [[Type]]: "dayPeriod", [[Value]]: formattedValue } を result に追加する。
    8. そうでなく partType"relatedYear" なら、
      1. valuelocalTime.[[RelatedYear]] とする。
      2. formattedValueFormatNumeric(nf, value) とする。
      3. Record { [[Type]]: "relatedYear", [[Value]]: formattedValue } を result に追加する。
    9. そうでなく partType"yearName" なら、
      1. valuelocalTime.[[YearName]] とする。
      2. formattedValuevalue を表す ILD String とする。
      3. Record { [[Type]]: "yearName", [[Value]]: formattedValue } を result に追加する。
    10. そうでなければ、
      1. unknownepochNanoseconds および partType に基づく ILND String とする。
      2. Record { [[Type]]: "unknown", [[Value]]: unknown } を result に追加する。
  16. result を返す。
Note
実装は、Common Locale Data Repository が提供するロケールおよびカレンダー依存文字列 (https://cldr.unicode.org/ で利用可能) を使用し、DateTimeFormat "short" 文字列には CLDR "abbreviated" 文字列を、DateTimeFormat "long" 文字列には CLDR "wide" 文字列を使用することが推奨される。

11.5.6 PartitionDateTimePattern ( dateTimeFormat, x )

The abstract operation PartitionDateTimePattern takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (Number) and returns フィールド [[Type]] (String) および [[Value]] (String) を持つ RecordsList を含む正常完了、または throw 完了. xECMA-26221.4.1.1 で規定される時刻値として解釈し、dateTimeFormat の実効ロケールおよび整形オプションに従って、対応する parts を作成する。 It performs the following steps when called:

  1. xTimeClip(x) に設定する。
  2. xNaN なら、RangeError 例外を投げる。
  3. epochNanoseconds((x) × 106) とする。
  4. formatdateTimeFormat.[[DateTimeFormat]] とする。
  5. dateTimeFormat.[[HourCycle]]"h11" または "h12" なら、
    1. patternformat.[[pattern12]] とする。
  6. そうでなければ、
    1. patternformat.[[pattern]] とする。
  7. resultFormatDateTimePattern(dateTimeFormat, format, pattern, epochNanoseconds) とする。
  8. result を返す。

11.5.7 FormatDateTime ( dateTimeFormat, x )

The abstract operation FormatDateTime takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (Number) and returns String を含む正常完了、または throw 完了. It performs the following steps when called:

  1. parts を ? PartitionDateTimePattern(dateTimeFormat, x) とする。
  2. result を空の String とする。
  3. parts の各 Record { [[Type]], [[Value]] } part について、次を行う。
    1. resultresultpart.[[Value]] の文字列連結に設定する。
  4. result を返す。

11.5.8 FormatDateTimeToParts ( dateTimeFormat, x )

The abstract operation FormatDateTimeToParts takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (Number) and returns Array を含む正常完了、または throw 完了. It performs the following steps when called:

  1. parts を ? PartitionDateTimePattern(dateTimeFormat, x) とする。
  2. result を ! ArrayCreate(0) とする。
  3. n を 0 とする。
  4. parts の各 Record { [[Type]], [[Value]] } part について、次を行う。
    1. partObjOrdinaryObjectCreate(%Object.prototype%) とする。
    2. CreateDataPropertyOrThrow(partObj, "type", part.[[Type]]) を実行する。
    3. CreateDataPropertyOrThrow(partObj, "value", part.[[Value]]) を実行する。
    4. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), partObj) を実行する。
    5. nn + 1 に設定する。
  5. result を返す。

11.5.9 PartitionDateTimeRangePattern ( dateTimeFormat, x, y )

The abstract operation PartitionDateTimeRangePattern takes arguments dateTimeFormat (Intl.DateTimeFormat), x (Number), and y (Number) and returns フィールド [[Type]] (String)、[[Value]] (String)、および [[Source]] (String) を持つ RecordsList を含む正常完了、または throw 完了. x および yECMA-26221.4.1.1 で規定される時刻値として解釈し、dateTimeFormat の実効ロケールおよび整形オプションに従って、対応する parts を作成する。 It performs the following steps when called:

  1. xTimeClip(x) に設定する。
  2. xNaN なら、RangeError 例外を投げる。
  3. yTimeClip(y) に設定する。
  4. yNaN なら、RangeError 例外を投げる。
  5. xEpochNanoseconds((x) × 106) とする。
  6. yEpochNanoseconds((y) × 106) とする。
  7. localTime1ToLocalTime(xEpochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]]) とする。
  8. localTime2ToLocalTime(yEpochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]]) とする。
  9. formatdateTimeFormat.[[DateTimeFormat]] とする。
  10. dateTimeFormat.[[HourCycle]]"h11" または "h12" なら、
    1. patternformat.[[pattern12]] とする。
    2. rangePatternsformat.[[rangePatterns12]] とする。
  11. そうでなければ、
    1. patternformat.[[pattern]] とする。
    2. rangePatternsformat.[[rangePatterns]] とする。
  12. selectedRangePatternundefined とする。
  13. relevantFieldsEqualtrue とする。
  14. checkMoreFieldstrue とする。
  15. Table 6 の各行について、ヘッダー行を除き、表の順序で、次を行う。
    1. fieldName をその行の Field Name 列で与えられた名前とする。
    2. rangePatterns が名前 fieldName のフィールドを持つなら、rangePatternrangePatterns の名前 fieldName のフィールドとする。そうでなければ rangePatternundefined とする。
    3. selectedRangePatternundefined でなく、かつ rangePatternundefined なら、
      1. NOTE: このフィールド以下の差異についての範囲パターンが存在しないため、それ以上のチェックは実行されない。
      2. checkMoreFieldsfalse に設定する。
    4. fieldName[[Default]] と等しくなく、かつ relevantFieldsEqualtrue で、かつ checkMoreFieldstrue なら、
      1. selectedRangePatternrangePattern に設定する。
      2. fieldName[[AmPm]] なら、
        1. localTime1.[[Hour]] が 12 未満なら、v1"am" とする。そうでなければ v1"pm" とする。
        2. localTime2.[[Hour]] が 12 未満なら、v2"am" とする。そうでなければ v2"pm" とする。
      3. そうでなく fieldName[[DayPeriod]] なら、
        1. v1localTime1 の day period を表す ILD String とする。
        2. v2localTime2 の day period を表す ILD String とする。
      4. そうでなく fieldName[[FractionalSecondDigits]] なら、
        1. format[[fractionalSecondDigits]] フィールドを持つなら、
          1. fractionalSecondDigitsformat.[[fractionalSecondDigits]] とする。
        2. そうでなければ、
          1. fractionalSecondDigits を 3 とする。
        3. expfractionalSecondDigits - 3 とする。
        4. v1floor(localTime1.[[Millisecond]] × 10exp) とする。
        5. v2floor(localTime2.[[Millisecond]] × 10exp) とする。
      5. そうでなければ、
        1. v1fieldName を名前とする localTime1 のフィールドとする。
        2. v2fieldName を名前とする localTime2 のフィールドとする。
      6. v1v2 と等しくないなら、
        1. relevantFieldsEqualfalse に設定する。
  16. relevantFieldsEqualtrue なら、
    1. collapsedResult を新しい空の List とする。
    2. resultPartsFormatDateTimePattern(dateTimeFormat, format, pattern, xEpochNanoseconds) とする。
    3. resultParts の各 Record { [[Type]], [[Value]] } part について、次を行う。
      1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Source]]: "shared" } を collapsedResult に追加する。
    4. collapsedResult を返す。
  17. rangeResult を新しい空の List とする。
  18. selectedRangePatternundefined なら、
    1. selectedRangePatternrangePatterns.[[Default]] に設定する。
  19. selectedRangePattern.[[PatternParts]] の各 Record { [[Pattern]], [[Source]] } rangePatternPart について、次を行う。
    1. patternrangePatternPart.[[Pattern]] とする。
    2. sourcerangePatternPart.[[Source]] とする。
    3. source"startRange" または "shared" なら、
      1. zxEpochNanoseconds とする。
    4. そうでなければ、
      1. zyEpochNanoseconds とする。
    5. resultPartsFormatDateTimePattern(dateTimeFormat, selectedRangePattern, pattern, z) とする。
    6. resultParts の各 Record { [[Type]], [[Value]] } part について、次を行う。
      1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Source]]: source } を rangeResult に追加する。
  20. rangeResult を返す。

11.5.10 FormatDateTimeRange ( dateTimeFormat, x, y )

The abstract operation FormatDateTimeRange takes arguments dateTimeFormat (Intl.DateTimeFormat), x (Number), and y (Number) and returns String を含む正常完了、または throw 完了. It performs the following steps when called:

  1. parts を ? PartitionDateTimeRangePattern(dateTimeFormat, x, y) とする。
  2. result を空の String とする。
  3. parts の各 Record { [[Type]], [[Value]], [[Source]] } part について、次を行う。
    1. resultresultpart.[[Value]] の文字列連結に設定する。
  4. result を返す。

11.5.11 FormatDateTimeRangeToParts ( dateTimeFormat, x, y )

The abstract operation FormatDateTimeRangeToParts takes arguments dateTimeFormat (Intl.DateTimeFormat), x (Number), and y (Number) and returns Array を含む正常完了、または throw 完了. It performs the following steps when called:

  1. parts を ? PartitionDateTimeRangePattern(dateTimeFormat, x, y) とする。
  2. result を ! ArrayCreate(0) とする。
  3. n を 0 とする。
  4. parts の各 Record { [[Type]], [[Value]], [[Source]] } part について、次を行う。
    1. partObjOrdinaryObjectCreate(%Object.prototype%) とする。
    2. CreateDataPropertyOrThrow(partObj, "type", part.[[Type]]) を実行する。
    3. CreateDataPropertyOrThrow(partObj, "value", part.[[Value]]) を実行する。
    4. CreateDataPropertyOrThrow(partObj, "source", part.[[Source]]) を実行する。
    5. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), partObj) を実行する。
    6. nn + 1 に設定する。
  5. result を返す。

11.5.12 ToLocalTime ( epochNs, calendar, timeZoneIdentifier )

The implementation-defined abstract operation ToLocalTime takes arguments epochNs (BigInt), calendar (String), and timeZoneIdentifier (String) and returns ToLocalTime Record. It performs the following steps when called:

  1. IsTimeZoneOffsetString(timeZoneIdentifier) が true なら、
    1. offsetNsParseTimeZoneOffsetString(timeZoneIdentifier) とする。
  2. そうでなければ、
    1. Assert: GetAvailableNamedTimeZoneIdentifier(timeZoneIdentifier) は empty ではない。
    2. offsetNsGetNamedTimeZoneOffsetNanoseconds(timeZoneIdentifier, epochNs) とする。
  3. tz(epochNs) + offsetNs とする。
  4. calendar"gregory" なら、
    1. Table 17 に従って tz から計算されたフィールドを持つ ToLocalTime Record を返す。
  5. そうでなければ、
    1. 与えられた calendar について tz から計算されたフィールドを持つ ToLocalTime Record を返す。この計算は、指定された calendar に関する利用可能な最良の情報を使用すべきである。

11.5.13 ToLocalTime Records

ToLocalTime Record は、Table 17 で定義されるフィールドを持つ。

Table 17: ToLocalTime によって返される Record
フィールド名 値の型 グレゴリオ暦における値の計算
[[Weekday]] 整数 (WeekDay(𝔽(floor(tz / 106))))
[[Era]] String yearYearFromTime(𝔽(floor(tz / 106))) とする。year < 1𝔽 なら "BC" を返し、そうでなければ "AD" を返す。
[[Year]] 整数 (YearFromTime(𝔽(floor(tz / 106))))
[[RelatedYear]] 整数または undefined undefined
[[YearName]] String または undefined undefined
[[Month]] 整数 (MonthFromTime(𝔽(floor(tz / 106))))
[[Day]] 整数 (DateFromTime(𝔽(floor(tz / 106))))
[[Hour]] 整数 (HourFromTime(𝔽(floor(tz / 106))))
[[Minute]] 整数 (MinFromTime(𝔽(floor(tz / 106))))
[[Second]] 整数 (SecFromTime(𝔽(floor(tz / 106))))
[[Millisecond]] 整数 (msFromTime(𝔽(floor(tz / 106))))
[[InDST]] Boolean 指定された calendar および timeZoneIdentifier について、IANA Time Zone Database から得られる UTC からのタイムゾーンオフセットおよび夏時間規則に関する現在および過去の情報を含む、利用可能な最良の情報を使用して true または false を計算する。

11.5.14 UnwrapDateTimeFormat ( dtf )

The abstract operation UnwrapDateTimeFormat takes argument dtf (ECMAScript 言語値) and returns ECMAScript 言語値を含む正常完了、または throw 完了. 入力オブジェクトの DateTimeFormat インスタンスを返す。それは、その値自体、または 4.3 Note 1 の規範的任意コンストラクターモードに従って %Intl.DateTimeFormat% によって関連付けられた値のいずれかである。 It performs the following steps when called:

  1. dtf が Object でないなら、TypeError 例外を投げる。
  2. dtf[[InitializedDateTimeFormat]] 内部スロットを持たず、かつ ? OrdinaryHasInstance(%Intl.DateTimeFormat%, dtf) が true なら、
    1. Get(dtf, %Intl%.[[FallbackSymbol]]) を返す。
  3. dtf を返す。

12 DisplayNamesオブジェクト

12.1 Intl.DisplayNamesコンストラクタ

Intl.DisplayNamesコンストラクタは、次のとおりである:

  • %Intl.DisplayNames%である。
  • Intlオブジェクト"DisplayNames"プロパティの初期値である。

Intlオブジェクトのすべてのサービスコンストラクタプロパティに共通する動作は、9.1で規定される。

12.1.1 Intl.DisplayNames ( locales, options )

Intl.DisplayNames関数が引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. NewTargetがundefinedならば、TypeError例外を投げる。
  2. displayNamesを? OrdinaryCreateFromConstructor(NewTarget, "%Intl.DisplayNames.prototype%", « [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[LanguageDisplay]], [[Fields]] »)とする。
  3. optionsResolutionを? ResolveOptions(%Intl.DisplayNames%, %Intl.DisplayNames%.[[LocaleData]], locales, options, « require-options »)とする。
  4. optionsoptionsResolution.[[Options]]に設定する。
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]]とする。
  6. styleを? GetOption(options, "style", string, « "narrow", "short", "long" », "long")とする。
  7. displayNames.[[Style]]styleに設定する。
  8. typeを? GetOption(options, "type", string, « "language", "region", "script", "currency", "calendar", "dateTimeField" », required)とする。
  9. displayNames.[[Type]]typeに設定する。
  10. fallbackを? GetOption(options, "fallback", string, « "code", "none" », "code")とする。
  11. displayNames.[[Fallback]]fallbackに設定する。
  12. displayNames.[[Locale]]resolvedLocale.[[Locale]]に設定する。
  13. resolvedLocaleDataresolvedLocale.[[LocaleData]]とする。
  14. typesresolvedLocaleData.[[types]]とする。
  15. Assert: typesRecordである(12.2.3を参照)。
  16. languageDisplayを? GetOption(options, "languageDisplay", string, « "dialect", "standard" », "dialect")とする。
  17. typeFieldstypes.[[<type>]]とする。
  18. Assert: typeFieldsRecordである(12.2.3を参照)。
  19. type"language"ならば、
    1. displayNames.[[LanguageDisplay]]languageDisplayに設定する。
    2. typeFieldstypeFields.[[<languageDisplay>]]に設定する。
    3. Assert: typeFieldsRecordである(12.2.3を参照)。
  20. styleFieldstypeFields.[[<style>]]とする。
  21. Assert: styleFieldsRecordである(12.2.3を参照)。
  22. displayNames.[[Fields]]styleFieldsに設定する。
  23. displayNamesを返す。

12.2 Intl.DisplayNamesコンストラクタのプロパティ

Intl.DisplayNamesコンストラクタは、次のとおりである:

  • 値が%Function.prototype%である[[Prototype]]内部スロットを持つ。
  • 次のプロパティを持つ:

12.2.1 Intl.DisplayNames.prototype

Intl.DisplayNames.prototypeの値は%Intl.DisplayNames.prototype%である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }を持つ。

12.2.2 Intl.DisplayNames.supportedLocalesOf ( locales [ , options ] )

supportedLocalesOfメソッドが引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. availableLocales%Intl.DisplayNames%.[[AvailableLocales]]とする。
  2. requestedLocalesを? CanonicalizeLocaleList(locales)とする。
  3. FilterLocales(availableLocales, requestedLocales, options)を返す。

12.2.3 内部スロット

[[AvailableLocales]]内部スロットの値は、9.1で述べられた制約の範囲内で実装定義である。

[[RelevantExtensionKeys]]内部スロットの値は« »である。

[[ResolutionOptionDescriptors]]内部スロットの値は« »である。

[[LocaleData]]内部スロットの値は、9.1で述べられた制約および次の追加制約の範囲内で実装定義である:

  • [[LocaleData]].[[<locale>]]は、すべてのロケール値localeについて[[types]]フィールドを持たなければならない。このフィールドの値はRecordでなければならず、すべての表示名型の名前を持つフィールド、すなわち"language""region""script""currency""calendar"、および"dateTimeField"を持たなければならない。
  • フィールド"language"の値はRecordでなければならず、有効な言語表示の名前のいずれか、すなわち"dialect"および"standard"を持つフィールドを持たなければならない。
  • 表示名型"language"の下の言語表示フィールドはRecordを含むべきであり、そのRecordは有効な表示名スタイルの名前のいずれか、すなわち"narrow""short"、および"long"を持つフィールドを持たなければならない。
  • フィールド"region""script""currency""calendar"、および"dateTimeField"の値はRecordでなければならず、すべての表示名スタイルの名前、すなわち"narrow""short"、および"long"を持つフィールドを持たなければならない。
  • 表示名型"language"の下の表示名スタイルフィールドは、unicode_language_id Unicodeロケール非終端記号により一致させることができる言語コードに対応するキーを持つRecordを含むべきである。これらのフィールドの値は文字列値でなければならない。
  • 表示名型"region"の下の表示名スタイルフィールドは、地域コードに対応するキーを持つRecordを含むべきである。これらのフィールドの値は文字列値でなければならない。
  • 表示名型"script"の下の表示名スタイルフィールドは、文字体系コードに対応するキーを持つRecordを含むべきである。これらのフィールドの値は文字列値でなければならない。
  • 表示名型"currency"の下の表示名スタイルフィールドは、通貨コードに対応するキーを持つRecordを含むべきである。これらのフィールドの値は文字列値でなければならない。
  • 表示名型"calendar"の下の表示名スタイルフィールドは、type Unicodeロケール非終端記号により一致させることができるカレンダー識別子に対応するキーを持つRecordを含むべきである。これらのフィールドの値は文字列値でなければならない。
  • 表示名型"dateTimeField"の下の表示名スタイルフィールドは、Table 19に列挙されるコードに対応するキーを持つRecordを含むべきである。これらのフィールドの値は文字列値でなければならない。
Note
実装は、Common Locale Data Repository(https://cldr.unicode.org/で入手可能)が提供するロケールデータを使用することが推奨される。

12.3 Intl.DisplayNamesプロトタイプオブジェクトのプロパティ

Intl.DisplayNamesプロトタイプオブジェクトは、次のとおりである:

  • %Intl.DisplayNames.prototype%である。
  • 通常のオブジェクトである。
  • Intl.DisplayNamesインスタンスではなく、[[InitializedDisplayNames]]内部スロットまたはIntl.DisplayNamesインスタンスオブジェクトのその他の内部スロットを持たない。
  • 値が%Object.prototype%である[[Prototype]]内部スロットを持つ。

12.3.1 Intl.DisplayNames.prototype.constructor

Intl.DisplayNames.prototype.constructorの初期値は%Intl.DisplayNames%である。

12.3.2 Intl.DisplayNames.prototype.resolvedOptions ( )

この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。

  1. displayNamesthis値とする。
  2. RequireInternalSlot(displayNames, [[InitializedDisplayNames]])を実行する。
  3. optionsOrdinaryObjectCreate(%Object.prototype%)とする。
  4. Table 18の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. propertyKeyを現在の行のProperty値とする。
    2. valueを、その名前が現在の行のInternal Slot値であるdisplayNamesの内部スロットの値とする。
    3. valueundefinedでないならば、
      1. CreateDataPropertyOrThrow(options, propertyKey, value)を実行する。
  5. optionsを返す。
Table 18: DisplayNamesインスタンスのResolved Options
内部スロット プロパティ
[[Locale]] "locale"
[[Style]] "style"
[[Type]] "type"
[[Fallback]] "fallback"
[[LanguageDisplay]] "languageDisplay"

12.3.3 Intl.DisplayNames.prototype.of ( code )

Intl.DisplayNames.prototype.ofが引数codeとともに呼び出されるとき、次の手順が実行される:

  1. displayNamesthis値とする。
  2. RequireInternalSlot(displayNames, [[InitializedDisplayNames]])を実行する。
  3. codeを? ToString(code)に設定する。
  4. codeを? CanonicalCodeForDisplayNames(displayNames.[[Type]], code)に設定する。
  5. fieldsdisplayNames.[[Fields]]とする。
  6. fieldsにフィールド[[<code>]]があるならば、fields.[[<code>]]を返す。
  7. displayNames.[[Fallback]]"code"ならば、codeを返す。
  8. undefinedを返す。

12.3.4 Intl.DisplayNames.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag%プロパティの初期値はString値"Intl.DisplayNames"である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }を持つ。

12.4 Intl.DisplayNamesインスタンスのプロパティ

Intl.DisplayNamesインスタンスは、%Intl.DisplayNames.prototype%からプロパティを継承する通常のオブジェクトである。

Intl.DisplayNamesインスタンスは[[InitializedDisplayNames]]内部スロットを持つ。

Intl.DisplayNamesインスタンスは、Intl.DisplayNamesコンストラクタによって計算されるいくつかの内部スロットも持つ:

  • [[Locale]]は、整形に使用されるローカライズのロケールの言語タグを持つString値である。
  • [[Style]]は、使用される表示名スタイルを識別する、String値"narrow""short"、または"long"のいずれかである。
  • [[Type]]は、要求された表示名の型を識別する、String値"language""region""script""currency""calendar"、または"dateTimeField"のいずれかである。
  • [[Fallback]]は、システムが要求された表示名を持たない場合のフォールバック戻り値を識別する、String値"code"または"none"のいずれかである。
  • [[LanguageDisplay]]は、言語表示の種類を識別する、String値"dialect"または"standard"のいずれかである。これは[[Type]]が値"language"を持つ場合にのみ使用される。
  • [[Fields]]Record12.2.3を参照)であり、[[Style]][[Type]]、および[[LanguageDisplay]]に従ってコードに対応するキーを持つフィールドを持たなければならない。

12.5 DisplayNamesオブジェクトのための抽象操作

12.5.1 CanonicalCodeForDisplayNames ( type, code )

The abstract operation CanonicalCodeForDisplayNames takes arguments type (String) and code (String) and returns Stringを含む通常完了またはthrow完了. codetypeに従って整形式コードを表すことを検証し、codeの大文字小文字を正規化した形式を返す。 It performs the following steps when called:

  1. type"language"ならば、
    1. codeunicode_language_id Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
    2. IsWellFormedLanguageTag(code)がfalseならば、RangeError例外を投げる。
    3. CanonicalizeUnicodeLocaleId(code)を返す。
  2. type"region"ならば、
    1. codeunicode_region_subtag Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
    2. codeのASCII大文字化を返す。
  3. type"script"ならば、
    1. codeunicode_script_subtag Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
    2. Assert: codeの長さは4であり、codeのすべてのコード単位はASCII文字(0x0041から0x005A、および0x0061から0x007Aまで、いずれも含む)を表す。
    3. firstを、codeの0から1までの部分文字列のASCII大文字化とする。
    4. restを、codeの1からの部分文字列のASCII小文字化とする。
    5. firstrestの文字列連結を返す。
  4. type"calendar"ならば、
    1. codetype Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
    2. codeUnicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformanceで述べられる後方互換性構文のいずれかを使用するならば、RangeError例外を投げる。
    3. codeのASCII小文字化を返す。
  5. type"dateTimeField"ならば、
    1. IsValidDateTimeFieldCode(code)の結果がfalseならば、RangeError例外を投げる。
    2. codeを返す。
  6. Assert: type"currency"である。
  7. IsWellFormedCurrencyCode(code)がfalseならば、RangeError例外を投げる。
  8. codeのASCII大文字化を返す。

12.5.2 IsValidDateTimeFieldCode ( field )

The abstract operation IsValidDateTimeFieldCode takes argument field (String) and returns Boolean. field引数が有効な日時フィールドコードを表すことを検証する。 It performs the following steps when called:

  1. fieldTable 19のCode列に列挙されているならば、trueを返す。
  2. falseを返す。
Table 19: DisplayNamesの日時フィールドのコード
コード 説明
"era" 時代を示すフィールド。例えば、グレゴリオ暦またはユリウス暦におけるADまたはBC。
"year" 年(時代内)を示すフィールド。
"quarter" 四半期を示すフィールド。例えばQ2、第2四半期など。
"month" 月を示すフィールド。例えばSep、Septemberなど。
"weekOfYear" 年内の週番号を示すフィールド。
"weekday" 曜日を示すフィールド。例えばTue、Tuesdayなど。
"day" 月内の日を示すフィールド。
"dayPeriod" 日中区分を示すフィールド。am、pmなど、または正午、夕方など。
"hour" 時を示すフィールド。
"minute" 分を示すフィールド。
"second" 秒を示すフィールド。
"timeZoneName" タイムゾーン名を示すフィールド。例えばPDT、Pacific Daylight Timeなど。

13 DurationFormatオブジェクト

13.1 Intl.DurationFormatコンストラクタ

Intl.DurationFormatコンストラクタは、次のとおりである:

  • %Intl.DurationFormat%である。
  • Intlオブジェクト"DurationFormat"プロパティの初期値である。

Intlオブジェクトのすべてのサービスコンストラクタプロパティに共通する動作は、9.1で規定される。

13.1.1 Intl.DurationFormat ( [ locales [ , options ] ] )

Intl.DurationFormat関数が省略可能な引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. NewTargetがundefinedならば、TypeError例外を投げる。
  2. durationFormatを? OrdinaryCreateFromConstructor(NewTarget, "%Intl.DurationFormatPrototype%", « [[InitializedDurationFormat]], [[Locale]], [[NumberingSystem]], [[Style]], [[YearsOptions]], [[MonthsOptions]], [[WeeksOptions]], [[DaysOptions]], [[HoursOptions]], [[MinutesOptions]], [[SecondsOptions]], [[MillisecondsOptions]], [[MicrosecondsOptions]], [[NanosecondsOptions]], [[HourMinuteSeparator]], [[MinuteSecondSeparator]], [[FractionalDigits]] »)とする。
  3. optionsResolutionを? ResolveOptions(%Intl.DurationFormat%, %Intl.DurationFormat%.[[LocaleData]], locales, options)とする。
  4. optionsoptionsResolution.[[Options]]に設定する。
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]]とする。
  6. durationFormat.[[Locale]]resolvedLocale.[[Locale]]に設定する。
  7. resolvedLocaleDataresolvedLocale.[[LocaleData]]とする。
  8. digitalFormatresolvedLocaleData.[[DigitalFormat]]とする。
  9. durationFormat.[[HourMinuteSeparator]]digitalFormat.[[HourMinuteSeparator]]に設定する。
  10. durationFormat.[[MinuteSecondSeparator]]digitalFormat.[[MinuteSecondSeparator]]に設定する。
  11. durationFormat.[[NumberingSystem]]resolvedLocale.[[nu]]に設定する。
  12. styleを? GetOption(options, "style", string, « "long", "short", "narrow", "digital" », "short")とする。
  13. durationFormat.[[Style]]styleに設定する。
  14. prevStyleを空のStringとする。
  15. Table 20の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. slotを現在の行のInternal Slot値とする。
    2. unitを現在の行のUnit値とする。
    3. stylesを現在の行のStyles値とする。
    4. digitalBaseを現在の行のDigital Default値とする。
    5. unitOptionsを? GetDurationUnitOptions(unit, options, style, styles, digitalBase, prevStyle, digitalFormat.[[TwoDigitHours]])とする。
    6. durationFormatの、名前がslotである内部スロットの値をunitOptionsに設定する。
    7. unit"hours""minutes""seconds""milliseconds"、または"microseconds"のいずれかならば、
      1. prevStyleunitOptions.[[Style]]に設定する。
  16. durationFormat.[[FractionalDigits]]を? GetNumberOption(options, "fractionalDigits", 0, 9, undefined)に設定する。
  17. durationFormatを返す。
Table 20: DurationFormatインスタンスの内部スロットおよびプロパティ名
内部スロット 単位 スタイル デジタル時のデフォルト
[[YearsOptions]] "years" « "long", "short", "narrow" » "short"
[[MonthsOptions]] "months" « "long", "short", "narrow" » "short"
[[WeeksOptions]] "weeks" « "long", "short", "narrow" » "short"
[[DaysOptions]] "days" « "long", "short", "narrow" » "short"
[[HoursOptions]] "hours" « "long", "short", "narrow", "numeric", "2-digit" » "numeric"
[[MinutesOptions]] "minutes" « "long", "short", "narrow", "numeric", "2-digit" » "numeric"
[[SecondsOptions]] "seconds" « "long", "short", "narrow", "numeric", "2-digit" » "numeric"
[[MillisecondsOptions]] "milliseconds" « "long", "short", "narrow", "numeric" » "numeric"
[[MicrosecondsOptions]] "microseconds" « "long", "short", "narrow", "numeric" » "numeric"
[[NanosecondsOptions]] "nanoseconds" « "long", "short", "narrow", "numeric" » "numeric"

13.2 Intl.DurationFormatコンストラクタのプロパティ

Intl.DurationFormatコンストラクタは、次のとおりである:

  • 値が%Function.prototype%である[[Prototype]]内部スロットを持つ。
  • 次のプロパティを持つ:

13.2.1 Intl.DurationFormat.prototype

Intl.DurationFormat.prototypeの値は%Intl.DurationFormat.prototype%である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }を持つ。

13.2.2 Intl.DurationFormat.supportedLocalesOf ( locales [ , options ] )

supportedLocalesOfメソッドが引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. availableLocales%Intl.DurationFormat%.[[AvailableLocales]]とする。
  2. requestedLocalesを? CanonicalizeLocaleList(locales)とする。
  3. FilterLocales(availableLocales, requestedLocales, options)を返す。

13.2.3 内部スロット

[[AvailableLocales]]内部スロットの値は、9.1で述べられた制約の範囲内で実装定義である。

[[RelevantExtensionKeys]]内部スロットの値は« "nu" »である。

[[ResolutionOptionDescriptors]]内部スロットの値は« { [[Key]]: "nu", [[Property]]: "numberingSystem" } »である。

[[LocaleData]]内部スロットの値は、9.1で述べられた制約およびすべてのロケール値localeに対する次の追加制約の範囲内で実装定義である:

  • [[LocaleData]].[[<locale>]]は、フィールド[[nu]]および[[DigitalFormat]]を持つRecordでなければならない。
  • [[LocaleData]].[[<locale>]].[[nu]]は、16.2.3で規定されるListでなければならず、値"native""traditio"、または"finance"を含んではならない。
  • [[LocaleData]].[[<locale>]].[[DigitalFormat]]は、localeで利用可能な各番号体系に対応するキーを持つRecordでなければならない。それらのキーのいずれかに関連付けられた各値は、次のフィールドを含むRecordでなければならない:
    • [[HourMinuteSeparator]]は、スタイル"numeric"または"2-digit"を使用するとき、そのロケールと番号体系の組み合わせにおける時と分の間の適切な区切り文字であるString値でなければならない。
    • [[MinuteSecondSeparator]]は、スタイル"numeric"または"2-digit"を使用するとき、そのロケールと番号体系の組み合わせにおける分と秒の間の適切な区切り文字であるString値でなければならない。
    • [[TwoDigitHours]]は、スタイル"numeric"を使用するとき、時が常に2桁で表示されるかどうかを示すBoolean値でなければならない。
Note
実装は、Common Locale Data Repository(http://cldr.unicode.org/で入手可能)が提供するロケールデータを使用することが推奨される。

13.3 Intl.DurationFormatプロトタイプオブジェクトのプロパティ

Intl.DurationFormatプロトタイプオブジェクトは、次のとおりである:

  • %Intl.DurationFormat.prototype%である。
  • 通常のオブジェクトである。
  • Intl.DurationFormatインスタンスではなく、[[InitializedDurationFormat]]内部スロットまたはIntl.DurationFormatインスタンスオブジェクトのその他の内部スロットを持たない。
  • 値が%Object.prototype%である[[Prototype]]内部スロットを持つ。

13.3.1 Intl.DurationFormat.prototype.constructor

Intl.DurationFormat.prototype.constructorの初期値は、組込みオブジェクト%Intl.DurationFormat%である。

13.3.2 Intl.DurationFormat.prototype.resolvedOptions ( )

この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。

  1. dfthis値とする。
  2. RequireInternalSlot(df, [[InitializedDurationFormat]])を実行する。
  3. optionsOrdinaryObjectCreate(%Object.prototype%)とする。
  4. Table 21の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. propertyKeyを現在の行のProperty値とする。
    2. valueを、その名前が現在の行のInternal Slot値であるdfの内部スロットの値とする。
    3. valueundefinedでないならば、
      1. 現在の行にConversion値があるならば、conversionをその値とする。そうでなければ、conversionemptyとする。
      2. conversionnumberならば、
        1. value𝔽(value)に設定する。
      3. そうでなく、conversionemptyでないならば、
        1. Assert: conversionstyle+displayであり、valueDuration Unit Options Recordである。
        2. NOTE: value.[[Style]]propertyKey(複数形のTemporal単位)という名前のプロパティで表され、その後value.[[Display]]propertyKey"Display"を接尾する名前のプロパティで表される。
        3. stylevalue.[[Style]]とする。
        4. style"fractional"ならば、
          1. Assert: IsFractionalSecondUnitName(propertyKey)はtrueである。
          2. style"numeric"に設定する。
        5. CreateDataPropertyOrThrow(options, propertyKey, style)を実行する。
        6. propertyKeypropertyKey"Display"の文字列連結に設定する。
        7. valuevalue.[[Display]]に設定する。
      4. CreateDataPropertyOrThrow(options, propertyKey, value)を実行する。
  5. optionsを返す。
Table 21: DurationFormatインスタンスのResolved Options
内部スロット プロパティ 変換
[[Locale]] "locale"
[[NumberingSystem]] "numberingSystem"
[[Style]] "style"
[[YearsOptions]] "years" style+display
[[MonthsOptions]] "months" style+display
[[WeeksOptions]] "weeks" style+display
[[DaysOptions]] "days" style+display
[[HoursOptions]] "hours" style+display
[[MinutesOptions]] "minutes" style+display
[[SecondsOptions]] "seconds" style+display
[[MillisecondsOptions]] "milliseconds" style+display
[[MicrosecondsOptions]] "microseconds" style+display
[[NanosecondsOptions]] "nanoseconds" style+display
[[FractionalDigits]] "fractionalDigits" number

13.3.3 Intl.DurationFormat.prototype.format ( duration )

formatメソッドが引数durationとともに呼び出されるとき、次の手順が実行される:

  1. dfthis 値とする。
  2. RequireInternalSlot(df, [[InitializedDurationFormat]]) を実行する。
  3. record を ? ToDurationRecord(duration) とする。
  4. partsPartitionDurationFormatPattern(df, record) とする。
  5. result を空の String とする。
  6. parts の各 Record { [[Type]], [[Value]], [[Unit]] } part について、次を行う。
    1. resultresultpart.[[Value]] の文字列連結に設定する。
  7. result を返す。

13.3.4 Intl.DurationFormat.prototype.formatToParts ( duration )

formatToPartsメソッドが引数durationとともに呼び出されるとき、次の手順が実行される:

  1. dfthis 値とする。
  2. RequireInternalSlot(df, [[InitializedDurationFormat]]) を実行する。
  3. record を ? ToDurationRecord(duration) とする。
  4. partsPartitionDurationFormatPattern(df, record) とする。
  5. result を ! ArrayCreate(0) とする。
  6. n を 0 とする。
  7. parts の各 Record { [[Type]], [[Value]], [[Unit]] } part について、次を行う。
    1. objOrdinaryObjectCreate(%Object.prototype%) とする。
    2. CreateDataPropertyOrThrow(obj, "type", part.[[Type]]) を実行する。
    3. CreateDataPropertyOrThrow(obj, "value", part.[[Value]]) を実行する。
    4. part.[[Unit]]empty でないなら、! CreateDataPropertyOrThrow(obj, "unit", part.[[Unit]]) を実行する。
    5. CreateDataPropertyOrThrow(result, ! ToString(n), obj) を実行する。
    6. nn + 1 に設定する。
  8. result を返す。

13.3.5 Intl.DurationFormat.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag%プロパティの初期値はString値"Intl.DurationFormat"である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }を持つ。

13.4 Intl.DurationFormatインスタンスのプロパティ

Intl.DurationFormatインスタンスは、%Intl.DurationFormat.prototype%からプロパティを継承する。

Intl.DurationFormatインスタンスは[[InitializedDurationFormat]]内部スロットを持つ。

Intl.DurationFormatインスタンスは、Intl.DurationFormatコンストラクタによって計算されるいくつかの内部スロットも持つ:

  • [[Locale]]は、整形に使用されるローカライズのロケールの言語タグを持つString値である。
  • [[NumberingSystem]]は、整形に使用されるUnicode Number System Identifierを表すString値である。
  • [[Style]]は、使用されるduration整形スタイルを識別する、String値"long""short""narrow"、または"digital"のいずれかである。
  • [[YearsOptions]]は、Duration Record[[Years]]フィールドの整形スタイルおよび表示基準を識別するDuration Unit Options Recordである。
  • [[MonthsOptions]]は、Duration Record[[Months]]フィールドの整形スタイルおよび表示基準を識別するDuration Unit Options Recordである。
  • [[WeeksOptions]]は、Duration Record[[Weeks]]フィールドの整形スタイルおよび表示基準を識別するDuration Unit Options Recordである。
  • [[DaysOptions]]は、Duration Record[[Days]]フィールドの整形スタイルおよび表示基準を識別するDuration Unit Options Recordである。
  • [[HoursOptions]]は、Duration Record[[Hours]]フィールドの整形スタイルおよび表示基準を識別するDuration Unit Options Recordである。
  • [[MinutesOptions]]は、Duration Record[[Minutes]]フィールドの整形スタイルおよび表示基準を識別するDuration Unit Options Recordである。
  • [[SecondsOptions]]は、Duration Record[[Seconds]]フィールドの整形スタイルおよび表示基準を識別するDuration Unit Options Recordである。
  • [[MillisecondsOptions]]は、Duration Record[[Milliseconds]]フィールドの整形スタイルおよび表示基準を識別するDuration Unit Options Recordである。
  • [[MicrosecondsOptions]]は、Duration Record[[Microseconds]]フィールドの整形スタイルおよび表示基準を識別するDuration Unit Options Recordである。
  • [[NanosecondsOptions]]は、Duration Record[[Nanoseconds]]フィールドの整形スタイルおよび表示基準を識別するDuration Unit Options Recordである。
  • [[HourMinuteSeparator]]は、時と分の両方のフィールドが表示され、両方のフィールドが数値スタイルを使用して整形される場合に、時と分の間に使用される区切り文字を識別するString値である。
  • [[MinuteSecondSeparator]]は、分と秒の両方のフィールドが表示され、両方のフィールドが数値スタイルを使用して整形される場合に、分と秒の間に使用される区切り文字を識別するString値である。
  • [[FractionalDigits]]は、undefinedまたは、数値スタイルで使用される小数桁数を識別する非負整数のいずれかである。

13.5 DurationFormatオブジェクトのための抽象操作

13.5.1 Duration Record

Duration Recordは、Durationを表すために使用されるRecord値である。

Duration Recordは、Table 22に列挙されるフィールドを持つ

Table 22: Duration Record Fields
フィールド 意味
[[Years]] duration内の年数。
[[Months]] duration内の月数。
[[Weeks]] duration内の週数。
[[Days]] duration内の日数。
[[Hours]] duration内の時数。
[[Minutes]] duration内の分数。
[[Seconds]] duration内の秒数。
[[Milliseconds]] duration内のミリ秒数。
[[Microseconds]] duration内のマイクロ秒数。
[[Nanoseconds]] duration内のナノ秒数。

13.5.2 ToIntegerIfIntegral ( arg )

The abstract operation ToIntegerIfIntegral takes argument arg (ECMAScript言語値) and returns 整数を含む通常完了、またはthrow完了. argを、そのNumber値を表す整数に変換する。または、その値が整数でない場合はRangeErrorを投げる。 It performs the following steps when called:

  1. numberを? ToNumber(arg)とする。
  2. numberが整数Numberでないならば、RangeError例外を投げる。
  3. (number)を返す。

13.5.3 ToDurationRecord ( input )

The abstract operation ToDurationRecord takes argument input (ECMAScript言語値) and returns Duration Recordを含む通常完了、またはthrow完了. Durationを表す与えられたオブジェクトをDuration Recordに変換する。 It performs the following steps when called:

  1. inputがObjectでないならば、
    1. inputがStringならば、RangeError例外を投げる。
    2. TypeError例外を投げる。
  2. resultを、各フィールドが0に設定された新しいDuration Recordとする。
  3. daysを? Get(input, "days")とする。
  4. daysundefinedでないならば、result.[[Days]]を? ToIntegerIfIntegral(days)に設定する。
  5. hoursを? Get(input, "hours")とする。
  6. hoursundefinedでないならば、result.[[Hours]]を? ToIntegerIfIntegral(hours)に設定する。
  7. microsecondsを? Get(input, "microseconds")とする。
  8. microsecondsundefinedでないならば、result.[[Microseconds]]を? ToIntegerIfIntegral(microseconds)に設定する。
  9. millisecondsを? Get(input, "milliseconds")とする。
  10. millisecondsundefinedでないならば、result.[[Milliseconds]]を? ToIntegerIfIntegral(milliseconds)に設定する。
  11. minutesを? Get(input, "minutes")とする。
  12. minutesundefinedでないならば、result.[[Minutes]]を? ToIntegerIfIntegral(minutes)に設定する。
  13. monthsを? Get(input, "months")とする。
  14. monthsundefinedでないならば、result.[[Months]]を? ToIntegerIfIntegral(months)に設定する。
  15. nanosecondsを? Get(input, "nanoseconds")とする。
  16. nanosecondsundefinedでないならば、result.[[Nanoseconds]]を? ToIntegerIfIntegral(nanoseconds)に設定する。
  17. secondsを? Get(input, "seconds")とする。
  18. secondsundefinedでないならば、result.[[Seconds]]を? ToIntegerIfIntegral(seconds)に設定する。
  19. weeksを? Get(input, "weeks")とする。
  20. weeksundefinedでないならば、result.[[Weeks]]を? ToIntegerIfIntegral(weeks)に設定する。
  21. yearsを? Get(input, "years")とする。
  22. yearsundefinedでないならば、result.[[Years]]を? ToIntegerIfIntegral(years)に設定する。
  23. yearsmonthsweeksdayshoursminutessecondsmillisecondsmicroseconds、およびnanosecondsがすべてundefinedならば、TypeError例外を投げる。
  24. IsValidDuration( result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]])がfalseならば、
    1. RangeError例外を投げる。
  25. resultを返す。

13.5.4 DurationSign ( duration )

The abstract operation DurationSign takes argument duration (Duration Record) and returns -1, 0, または1. duration引数内で最上位の非ゼロフィールドが正である場合は1を返し、最上位の非ゼロフィールドが負である場合は-1を返す。durationのすべてのフィールドがゼロである場合は0を返す。 It performs the following steps when called:

  1. « duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]] »の各値vについて、次を行う:
    1. v < 0ならば、-1を返す。
    2. v > 0ならば、1を返す。
  2. 0を返す。

13.5.5 IsValidDuration ( years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds )

The abstract operation IsValidDuration takes arguments years (整数), months (整数), weeks (整数), days (整数), hours (整数), minutes (整数), seconds (整数), milliseconds (整数), microseconds (整数), and nanoseconds (整数) and returns Boolean. その引数がDuration Recordを構築するための有効な入力を形成する場合はtrueを返し、そうでなければfalseを返す。 It performs the following steps when called:

  1. signを0とする。
  2. « years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds »の各値vについて、次を行う:
    1. 𝔽(v)が有限でないならば、falseを返す。
    2. v < 0ならば、
      1. sign > 0ならば、falseを返す。
      2. signを-1に設定する。
    3. そうでなく、v > 0ならば、
      1. sign < 0ならば、falseを返す。
      2. signを1に設定する。
  3. abs(years) ≥ 232ならば、falseを返す。
  4. abs(months) ≥ 232ならば、falseを返す。
  5. abs(weeks) ≥ 232ならば、falseを返す。
  6. normalizedSecondsdays × 86,400 + hours × 3600 + minutes × 60 + seconds + (𝔽(milliseconds)) × 10-3 + (𝔽(microseconds)) × 10-6 + (𝔽(nanoseconds)) × 10-9とする。
  7. NOTE: 上記の手順は、浮動小数点演算を使用して直接実装することはできない。millisecondsmicroseconds、またはnanosecondsが安全でない整数である場合、それぞれ10-3、10-6、および10-9を掛けると不正確になる可能性がある。この乗算は、商に十分なビットを持つstd::remquo()の実装を使用してC++で実装できる。乗算は10の冪によるものであるため、文字列操作でも正確な結果が得られる。
  8. abs(normalizedSeconds) ≥ 253ならば、falseを返す。
  9. trueを返す。

13.5.6 GetDurationUnitOptions ( unit, options, baseStyle, stylesList, digitalBase, prevStyle, twoDigitHours )

The abstract operation GetDurationUnitOptions takes arguments unit (String), options (Object), baseStyle (String), stylesList (StringのList), digitalBase (String), prevStyle (String), and twoDigitHours (Boolean) and returns Duration Unit Options Recordを含む通常完了、またはthrow完了. 任意の与えられたunitについて、Objectから関連するオプションを抽出し、それらをRecordとして返す。 It performs the following steps when called:

  1. styleを? GetOption(options, unit, string, stylesList, undefined)とする。
  2. displayDefault"always"とする。
  3. styleundefinedならば、
    1. baseStyle"digital"ならば、
      1. styledigitalBaseに設定する。
      2. unit"hours""minutes"、または"seconds"のいずれでもないならば、displayDefault"auto"に設定する。
    2. そうでなく、prevStyle"fractional""numeric"、または"2-digit"のいずれかならば、
      1. style"numeric"に設定する。
      2. unit"minutes"または"seconds"でないならば、displayDefault"auto"に設定する。
    3. そうでなければ、
      1. stylebaseStyleに設定する。
      2. displayDefault"auto"に設定する。
  4. style"numeric"であり、かつIsFractionalSecondUnitName(unit)がtrueならば、
    1. style"fractional"に設定する。
    2. displayDefault"auto"に設定する。
  5. displayFieldunit"Display"の文字列連結とする。
  6. displayを? GetOption(options, displayField, string, « "auto", "always" », displayDefault)とする。
  7. ValidateDurationUnitStyle(unit, style, display, prevStyle)を実行する。
  8. unit"hours"であり、かつtwoDigitHourstrueならば、style"2-digit"に設定する。
  9. unit"minutes"または"seconds"であり、かつprevStyle"numeric"または"2-digit"ならば、style"2-digit"に設定する。
  10. Duration Unit Options Record { [[Style]]: style, [[Display]]: display }を返す。

13.5.6.1 Duration Unit Options Record

Duration Unit Options Recordは、Table 23で定義されるフィールドを持つ。

Table 23: Duration Unit Options Record
フィールド名 値の型
[[Style]] Table 20のStyles列からのString
[[Display]] "auto"または"always"

13.5.6.2 ValidateDurationUnitStyle ( unit, style, display, prevStyle )

The abstract operation ValidateDurationUnitStyle takes arguments unit (String), style (String), display (String), and prevStyle (String) and returns unusedを含む通常完了またはthrow完了. It performs the following steps when called:

  1. display"always"であり、かつstyle"fractional"ならば、RangeError例外を投げる。
  2. prevStyle"fractional"であり、かつstyle"fractional"でないならば、RangeError例外を投げる。
  3. prevStyle"numeric"または"2-digit"であり、かつstyle"fractional""numeric"、または"2-digit"のいずれでもないならば、RangeError例外を投げる。
  4. unusedを返す。
Note
unitは前述のアルゴリズムでは参照されないが、投げられる例外のメッセージを構築するとき、実装がこれを使用することが推奨される。

13.5.7 ComputeFractionalDigits ( durationFormat, duration )

The abstract operation ComputeFractionalDigits takes arguments durationFormat (DurationFormat Object) and duration (Duration Record) and returns 数学的値. durationFormat内で"fractional"スタイルを使用するすべての単位の値の合計を、"fractional"スタイルを使用しないdurationFormatの最小単位の分数として表したものとして計算する。 It performs the following steps when called:

  1. resultを0とする。
  2. exponentを3とする。
  3. Table 24の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. unitOptionsを、名前が現在の行のInternal Slot値であるdurationFormatの内部スロットの値とする。
    2. unitOptions.[[Style]]"fractional"ならば、
      1. unitを現在の行のUnit値とする。
      2. Assert: IsFractionalSecondUnitName(unit)はtrueである。
      3. valueを、名前が現在の行のValue Field値であるdurationのフィールドの値とする。
      4. resultresult + (value / 10exponent)に設定する。
      5. exponentexponent + 3に設定する。
  4. resultを返す。

13.5.8 NextUnitFractional ( durationFormat, unit )

The abstract operation NextUnitFractional takes arguments durationFormat (DurationFormat Object) and unit (String) and returns Boolean. 次に小さい単位が"fractional"スタイルを使用する場合はtrueを返す。 It performs the following steps when called:

  1. unit"seconds"であり、かつdurationFormat.[[MillisecondsOptions]].[[Style]]"fractional"ならば、trueを返す。
  2. unit"milliseconds"であり、かつdurationFormat.[[MicrosecondsOptions]].[[Style]]"fractional"ならば、trueを返す。
  3. unit"microseconds"であり、かつdurationFormat.[[NanosecondsOptions]].[[Style]]"fractional"ならば、trueを返す。
  4. falseを返す。

13.5.9 FormatNumericHours ( durationFormat, hoursValue, signDisplayed )

The abstract operation FormatNumericHours takes arguments durationFormat (DurationFormatオブジェクト), hoursValue (整数), and signDisplayed (Boolean) and returns RecordList. hoursValueは時数を示す整数である。durationFormatの有効なロケールおよび整形オプションに従って、hoursValueの部分を作成する。 It performs the following steps when called:

  1. resultを新しい空のListとする。
  2. hoursStyledurationFormat.[[HoursOptions]].[[Style]]とする。
  3. Assert: hoursStyle"numeric"または"2-digit"である。
  4. nfOptionsOrdinaryObjectCreate(null)とする。
  5. numberingSystemdurationFormat.[[NumberingSystem]]とする。
  6. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", numberingSystem)を実行する。
  7. hoursStyle"2-digit"ならば、
    1. CreateDataPropertyOrThrow(nfOptions, "minimumIntegerDigits", 2𝔽)を実行する。
  8. signDisplayedfalseならば、
    1. CreateDataPropertyOrThrow(nfOptions, "signDisplay", "never")を実行する。
  9. CreateDataPropertyOrThrow(nfOptions, "useGrouping", false)を実行する。
  10. nfを! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOptions »)とする。
  11. hoursPartsPartitionNumberPattern(nf, hoursValue)とする。
  12. hoursPartsの各Record { [[Type]], [[Value]] } partについて、次を行う:
    1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: "hour" }をresultに追加する。
  13. resultを返す。

13.5.10 FormatNumericMinutes ( durationFormat, minutesValue, hoursDisplayed, signDisplayed )

The abstract operation FormatNumericMinutes takes arguments durationFormat (DurationFormat Object), minutesValue (整数), hoursDisplayed (Boolean), and signDisplayed (Boolean) and returns RecordList. minutesValueは分数を示す整数である。durationFormatの有効なロケールおよび整形オプションに従って、minutesValueの部分を作成する。 It performs the following steps when called:

  1. resultを新しい空のListとする。
  2. hoursDisplayedtrueならば、
    1. separatordurationFormat.[[HourMinuteSeparator]]とする。
    2. Record { [[Type]]: "literal", [[Value]]: separator, [[Unit]]: empty }をresultに追加する。
  3. minutesStyledurationFormat.[[MinutesOptions]].[[Style]]とする。
  4. Assert: minutesStyle"numeric"または"2-digit"である。
  5. nfOptionsOrdinaryObjectCreate(null)とする。
  6. numberingSystemdurationFormat.[[NumberingSystem]]とする。
  7. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", numberingSystem)を実行する。
  8. minutesStyle"2-digit"ならば、
    1. CreateDataPropertyOrThrow(nfOptions, "minimumIntegerDigits", 2𝔽)を実行する。
  9. signDisplayedfalseならば、
    1. CreateDataPropertyOrThrow(nfOptions, "signDisplay", "never")を実行する。
  10. CreateDataPropertyOrThrow(nfOptions, "useGrouping", false)を実行する。
  11. nfを! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOptions »)とする。
  12. minutesPartsPartitionNumberPattern(nf, minutesValue)とする。
  13. minutesPartsの各Record { [[Type]], [[Value]] } partについて、次を行う:
    1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: "minute" }をresultに追加する。
  14. resultを返す。

13.5.11 FormatNumericSeconds ( durationFormat, secondsValue, minutesDisplayed, signDisplayed )

The abstract operation FormatNumericSeconds takes arguments durationFormat (DurationFormat Object), secondsValue (数学的値), minutesDisplayed (Boolean), and signDisplayed (Boolean) and returns RecordList. secondsValueは秒数を示す数学的値である。durationFormatの有効なロケールおよび整形オプションに従って、secondsValueの部分を作成する。 It performs the following steps when called:

  1. resultを新しい空のListとする。
  2. minutesDisplayedtrueならば、
    1. separatordurationFormat.[[MinuteSecondSeparator]]とする。
    2. Record { [[Type]]: "literal", [[Value]]: separator, [[Unit]]: empty }をresultに追加する。
  3. secondsStyledurationFormat.[[SecondsOptions]].[[Style]]とする。
  4. Assert: secondsStyle"numeric"または"2-digit"である。
  5. nfOptionsOrdinaryObjectCreate(null)とする。
  6. numberingSystemdurationFormat.[[NumberingSystem]]とする。
  7. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", numberingSystem)を実行する。
  8. secondsStyle"2-digit"ならば、
    1. CreateDataPropertyOrThrow(nfOptions, "minimumIntegerDigits", 2𝔽)を実行する。
  9. signDisplayedfalseならば、
    1. CreateDataPropertyOrThrow(nfOptions, "signDisplay", "never")を実行する。
  10. CreateDataPropertyOrThrow(nfOptions, "useGrouping", false)を実行する。
  11. fractionDigitsdurationFormat.[[FractionalDigits]]とする。
  12. fractionDigitsundefinedならば、
    1. CreateDataPropertyOrThrow(nfOptions, "maximumFractionDigits", 9𝔽)を実行する。
    2. CreateDataPropertyOrThrow(nfOptions, "minimumFractionDigits", +0𝔽)を実行する。
  13. そうでなければ、
    1. CreateDataPropertyOrThrow(nfOptions, "maximumFractionDigits", fractionDigits)を実行する。
    2. CreateDataPropertyOrThrow(nfOptions, "minimumFractionDigits", fractionDigits)を実行する。
  14. CreateDataPropertyOrThrow(nfOptions, "roundingMode", "trunc")を実行する。
  15. nfを! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOptions »)とする。
  16. secondsPartsPartitionNumberPattern(nf, secondsValue)とする。
  17. secondsPartsの各Record { [[Type]], [[Value]] } partについて、次を行う:
    1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: "second" }をresultに追加する。
  18. resultを返す。

13.5.12 FormatNumericUnits ( durationFormat, duration, firstNumericUnit, signDisplayed )

The abstract operation FormatNumericUnits takes arguments durationFormat (DurationFormat Object), duration (Duration Record), firstNumericUnit (String), and signDisplayed (Boolean) and returns RecordList. durationFormatの有効なロケールおよび整形オプションに従って、"numeric"または"2-digit"スタイルを使用するdurationの要素を表す部分を作成する。 It performs the following steps when called:

  1. Assert: firstNumericUnit"hours""minutes"、または"seconds"である。
  2. numericPartsListを新しい空のListとする。
  3. hoursValueduration.[[Hours]]とする。
  4. hoursDisplaydurationFormat.[[HoursOptions]].[[Display]]とする。
  5. minutesValueduration.[[Minutes]]とする。
  6. minutesDisplaydurationFormat.[[MinutesOptions]].[[Display]]とする。
  7. secondsValueduration.[[Seconds]]とする。
  8. duration.[[Milliseconds]]が0でない、またはduration.[[Microseconds]]が0でない、またはduration.[[Nanoseconds]]が0でないならば、
    1. secondsValuesecondsValue + ComputeFractionalDigits(durationFormat, duration)に設定する。
  9. secondsDisplaydurationFormat.[[SecondsOptions]].[[Display]]とする。
  10. hoursFormattedfalseとする。
  11. firstNumericUnit"hours"ならば、
    1. hoursValueが0でない、またはhoursDisplay"always"ならば、
      1. hoursFormattedtrueに設定する。
  12. secondsValueが0でない、またはsecondsDisplay"always"ならば、
    1. secondsFormattedtrueとする。
  13. そうでなければ、
    1. secondsFormattedfalseとする。
  14. minutesFormattedfalseとする。
  15. firstNumericUnit"hours"またはfirstNumericUnit"minutes"ならば、
    1. hoursFormattedtrueであり、かつsecondsFormattedtrueならば、
      1. minutesFormattedtrueに設定する。
    2. そうでなく、minutesValueが0でない、またはminutesDisplay"always"ならば、
      1. minutesFormattedtrueに設定する。
  16. hoursFormattedtrueならば、
    1. signDisplayedtrueならば、
      1. hoursValueが0であり、かつDurationSign(duration)が-1ならば、
        1. hoursValuenegative-zeroに設定する。
    2. hoursPartsFormatNumericHours(durationFormat, hoursValue, signDisplayed)とする。
    3. numericPartsListnumericPartsListhoursPartsのリスト連結に設定する。
    4. signDisplayedfalseに設定する。
  17. minutesFormattedtrueならば、
    1. signDisplayedtrueならば、
      1. minutesValueが0であり、かつDurationSign(duration)が-1ならば、
        1. minutesValuenegative-zeroに設定する。
    2. minutesPartsFormatNumericMinutes(durationFormat, minutesValue, hoursFormatted, signDisplayed)とする。
    3. numericPartsListnumericPartsListminutesPartsのリスト連結に設定する。
    4. signDisplayedfalseに設定する。
  18. secondsFormattedtrueならば、
    1. secondsPartsFormatNumericSeconds(durationFormat, secondsValue, minutesFormatted, signDisplayed)とする。
    2. numericPartsListnumericPartsListsecondsPartsのリスト連結に設定する。
  19. numericPartsListを返す。

13.5.13 IsFractionalSecondUnitName ( unit )

The abstract operation IsFractionalSecondUnitName takes argument unit (String) and returns Boolean. It performs the following steps when called:

  1. unit"milliseconds""microseconds"、または"nanoseconds"のいずれかならば、trueを返す。
  2. falseを返す。

13.5.14 ListFormatParts ( durationFormat, partitionedPartsList )

The abstract operation ListFormatParts takes arguments durationFormat (DurationFormat Object) and partitionedPartsList (RecordListからなるList) and returns List. durationFormatの有効なロケールおよび整形オプションに従って、partitionedPartsList内のList内の部分に対応するListを作成する。 It performs the following steps when called:

  1. lfOptionsOrdinaryObjectCreate(null) とする。
  2. CreateDataPropertyOrThrow(lfOptions, "type", "unit") を実行する。
  3. listStyledurationFormat.[[Style]] とする。
  4. listStyle"digital" なら、
    1. listStyle"short" に設定する。
  5. CreateDataPropertyOrThrow(lfOptions, "style", listStyle) を実行する。
  6. lf を ! Construct(%Intl.ListFormat%, « durationFormat.[[Locale]], lfOptions ») とする。
  7. strings を新しい空の List とする。
  8. partitionedPartsList の各要素 parts について、次を行う。
    1. string を空の String とする。
    2. parts の各 Record { [[Type]], [[Value]], [[Unit]] } part について、次を行う。
      1. stringstringpart.[[Value]] の文字列連結に設定する。
    3. stringstrings に追加する。
  9. formattedPartsListCreatePartsFromList(lf, strings) とする。
  10. partitionedPartsIndex を 0 とする。
  11. partitionedLengthpartitionedPartsList 内の要素数とする。
  12. flattenedPartsList を新しい空の List とする。
  13. formattedPartsList の各 Record { [[Type]], [[Value]] } listPart について、次を行う。
    1. listPart.[[Type]]"element" なら、
      1. Assert: partitionedPartsIndex < partitionedLength である。
      2. partspartitionedPartsList[partitionedPartsIndex] とする。
      3. parts の各 Record { [[Type]], [[Value]], [[Unit]] } part について、次を行う。
        1. partflattenedPartsList に追加する。
      4. partitionedPartsIndexpartitionedPartsIndex + 1 に設定する。
    2. そうでなければ、
      1. Assert: listPart.[[Type]]"literal" である。
      2. Record { [[Type]]: "literal", [[Value]]: listPart.[[Value]], [[Unit]]: empty } を flattenedPartsList に追加する。
  14. flattenedPartsList を返す。

13.5.15 PartitionDurationFormatPattern ( durationFormat, duration )

The abstract operation PartitionDurationFormatPattern takes arguments durationFormat (DurationFormat) and duration (Duration Record) and returns List. durationFormatの有効なロケールおよび整形オプションに従って、durationに対応する部分を作成する。 It performs the following steps when called:

  1. resultを新しい空のListとする。
  2. signDisplayedtrueとする。
  3. numericUnitFoundfalseとする。
  4. numericUnitFoundfalseである間、Table 24内の各行(ヘッダ行を除く)について、表の順序で繰り返す:
    1. valueを、名前が現在の行のValue Field値であるdurationのフィールドの値とする。
    2. unitOptionsを、名前が現在の行のInternal Slot値であるdurationFormatの内部スロットの値とする。
    3. styleunitOptions.[[Style]]とする。
    4. displayunitOptions.[[Display]]とする。
    5. unitを現在の行のUnit値とする。
    6. numberFormatUnitを現在の行のNumberFormat Unit値とする。
    7. style"numeric"または"2-digit"ならば、
      1. numericPartsListFormatNumericUnits(durationFormat, duration, unit, signDisplayed)とする。
      2. numericPartsListが空でないならば、numericPartsListresultに追加する。
      3. numericUnitFoundtrueに設定する。
    8. そうでなければ、
      1. nfOptionsOrdinaryObjectCreate(null)とする。
      2. NextUnitFractional(durationFormat, unit)がtrueならば、
        1. valuevalue + ComputeFractionalDigits(durationFormat, duration)に設定する。
        2. fractionDigitsdurationFormat.[[FractionalDigits]]とする。
        3. fractionDigitsundefinedならば、
          1. CreateDataPropertyOrThrow(nfOptions, "maximumFractionDigits", 9𝔽)を実行する。
          2. CreateDataPropertyOrThrow(nfOptions, "minimumFractionDigits", +0𝔽)を実行する。
        4. そうでなければ、
          1. CreateDataPropertyOrThrow(nfOptions, "maximumFractionDigits", fractionDigits)を実行する。
          2. CreateDataPropertyOrThrow(nfOptions, "minimumFractionDigits", fractionDigits)を実行する。
        5. CreateDataPropertyOrThrow(nfOptions, "roundingMode", "trunc")を実行する。
        6. numericUnitFoundtrueに設定する。
      3. display"always"である、またはvalueが0でないならば、
        1. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", durationFormat.[[NumberingSystem]])を実行する。
        2. signDisplayedtrueならば、
          1. signDisplayedfalseに設定する。
          2. valueが0であり、かつDurationSign(duration)が-1ならば、valuenegative-zeroに設定する。
        3. そうでなければ、
          1. CreateDataPropertyOrThrow(nfOptions, "signDisplay", "never")を実行する。
        4. CreateDataPropertyOrThrow(nfOptions, "style", "unit")を実行する。
        5. CreateDataPropertyOrThrow(nfOptions, "unit", numberFormatUnit)を実行する。
        6. CreateDataPropertyOrThrow(nfOptions, "unitDisplay", style)を実行する。
        7. nfを! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOptions »)とする。
        8. partsPartitionNumberPattern(nf, value)とする。
        9. listを新しい空のListとする。
        10. partsの各Record { [[Type]], [[Value]] } partについて、次を行う:
          1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: numberFormatUnit }をlistに追加する。
        11. listresultに追加する。
  5. ListFormatParts(durationFormat, result)を返す。
Table 24: PartitionDurationFormatPatternに関連するDurationFormatインスタンスの内部スロットおよびプロパティ
値フィールド 内部スロット 単位 NumberFormat単位
[[Years]] [[YearsOptions]] "years" "year"
[[Months]] [[MonthsOptions]] "months" "month"
[[Weeks]] [[WeeksOptions]] "weeks" "week"
[[Days]] [[DaysOptions]] "days" "day"
[[Hours]] [[HoursOptions]] "hours" "hour"
[[Minutes]] [[MinutesOptions]] "minutes" "minute"
[[Seconds]] [[SecondsOptions]] "seconds" "second"
[[Milliseconds]] [[MillisecondsOptions]] "milliseconds" "millisecond"
[[Microseconds]] [[MicrosecondsOptions]] "microseconds" "microsecond"
[[Nanoseconds]] [[NanosecondsOptions]] "nanoseconds" "nanosecond"

14 ListFormatオブジェクト

14.1 Intl.ListFormatコンストラクタ

Intl.ListFormatコンストラクタは、次のとおりである:

Intlオブジェクトのすべてのサービスコンストラクタプロパティに共通する挙動は、9.1で規定される。

14.1.1 Intl.ListFormat ( [ locales [ , options ] ] )

Intl.ListFormat関数が省略可能な引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. NewTargetがundefinedならば、TypeError例外を投げる。
  2. listFormatを? OrdinaryCreateFromConstructor(NewTarget, "%Intl.ListFormat.prototype%", « [[InitializedListFormat]], [[Locale]], [[Type]], [[Style]], [[Templates]] »)とする。
  3. optionsResolutionを? ResolveOptions(%Intl.ListFormat%, %Intl.ListFormat%.[[LocaleData]], locales, options)とする。
  4. optionsoptionsResolution.[[Options]]に設定する。
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]]とする。
  6. listFormat.[[Locale]]resolvedLocale.[[Locale]]に設定する。
  7. typeを? GetOption(options, "type", string, « "conjunction", "disjunction", "unit" », "conjunction")とする。
  8. listFormat.[[Type]]typeに設定する。
  9. styleを? GetOption(options, "style", string, « "long", "short", "narrow" », "long")とする。
  10. listFormat.[[Style]]styleに設定する。
  11. resolvedLocaleDataresolvedLocale.[[LocaleData]]とする。
  12. dataLocaleTypesresolvedLocaleData.[[<type>]]とする。
  13. listFormat.[[Templates]]dataLocaleTypes.[[<style>]]に設定する。
  14. listFormatを返す。

14.2 Intl.ListFormatコンストラクタのプロパティ

Intl.ListFormatコンストラクタは、次のとおりである:

  • 値が%Function.prototype%である[[Prototype]]内部スロットを持つ。
  • 次のプロパティを持つ:

14.2.1 Intl.ListFormat.prototype

Intl.ListFormat.prototypeの値は%Intl.ListFormat.prototype%である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }を持つ。

14.2.2 Intl.ListFormat.supportedLocalesOf ( locales [ , options ] )

supportedLocalesOfメソッドが引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. availableLocales%Intl.ListFormat%.[[AvailableLocales]]とする。
  2. requestedLocalesを? CanonicalizeLocaleList(locales)とする。
  3. FilterLocales(availableLocales, requestedLocales, options)を返す。

14.2.3 内部スロット

[[AvailableLocales]]内部スロットの値は、9.1で述べられた制約の範囲内で実装定義である。

[[RelevantExtensionKeys]]内部スロットの値は« »である。

[[ResolutionOptionDescriptors]]内部スロットの値は« »である。

Note 1
Intl.ListFormatには関連する拡張キーがない。

[[LocaleData]]内部スロットの値は、%Intl.ListFormat%.[[AvailableLocales]]内の各ロケール値localeについて、9.1で述べられた制約および次の追加制約の範囲内で実装定義である:

  • [[LocaleData]].[[<locale>]]は、3つのフィールド[[conjunction]][[disjunction]]、および[[unit]]を持つRecordである。これらはそれぞれRecordであり、3つの整形スタイルの名前、すなわち[[long]][[short]]、および[[narrow]]を持つフィールドを持たなければならない。
  • それらの各フィールドはListFormat template setと見なされ、[[Pair]][[Start]][[Middle]]、および[[End]]という名前のフィールドを持つRecordListでなければならない。これらの各フィールドは、LDML List Format Rulesで規定されるテンプレート文字列でなければならない。各テンプレート文字列は、部分文字列"{0}"および"{1}"をちょうど1回ずつ含まなければならない。部分文字列"{0}"は部分文字列"{1}"より前に現れるべきである。
Note 2
実装は、Common Locale Data Repository(https://cldr.unicode.org/で入手可能)が提供するロケールデータを使用することが推奨される。LDMLのlistPatternでは、conjunctionは"standard"に、disjunctionは"or"に、unitは"unit"に対応する。
Note 3
リスト型のうち、conjunctionは"and"に基づくリスト(例:"A, B, and C")を表し、disjunctionは"or"に基づくリスト(例:"A, B, or C")を表し、unitは単位付きの値のリスト(例:"5 pounds, 12 ounces")を表す。

14.3 Intl.ListFormatプロトタイプオブジェクトのプロパティ

Intl.ListFormatプロトタイプオブジェクトは、次のとおりである:

  • %Intl.ListFormat.prototype%である。
  • 通常のオブジェクトである。
  • Intl.ListFormatインスタンスではなく、[[InitializedListFormat]]内部スロットまたはIntl.ListFormatインスタンスオブジェクトのその他の内部スロットを持たない。
  • 値が%Object.prototype%である[[Prototype]]内部スロットを持つ。

14.3.1 Intl.ListFormat.prototype.constructor

Intl.ListFormat.prototype.constructorの初期値は%Intl.ListFormat%である。

14.3.2 Intl.ListFormat.prototype.resolvedOptions ( )

この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。

  1. lfthis値とする。
  2. RequireInternalSlot(lf, [[InitializedListFormat]])を実行する。
  3. optionsOrdinaryObjectCreate(%Object.prototype%)とする。
  4. Table 25の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. propertyKeyを現在の行のProperty値とする。
    2. valueを、その名前が現在の行のInternal Slot値であるlfの内部スロットの値とする。
    3. Assert: valueundefinedでない。
    4. CreateDataPropertyOrThrow(options, propertyKey, value)を実行する。
  5. optionsを返す。
Table 25: ListFormatインスタンスのResolved Options
内部スロット プロパティ
[[Locale]] "locale"
[[Type]] "type"
[[Style]] "style"

14.3.3 Intl.ListFormat.prototype.format ( list )

formatメソッドが引数listとともに呼び出されるとき、次の手順が実行される:

  1. lfthis値とする。
  2. RequireInternalSlot(lf, [[InitializedListFormat]])を実行する。
  3. stringListを? StringListFromIterable(list)とする。
  4. FormatList(lf, stringList)を返す。

14.3.4 Intl.ListFormat.prototype.formatToParts ( list )

formatToPartsメソッドが引数listとともに呼び出されるとき、次の手順が実行される:

  1. lfthis値とする。
  2. RequireInternalSlot(lf, [[InitializedListFormat]])を実行する。
  3. stringListを? StringListFromIterable(list)とする。
  4. FormatListToParts(lf, stringList)を返す。

14.3.5 Intl.ListFormat.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag%プロパティの初期値はString値"Intl.ListFormat"である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }を持つ。

14.4 Intl.ListFormatインスタンスのプロパティ

Intl.ListFormatインスタンスは、%Intl.ListFormat.prototype%からプロパティを継承する。

Intl.ListFormatインスタンスは[[InitializedListFormat]]内部スロットを持つ。

Intl.ListFormatインスタンスは、Intl.ListFormatコンストラクタによって計算されるいくつかの内部スロットも持つ:

  • [[Locale]]は、リスト整形スタイルで使用されるローカライズのロケールの言語タグを持つString値である。
  • [[Type]]は、使用される型のリストを識別する、String値"conjunction""disjunction"、または"unit"のいずれかである。
  • [[Style]]は、使用されるリスト整形スタイルを識別する、String値"long""short"、または"narrow"のいずれかである。
  • [[Templates]]ListFormat template setである。

14.5 ListFormatオブジェクトのための抽象操作

14.5.1 DeconstructPattern ( pattern, placeables )

The abstract operation DeconstructPattern takes arguments pattern (Pattern String) and placeables (Record) and returns List.

パターン文字列を部分のListへ分解する。

placeablesは、キーがパターン文字列で使用される置換可能トークンであり、値が結果List内でそのトークン部分を表すために使用されるparts RecordPartitionPatternからのものと同様)であるRecordである。 例:

入力:
  DeconstructPattern("AA{xx}BB{yy}CC", {
    [[xx]]: {[[Type]]: "hour", [[Value]]: "15"},
    [[yy]]: {[[Type]]: "minute", [[Value]]: "06"}
  })

出力(parts RecordのList):
  «
    {[[Type]]: "literal", [[Value]]: "AA"},
    {[[Type]]: "hour", [[Value]]: "15"},
    {[[Type]]: "literal", [[Value]]: "BB"},
    {[[Type]]: "minute", [[Value]]: "06"},
    {[[Type]]: "literal", [[Value]]: "CC"}
  »
          

It performs the following steps when called:

  1. patternPartsPartitionPattern(pattern)とする。
  2. resultを新しい空のListとする。
  3. patternPartsの各Record { [[Type]], [[Value]] } patternPartについて、次を行う:
    1. partTypepatternPart.[[Type]]とする。
    2. partType"literal"ならば、
      1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }をresultに追加する。
    3. そうでなければ、
      1. Assert: placeablesはフィールド[[<partType>]]を持つ。
      2. substitutionplaceables.[[<partType>]]とする。
      3. substitutionListならば、
        1. substitutionの各要素partについて、次を行う:
          1. partresultに追加する。
      4. そうでなければ、
        1. substitutionresultに追加する。
  4. resultを返す。

14.5.2 CreatePartsFromList ( listFormat, list )

The abstract operation CreatePartsFromList takes arguments listFormat (Intl.ListFormat) and list (StringのList) and returns フィールド[[Type]]"element"または"literal")および[[Value]](String)を持つRecordList. listFormatの有効なロケールおよび整形オプションに従って、対応する部分のListを作成する。 It performs the following steps when called:

  1. sizelist の要素数とする。
  2. size が 0 なら、
    1. 新しい空の List を返す。
  3. size が 2 なら、
    1. n を、listFormat.[[Locale]]list[0]、および list[1] に基づく listFormat.[[Templates]] へのインデックスとする。
    2. patternlistFormat.[[Templates]][n].[[Pair]] とする。
    3. firstRecord { [[Type]]: "element", [[Value]]: list[0] } とする。
    4. secondRecord { [[Type]]: "element", [[Value]]: list[1] } とする。
    5. placeablesRecord { [[0]]: first, [[1]]: second } とする。
    6. DeconstructPattern(pattern, placeables) を返す。
  4. lastRecord { [[Type]]: "element", [[Value]]: list[size - 1] } とする。
  5. parts を « last » とする。
  6. isize - 2 とする。
  7. i ≥ 0 の間、繰り返す。
    1. headRecord { [[Type]]: "element", [[Value]]: list[i] } とする。
    2. n を、listFormat.[[Locale]]head、および parts に基づく listFormat.[[Templates]] への実装定義のインデックスとする。
    3. i が 0 なら、
      1. patternlistFormat.[[Templates]][n].[[Start]] とする。
    4. そうでなく isize - 2 より小さいなら、
      1. patternlistFormat.[[Templates]][n].[[Middle]] とする。
    5. そうでなければ、
      1. patternlistFormat.[[Templates]][n].[[End]] とする。
    6. placeablesRecord { [[0]]: head, [[1]]: parts } とする。
    7. partsDeconstructPattern(pattern, placeables) に設定する。
    8. ii - 1 に設定する。
  8. parts を返す。
Note
複数のテンプレートから選択するインデックスnにより、スペイン語のように、後続の語に応じて"y"または"e"のいずれかが選択される場合など、接続詞を文脈に依存させることができる。

14.5.3 FormatList ( listFormat, list )

The abstract operation FormatList takes arguments listFormat (Intl.ListFormat) and list (StringのList) and returns String. It performs the following steps when called:

  1. partsCreatePartsFromList(listFormat, list)とする。
  2. resultを空のStringとする。
  3. partsの各Record { [[Type]], [[Value]] } partについて、次を行う:
    1. resultresultpart.[[Value]]の文字列連結に設定する。
  4. resultを返す。

14.5.4 FormatListToParts ( listFormat, list )

The abstract operation FormatListToParts takes arguments listFormat (Intl.ListFormat) and list (StringのList) and returns Array. It performs the following steps when called:

  1. partsCreatePartsFromList(listFormat, list)とする。
  2. resultを! ArrayCreate(0)とする。
  3. nを0とする。
  4. partsの各Record { [[Type]], [[Value]] } partについて、次を行う:
    1. objOrdinaryObjectCreate(%Object.prototype%)とする。
    2. CreateDataPropertyOrThrow(obj, "type", part.[[Type]])を実行する。
    3. CreateDataPropertyOrThrow(obj, "value", part.[[Value]])を実行する。
    4. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), obj)を実行する。
    5. nn + 1 に設定する。
  5. resultを返す。

14.5.5 StringListFromIterable ( iterable )

The abstract operation StringListFromIterable takes argument iterable (ECMAScript言語値) and returns StringのListを含む通常完了、またはthrow完了. It performs the following steps when called:

  1. iterableundefinedならば、
    1. 新しい空のListを返す。
  2. iteratorRecordを? GetIterator(iterable, sync)とする。
  3. listを新しい空のListとする。
  4. 繰り返す:
    1. nextを? IteratorStepValue(iteratorRecord)とする。
    2. nextdoneならば、
      1. listを返す。
    3. nextがStringでないならば、
      1. errorThrowCompletion(新しく作成されたTypeErrorオブジェクト)とする。
      2. IteratorClose(iteratorRecord, error)を返す。
    4. nextlistに追加する。
Note

このアルゴリズムは、Stringでない値に遭遇したときに例外を発生させる。任意の値に対する明らかなロケール認識の強制変換がないためである。

15 Localeオブジェクト

15.1 Intl.Localeコンストラクタ

Intl.Localeコンストラクタは、次のとおりである:

15.1.1 Intl.Locale ( tag [ , options ] )

Intl.Locale関数が引数tagおよび省略可能な引数optionsとともに呼び出されるとき、次の手順が実行される:

#### ECMARKDOWN PARSE FAILED ####
        1. NewTarget が *undefined* なら、*TypeError* 例外を投げる。
        1. _localeExtensionKeys_ を %Intl.Locale%.[[LocaleExtensionKeys]] とする。
        1. _internalSlotsList_ を « [[InitializedLocale]], [[Locale]], [[Calendar]], [[Collation]], [[FirstDayOfWeek]], [[HourCycle]], [[NumberingSystem]] » とする。
        1. _localeExtensionKeys_ が *"kf"* を含むなら、
          1. [[CaseFirst]] を _internalSlotsList_ に追加する。
        1. _localeExtensionKeys_ が *"kn"* を含むなら、
          1. [[Numeric]] を _internalSlotsList_ に追加する。
        1. _locale_ を ? OrdinaryCreateFromConstructor(NewTarget, *"%Intl.Locale.prototype%"*, _internalSlotsList_) とする。
        1. _tag_ が String でなく、かつ _tag_ が Object でもないなら、*TypeError* 例外を投げる。
        1. _tag_ が Object で、かつ _tag_ が [[InitializedLocale]] 内部スロットを持つなら、
          1. _tag_ を _tag_.[[Locale]] に設定する。
        1. そうでなければ、
          1. _tag_ を ? ToString(_tag_) に設定する。
        1. _options_ を ? CoerceOptionsToObject(_options_) に設定する。
        1. IsWellFormedLanguageTag(_tag_) が *false* なら、*RangeError* 例外を投げる。
        1. NOTE: LanguageId 正規化は、supplementalMetadata.xml からの Alias Rules に従って _tag_ を任意の方法で変更し得るため、_options_ からの上書きを適用する前に、そのような正規化を実行する必要がある。
        1. _tag_ を CanonicalizeUnicodeLocaleId(_tag_) に設定する。
        1. _tag_ を ? UpdateLanguageId(_tag_, _options_) に設定する。
        1. _opt_ を新しい Record とする。
        1. _calendar_ を ? GetOption(_options_, *"calendar"*, ~string~, ~empty~, *undefined*) とする。
        1. _calendar_ が *undefined* でないなら、
          1. _calendar_ が type Unicode ロケール非終端記号に一致できないなら、*RangeError* 例外を投げる。
        1. _opt_.[[ca]] を _calendar_ に設定する。
        1. _collation_ を ? GetOption(_options_, *"collation"*, ~string~, ~empty~, *undefined*) とする。
        1. _collation_ が *undefined* でないなら、
          1. _collation_ が type Unicode ロケール非終端記号に一致できないなら、*RangeError* 例外を投げる。
        1. _opt_.[[co]] を _collation_ に設定する。
        1. _fw_ を ? GetOption(_options_, *"firstDayOfWeek"*, ~string~, ~empty~, *undefined*) とする。
        1. _fw_ が *undefined* でないなら、
          1. _fw_ を WeekdayToUValue(_fw_) に設定する。
          1. _fw_ が type Unicode ロケール非終端記号に一致できないなら、*RangeError* 例外を投げる。
        1. _opt_.[[fw]] を _fw_ に設定する。
        1. _hc_ を ? GetOption(_options_, *"hourCycle"*, ~string~, « *"h11"*, *"h12"*, *"h23"*, *"h24"* », *undefined*) とする。
        1. _opt_.[[hc]] を _hc_ に設定する。
        1. _kf_ を ? GetOption(_options_, *"caseFirst"*, ~string~, « *"upper"*, *"lower"*, *"false"* », *undefined*) とする。
        1. _opt_.[[kf]] を _kf_ に設定する。
        1. _kn_ を ? GetOption(_options_, *"numeric"*, ~boolean~, ~empty~, *undefined*) とする。
        1. _kn_ が *undefined* でないなら、_kn_ を ! ToString(_kn_) に設定する。
        1. _opt_.[[kn]] を _kn_ に設定する。
        1. _numberingSystem_ を ? GetOption(_options_, *"numberingSystem"*, ~string~, ~empty~, *undefined*) とする。
        1. _numberingSystem_ が *undefined* でないなら、
          1. _numberingSystem_ が type Unicode ロケール非終端記号に一致できないなら、*RangeError* 例外を投げる。
        1. _opt_.[[nu]] を _numberingSystem_ に設定する。
        1. _localeRecord_ を MakeLocaleRecord(_tag_, _opt_, _localeExtensionKeys_) とする。
        1. _locale_.[[Locale]] を _localeRecord_.[[locale]] に設定する。
        1. _locale_.[[Calendar]] を _localeRecord_.[[ca]] に設定する。
        1. _locale_.[[Collation]] を _localeRecord_.[[co]] に設定する。
        1. _locale_.[[FirstDayOfWeek]] を _localeRecord_.[[fw]] に設定する。
        1. _locale_.[[HourCycle]] を _localeRecord_.[[hc]] に設定する。
        1. _localeExtensionKeys_ が *"kf"* を含むなら、
          1. _locale_.[[CaseFirst]] を _localeRecord_.[[kf]] に設定する。
        1. _localeExtensionKeys_ が *"kn"* を含むなら、
          1. _localeRecord_.[[kn]] が *"true"* または空の String のいずれかなら、
            1. _locale_.[[Numeric]] を *true* に設定する。
          1. そうでなければ、
            1. _locale_.[[Numeric]] を *false* に設定する。
        1. _locale_.[[NumberingSystem]] を _localeRecord_.[[nu]] に設定する。
        1. _locale_ を返す。
      

15.1.2 UpdateLanguageId ( tag, options )

The abstract operation UpdateLanguageId takes arguments tag (整形式言語タグ) and options (Object) and returns 整形式言語タグを含む通常完了またはthrow完了. tag内のunicode_language_idサブタグoptionsの対応するプロパティから更新し、それらを検証し、結果を返す。 It performs the following steps when called:

  1. baseNameGetLocaleBaseName(tag)とする。
  2. languageを? GetOption(options, "language", string, empty, GetLocaleLanguage(baseName))とする。
  3. languageunicode_language_subtag Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
  4. scriptを? GetOption(options, "script", string, empty, GetLocaleScript(baseName))とする。
  5. scriptundefinedでないならば、
    1. scriptunicode_script_subtag Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
  6. regionを? GetOption(options, "region", string, empty, GetLocaleRegion(baseName))とする。
  7. regionundefinedでないならば、
    1. regionunicode_region_subtag Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
  8. variantsを? GetOption(options, "variants", string, empty, GetLocaleVariants(baseName))とする。
  9. variantsundefinedでないならば、
    1. variantsが空のStringならば、RangeError例外を投げる。
    2. lowerVariantsvariantsのASCII小文字化とする。
    3. variantSubtagsStringSplitToList(lowerVariants, "-")とする。
    4. variantSubtagsの各要素variantについて、次を行う:
      1. variantunicode_variant_subtag Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
    5. variantSubtagsが重複要素を含むならば、RangeError例外を投げる。
  10. allExtensionsbaseNameの後に続くtagの接尾部とする。
  11. newTaglanguageとする。
  12. scriptundefinedでないならば、newTagnewTag"-"、およびscriptの文字列連結に設定する。
  13. regionundefinedでないならば、newTagnewTag"-"、およびregionの文字列連結に設定する。
  14. variantsundefinedでないならば、newTagnewTag"-"、およびvariantsの文字列連結に設定する。
  15. newTagnewTagallExtensionsの文字列連結に設定する。
  16. newTagを返す。

15.1.3 MakeLocaleRecord ( tag, options, localeExtensionKeys )

The abstract operation MakeLocaleRecord takes arguments tag (言語タグ), options (Record), and localeExtensionKeys (StringのList) and returns Record. localeExtensionKeysの各要素が、tagの任意のUnicodeロケール拡張シーケンスからのデータを持つ対応するフィールドを定義し、それがoptionsの対応するフィールドによって上書きされるRecordを構築して返す。また、それらのフィールドをtagへ組み込んだ結果として得られるUnicode正規化済みロケール識別子を含む[[locale]]フィールドも追加で含む。 It performs the following steps when called:

  1. tagUnicodeロケール拡張シーケンスであるsubstringを含むならば、
    1. extensionを、tag内のUnicodeロケール拡張シーケンスsubstringからなるString値とする。
    2. componentsUnicodeExtensionComponents(extension)とする。
    3. attributescomponents.[[Attributes]]とする。
    4. keywordscomponents.[[Keywords]]とする。
  2. そうでなければ、
    1. attributesを新しい空のListとする。
    2. keywordsを新しい空のListとする。
  3. resultを新しいRecordとする。
  4. localeExtensionKeysの各要素keyについて、次を行う:
    1. keywords[[Key]]keyである要素を含むならば、
      1. entryを、[[Key]]keyであるkeywordsの要素とする。
      2. valueentry.[[Value]]とする。
    2. そうでなければ、
      1. entryemptyとする。
      2. valueundefinedとする。
    3. Assert: optionsはフィールド[[<key>]]を持つ。
    4. overrideValueoptions.[[<key>]]とする。
    5. overrideValueundefinedでないならば、
      1. valueCanonicalizeUValue(key, overrideValue)に設定する。
      2. entryemptyでないならば、
        1. entry.[[Value]]valueに設定する。
      3. そうでなければ、
        1. Record { [[Key]]: key, [[Value]]: value }をkeywordsに追加する。
    6. result.[[<key>]]をvalueに設定する。
  5. localeを、任意のUnicodeロケール拡張シーケンスが削除されたtagであるString値とする。
  6. attributesが空でない、またはkeywordsが空でないならば、
    1. result.[[locale]]InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords)に設定する。
  7. そうでなければ、
    1. result.[[locale]]CanonicalizeUnicodeLocaleId(locale)に設定する。
  8. resultを返す。

15.2 Intl.Localeコンストラクタのプロパティ

Intl.Localeコンストラクタは、次のとおりである:

  • 値が%Function.prototype%である[[Prototype]]内部スロットを持つ。
  • 次のプロパティを持つ:

15.2.1 Intl.Locale.prototype

Intl.Locale.prototypeの値は%Intl.Locale.prototype%である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }を持つ。

15.2.2 内部スロット

[[LocaleExtensionKeys]]内部スロットの値は、« "ca", "co", "fw", "hc", "nu" »のすべての要素を含まなければならず、%Intl.Collator%.[[RelevantExtensionKeys]]の要素でもある« "kf", "kn" »の任意の要素を追加で含まなければならず、その他の要素を含んではならないListである。

15.3 Intl.Localeプロトタイプオブジェクトのプロパティ

Intl.Localeプロトタイプオブジェクトは、次のとおりである:

  • %Intl.Locale.prototype%である。
  • 通常のオブジェクトである。
  • Intl.Localeインスタンスではなく、[[InitializedLocale]]内部スロットまたはIntl.Localeインスタンスオブジェクトのその他の内部スロットを持たない。
  • 値が%Object.prototype%である[[Prototype]]内部スロットを持つ。

15.3.1 Intl.Locale.prototype.constructor

Intl.Locale.prototype.constructorの初期値は%Intl.Locale%である。

15.3.2 get Intl.Locale.prototype.baseName

Intl.Locale.prototype.baseNameは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. GetLocaleBaseName(loc.[[Locale]])を返す。

15.3.3 get Intl.Locale.prototype.calendar

Intl.Locale.prototype.calendarは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. loc.[[Calendar]]を返す。

15.3.4 get Intl.Locale.prototype.caseFirst

このプロパティは、%Intl.Locale%.[[LocaleExtensionKeys]]"kf"を含む場合にのみ存在する。

Intl.Locale.prototype.caseFirstは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. loc.[[CaseFirst]]を返す。

15.3.5 get Intl.Locale.prototype.collation

Intl.Locale.prototype.collationは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. loc.[[Collation]]を返す。

15.3.6 get Intl.Locale.prototype.firstDayOfWeek

Intl.Locale.prototype.firstDayOfWeekは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. loc.[[FirstDayOfWeek]]を返す。

15.3.7 get Intl.Locale.prototype.hourCycle

Intl.Locale.prototype.hourCycleは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. loc.[[HourCycle]]を返す。

15.3.8 get Intl.Locale.prototype.language

Intl.Locale.prototype.languageは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. GetLocaleLanguage(loc.[[Locale]])を返す。

15.3.9 Intl.Locale.prototype.maximize ( )

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. maximalを、loc.[[Locale]]に適用されたAdd Likely Subtagsアルゴリズムの結果とする。エラーが通知されたならば、maximalloc.[[Locale]]に設定する。
  4. Construct(%Intl.Locale%, « maximal »)を返す。

15.3.10 Intl.Locale.prototype.minimize ( )

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. minimalを、loc.[[Locale]]に適用されたRemove Likely Subtagsアルゴリズムの結果とする。エラーが通知されたならば、minimalloc.[[Locale]]に設定する。
  4. Construct(%Intl.Locale%, « minimal »)を返す。

15.3.11 get Intl.Locale.prototype.numberingSystem

Intl.Locale.prototype.numberingSystemは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. loc.[[NumberingSystem]]を返す。

15.3.12 get Intl.Locale.prototype.numeric

このプロパティは、%Intl.Locale%.[[LocaleExtensionKeys]]"kn"を含む場合にのみ存在する。

Intl.Locale.prototype.numericは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. loc.[[Numeric]]を返す。

15.3.13 get Intl.Locale.prototype.region

Intl.Locale.prototype.regionは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. GetLocaleRegion(loc.[[Locale]])を返す。

15.3.14 get Intl.Locale.prototype.script

Intl.Locale.prototype.scriptは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. GetLocaleScript(loc.[[Locale]])を返す。

15.3.15 Intl.Locale.prototype.toString ( )

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. loc.[[Locale]]を返す。

15.3.16 Intl.Locale.prototype.getCalendars ( )

getCalendarsメソッドが呼び出されるとき、次の手順が実行される:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. CalendarsOfLocale(loc)を返す。

15.3.17 Intl.Locale.prototype.getCollations ( )

getCollationsメソッドが呼び出されるとき、次の手順が実行される:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. CollationsOfLocale(loc)を返す。

15.3.18 Intl.Locale.prototype.getHourCycles ( )

getHourCyclesメソッドが呼び出されるとき、次の手順が実行される:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. HourCyclesOfLocale(loc)を返す。

15.3.19 Intl.Locale.prototype.getNumberingSystems ( )

getNumberingSystemsメソッドが呼び出されるとき、次の手順が実行される:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. NumberingSystemsOfLocale(loc)を返す。

15.3.20 Intl.Locale.prototype.getTimeZones ( )

getTimeZonesメソッドが呼び出されるとき、次の手順が実行される:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. TimeZonesOfLocale(loc)を返す。

15.3.21 Intl.Locale.prototype.getTextInfo ( )

getTextInfoメソッドが呼び出されるとき、次の手順が実行される:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. infoOrdinaryObjectCreate(%Object.prototype%)とする。
  4. dirTextDirectionOfLocale(loc)とする。
  5. CreateDataPropertyOrThrow(info, "direction", dir)を実行する。
  6. infoを返す。

15.3.22 Intl.Locale.prototype.getWeekInfo ( )

getWeekInfoメソッドが呼び出されるとき、次の手順が実行される:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. infoOrdinaryObjectCreate(%Object.prototype%)とする。
  4. weekInfoWeekInfoOfLocale(loc)とする。
  5. CreateDataPropertyOrThrow(info, "firstDay", weekInfo.[[FirstDay]])を実行する。
  6. CreateDataPropertyOrThrow(info, "weekend", CreateArrayFromList(weekInfo.[[Weekend]]))を実行する。
  7. infoを返す。

15.3.23 get Intl.Locale.prototype.variants

Intl.Locale.prototype.variantsは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. locthis値とする。
  2. RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. GetLocaleVariants(loc.[[Locale]])を返す。

15.3.24 Intl.Locale.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag%プロパティの初期値はString値"Intl.Locale"である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }を持つ。

15.4 Intl.Localeインスタンスのプロパティ

Intl.Localeインスタンスは、%Intl.Locale.prototype%からプロパティを継承する通常のオブジェクトである。

Intl.Localeインスタンスは[[InitializedLocale]]内部スロットを持つ。

Intl.Localeインスタンスは、Intl.Localeコンストラクタによって計算されるいくつかの内部スロットも持つ:

  • [[Locale]]は、整形に使用されるローカライズのロケールの言語タグを持つString値である。
  • [[Calendar]]は、undefinedまたは正準形式の整形式Unicode Calendar IdentifierであるString値のいずれかである。
  • [[Collation]]は、undefinedまたは正準形式の整形式Unicode Collation IdentifierであるString値のいずれかである。
  • [[FirstDayOfWeek]]は、undefinedまたは正準形式の有効なUnicode First Day IdentifierであるString値のいずれかである。
  • [[HourCycle]]は、undefinedまたは正準形式の有効なUnicode Hour Cycle IdentifierであるString値のいずれかである。
  • [[NumberingSystem]]は、undefinedまたは正準形式の整形式Unicode Number System IdentifierであるString値のいずれかである。
  • [[CaseFirst]]は、undefinedまたはString値"upper""lower""false"のいずれかである。この内部スロットは、%Intl.Locale%[[LocaleExtensionKeys]]内部スロットが"kf"を含む場合にのみ存在する。
  • [[Numeric]]は、undefinedまたはロケールによって数値ソートが使用されるかどうかを指定するBoolean値である。この内部スロットは、%Intl.Locale%[[LocaleExtensionKeys]]内部スロットが"kn"を含む場合にのみ存在する。

15.5 Localeオブジェクトのための抽象操作

15.5.1 GetLocaleBaseName ( locale )

The abstract operation GetLocaleBaseName takes argument locale (String) and returns String. It performs the following steps when called:

  1. Assert: localeunicode_locale_id Unicodeロケール非終端記号により一致させることができる。
  2. localeのうち、unicode_language_id Unicodeロケール非終端記号により一致する最長の接頭部を返す。

15.5.2 GetLocaleLanguage ( locale )

The abstract operation GetLocaleLanguage takes argument locale (String) and returns String. It performs the following steps when called:

  1. baseNameGetLocaleBaseName(locale)とする。
  2. Assert: baseNameの最初のサブタグunicode_language_subtag Unicodeロケール非終端記号により一致させることができる。
  3. baseNameの最初のサブタグを返す。

15.5.3 GetLocaleScript ( locale )

The abstract operation GetLocaleScript takes argument locale (String) and returns Stringまたはundefined. It performs the following steps when called:

  1. baseNameGetLocaleBaseName(locale)とする。
  2. Assert: baseNameは、unicode_script_subtag Unicodeロケール非終端記号により一致させることができるサブタグを高々1つ含む。
  3. baseNameunicode_script_subtag Unicodeロケール非終端記号により一致するサブタグを含むならば、そのサブタグを返す。
  4. undefinedを返す。

15.5.4 GetLocaleRegion ( locale )

The abstract operation GetLocaleRegion takes argument locale (String) and returns Stringまたはundefined. It performs the following steps when called:

  1. baseNameGetLocaleBaseName(locale)とする。
  2. NOTE: unicode_region_subtagサブタグは、最初のunicode_language_subtagサブタグの直後、必要に応じてその間に単一のunicode_script_subtagサブタグを伴う位置でのみ有効である。その位置では、unicode_region_subtagは他の有効なサブタグと混同され得ない。すべての生成規則が互いに素であるためである。
  3. Assert: baseNameの最初のサブタグunicode_language_subtag Unicodeロケール非終端記号により一致させることができる。
  4. baseNameTailを、最初のサブタグに続くbaseNameの接尾部とする。
  5. Assert: baseNameTailは、unicode_region_subtag Unicodeロケール非終端記号により一致させることができるサブタグを高々1つ含む。
  6. baseNameTailunicode_region_subtag Unicodeロケール非終端記号により一致するサブタグを含むならば、そのサブタグを返す。
  7. undefinedを返す。

15.5.5 GetLocaleVariants ( locale )

The abstract operation GetLocaleVariants takes argument locale (String) and returns Stringまたはundefined. It performs the following steps when called:

  1. baseNameGetLocaleBaseName(locale) とする。
  2. NOTE: baseName 内で "-" が前に付く各サブタグは、unicode_script_subtagunicode_region_subtag、または unicode_variant_subtag のいずれかであるが、unicode_variant_subtag に一致する任意の substring は、他の生成規則のいずれかにも一致し得るその任意の接頭辞よりも厳密に長い。
  3. subtagsStringSplitToList(baseName, "-") とする。
  4. dashIndexsubtags[0] の長さとする。
  5. subtags から最初の要素を取り除く。
  6. subtags の各 String subtag について、次を行う。
    1. subtagunicode_variant_subtag Unicode ロケール非終端記号に一致するなら、
      1. baseNamedashIndex + 1 から始まる部分文字列を返す。
    2. subtagLengthsubtag の長さとする。
    3. dashIndexdashIndex + subtagLength + 1 に設定する。
  7. undefined を返す。

15.5.6 UnicodeExtensionValue ( locale, key )

The abstract operation UnicodeExtensionValue takes arguments locale (Unicode正規化済みロケール識別子) and key (String) and returns Stringまたはempty. It performs the following steps when called:

  1. localeUnicodeロケール拡張シーケンスを含むならば、
    1. extensionlocaleUnicodeロケール拡張シーケンスとする。
    2. componentsUnicodeExtensionComponents(extension)とする。
    3. keywordscomponents.[[Keywords]]とする。
    4. keywordsの要素entryentry.[[Key]]keyであるものが存在するならば、entry.[[Value]]を返す。
  2. emptyを返す。

15.5.7 CanonicalUnicodeSubdivision ( locale, key )

The abstract operation CanonicalUnicodeSubdivision takes arguments locale (Unicode正規化済みロケール識別子) and key ("rg"または"sd") and returns Stringまたはundefined. It performs the following steps when called:

  1. subdivisionUnicodeExtensionValue(locale, key)とする。
  2. subdivisionemptyならば、undefinedを返す。
  3. subdivisionunicode_subdivision_id Unicodeロケール非終端記号により一致させることができないならば、undefinedを返す。
  4. regionを、unicode_region_subtag Unicodeロケール非終端記号により一致するsubdivisionの最長の接頭部とする。
  5. regionLocale"und-"regionの文字列連結とする。
  6. regionLocaleCanonicalizeUnicodeLocaleId(regionLocale)に設定する。
  7. GetLocaleRegion(regionLocale)を返す。

15.5.8 RegionPreference ( locale )

The abstract operation RegionPreference takes argument locale (Unicode正規化済みロケール識別子) and returns フィールド[[Region]](String)および[[RegionOverride]](Stringまたはundefined)を持つRecord. It performs the following steps when called:

  1. regionGetLocaleRegion(locale)とする。
  2. regionundefinedならば、
    1. regionCanonicalUnicodeSubdivision(locale, "sd")に設定する。
    2. regionundefinedならば、
      1. maximalを、localeに適用されたAdd Likely Subtagsアルゴリズムの結果とする。エラーが通知されたならば、maximallocaleに設定する。
      2. maximalCanonicalizeUnicodeLocaleId(maximal)に設定する。
      3. regionGetLocaleRegion(maximal)に設定する。
      4. regionundefinedならば、
        1. region"001"に設定する。
  3. regionOverrideCanonicalUnicodeSubdivision(locale, "rg")とする。
  4. { [[Region]]: region, [[RegionOverride]]: regionOverride }を返す。

15.5.9 CalendarsOfLocale ( loc )

The implementation-defined abstract operation CalendarsOfLocale takes argument loc (Intl.Locale) and returns Array. 次のアルゴリズムは、Unicode Technical Standard #35 Part 4 Dates, Calendar Preference Dataで規定されるLocaleデータを参照する。 It performs the following steps when called:

  1. loc.[[Calendar]]undefinedでないならば、
    1. CreateArrayFromListloc.[[Calendar]] »)を返す。
  2. preferenceRegionPreference(loc.[[Locale]])とする。
  3. regionpreference.[[Region]]とする。
  4. regionOverridepreference.[[RegionOverride]]とする。
  5. regionOverrideundefinedでなく、かつregionOverrideのカレンダー選好データが利用可能ならば、
    1. lookupRegionregionOverrideとする。
  6. そうでなければ、
    1. lookupRegionregionとする。
  7. listを新しい空のListとする。
  8. availableCalendarsAvailableCalendars()とする。
  9. calendarsInUseを、lookupRegionにおける日時整形で一般に使用される一意なカレンダー型Listであり、lookupRegionでの使用選好の降順でソートされたものとする。lookupRegionのカレンダー選好データが利用可能でない場合、このListは空である。
  10. calendarsInUseの各要素identifierについて、次を行う:
    1. canonicalCanonicalizeUValue("ca", identifier)とする。
    2. identifiercanonicalであり、かつavailableCalendarsidentifierを含むならば、
      1. identifierlistに追加する。
  11. listが空ならば、listを« "gregory" »に設定する。
  12. CreateArrayFromList(list)を返す。

15.5.10 CollationsOfLocale ( loc )

The implementation-defined abstract operation CollationsOfLocale takes argument loc (Intl.Locale) and returns Array. It performs the following steps when called:

  1. loc.[[Collation]]undefinedでないならば、
    1. CreateArrayFromListloc.[[Collation]] »)を返す。
  2. languageGetLocaleLanguage(loc.[[Locale]])とする。
  3. language"und"でないならば、
    1. matchLookupMatchingLocaleByPrefix(%Intl.Collator%.[[AvailableLocales]], « loc.[[Locale]] »)とする。
    2. matchundefinedでないならばfoundLocalematch.[[locale]]とし、そうでなければfoundLocaleDefaultLocale()とする。
    3. foundLocaleData%Intl.Collator%.[[SortLocaleData]].[[<foundLocale>]]とする。
    4. listfoundLocaleData.[[co]]のコピーとする。
    5. Assert: list[0]はnullである。
    6. listから最初の要素を削除する。
  4. そうでなければ、
    1. listを« "emoji", "eor" »とする。
  5. sortedを、辞書式コード単位順序に従ってソートされたlistのコピーとする。
  6. CreateArrayFromList(sorted)を返す。

15.5.11 HourCyclesOfLocale ( loc )

The implementation-defined abstract operation HourCyclesOfLocale takes argument loc (Intl.Locale) and returns Array. 次のアルゴリズムは、Unicode Technical Standard #35 Part 4 Dates, Time Dataで規定されるLocaleデータを参照する。 It performs the following steps when called:

  1. loc.[[HourCycle]]undefinedでないならば、
    1. CreateArrayFromListloc.[[HourCycle]] »)を返す。
  2. preferenceRegionPreference(loc.[[Locale]])とする。
  3. regionpreference.[[Region]]とする。
  4. regionOverridepreference.[[RegionOverride]]とする。
  5. regionOverrideundefinedでなく、かつregionOverrideの時刻データが利用可能ならば、
    1. lookupRegionregionOverrideとする。
  6. そうでなければ、
    1. lookupRegionregionとする。
  7. listを、一意な時制識別子のListであり、12時間形式("h11""h12")または24時間形式("h23""h24")のいずれかを示す小文字String値でなければならず、lookupRegionにおける日時整形で一般に使用されるものの降順の選好でソートされたものとする。lookupRegionの時刻データが利用可能でない場合、このListは空である。
  8. listが空ならば、listを« "h23" »に設定する。
  9. CreateArrayFromList(list)を返す。

15.5.12 NumberingSystemsOfLocale ( loc )

The implementation-defined abstract operation NumberingSystemsOfLocale takes argument loc (Intl.Locale) and returns Array. It performs the following steps when called:

  1. loc.[[NumberingSystem]]undefinedでないならば、
    1. CreateArrayFromListloc.[[NumberingSystem]] »)を返す。
  2. matchLookupMatchingLocaleByPrefix(%Intl.NumberFormat%.[[AvailableLocales]], « loc.[[Locale]] »)とする。
  3. matchundefinedでないならば、
    1. foundLocalematch.[[locale]]とする。
    2. foundLocaleData%Intl.NumberFormat%.[[LocaleData]].[[<foundLocale>]]とする。
    3. numberingSystemsfoundLocaleData.[[nu]]とする。
    4. listを« numberingSystems[0] »とする。
  4. そうでなければ、
    1. listを« "latn" »とする。
  5. CreateArrayFromList(list)を返す。

15.5.13 TimeZonesOfLocale ( loc )

The implementation-defined abstract operation TimeZonesOfLocale takes argument loc (Intl.Locale) and returns Arrayまたはundefined. It performs the following steps when called:

  1. regionGetLocaleRegion(loc.[[Locale]])とする。
  2. regionundefinedならば、undefinedを返す。
  3. listを、一意な正準タイムゾーン識別子のListであり、IANA Time Zone Databaseの正準Zone名を示すString値でなければならず、regionで一般に使用されるものとする。regionで一般に使用されるタイムゾーンがない場合、このListは空である。このListは辞書式コード単位順序に従ってソートされる。
  4. CreateArrayFromList( list )を返す。

15.5.14 TextDirectionOfLocale ( loc )

The implementation-defined abstract operation TextDirectionOfLocale takes argument loc (Intl.Locale) and returns Stringまたはundefined. 次のアルゴリズムは、Unicode Technical Standard #35 Part 1 Core, Script Metadataで規定されるLocaleデータを参照する。 It performs the following steps when called:

  1. localeloc.[[Locale]]とする。
  2. scriptGetLocaleScript(locale)とする。
  3. scriptundefinedならば、
    1. maximalを、localeに適用されたAdd Likely Subtagsアルゴリズムの結果とする。エラーが通知されたならば、undefinedを返す。
    2. scriptGetLocaleScript(maximal)に設定する。
    3. scriptundefinedならば、undefinedを返す。
  4. script内の行内における文字の既定の一般順序が右から左ならば、"rtl"を返す。
  5. script内の行内における文字の既定の一般順序が左から右ならば、"ltr"を返す。
  6. undefinedを返す。
Note 1
script内の行内における文字の既定の一般順序の方向が決定できない場合、または方向が右から左でも左から右でもない場合、undefinedが返される。
Note 2
ある言語のテキストは複数の可能な方向を持つことがある。ある用字で書かれた言語のテキストも、複数の可能な方向を持つことがある。したがって、テキスト片に関連付けられたメタデータに方向情報が含まれている場合、その方向情報を主要な真実の情報源として考慮すべきである。TextDirectionOfLocaleによって返される情報は、テキストの方向情報を提供するメタデータがテキストに関連付けられていない間のフォールバック機構としてのみ使用されるべきである。方向情報が存在しないが言語情報が既知である間にのみ使用されるべきである。Web開発者は、テキストの方向を決定するためにこのAPIへ過度に依存すべきではない。

15.5.15 WeekdayToUValue ( fw )

The abstract operation WeekdayToUValue takes argument fw (String) and returns String. 曜日を数値的に表す文字列を、Unicode Technical Standard #35 Part 1 Core Section 3.6.1 Key and Type Definitionsで定義される有効なUnicode First Day Identifierに変換し、その他の文字列を変更せずに返す。 It performs the following steps when called:

  1. Table 26の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. weekdayを現在の行のWeekday値とする。
    2. stringを現在の行のString値とする。
    3. fwweekdayと等しいならば、stringを返す。
  2. fwを返す。
Table 26: WeekdayのStringとValue
Weekday String Value
"0" "sun" 7𝔽
"1" "mon" 1𝔽
"2" "tue" 2𝔽
"3" "wed" 3𝔽
"4" "thu" 4𝔽
"5" "fri" 5𝔽
"6" "sat" 6𝔽
"7" "sun" 7𝔽

15.5.16 WeekdayUValueToNumber ( fw )

The abstract operation WeekdayUValueToNumber takes argument fw (String) and returns 整数Numberまたはundefined. Unicode Technical Standard #35 Part 1 Core Section 3.6.1 Key and Type Definitionsで定義されるUnicode First Day Identifierを数値ISO 8601のカレンダー曜日に変換し、その他の任意の文字列についてはundefinedを返す。 It performs the following steps when called:

  1. Table 26の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. stringを現在の行のString値とする。
    2. valueを現在の行のValue値とする。
    3. fwstringと等しいならば、valueを返す。
  2. undefinedを返す。

15.5.17 WeekInfoOfLocale ( loc )

The implementation-defined abstract operation WeekInfoOfLocale takes argument loc (Intl.Locale) and returns Record. 次のアルゴリズムは、Unicode Technical Standard #35 Part 4 Dates, Week Elementsで規定されるLocaleデータを参照する。 It performs the following steps when called:

  1. localeloc.[[Locale]]とする。
  2. weekInfoを、フィールドがTable 27で定義され、値がlocaleに基づくRecordとする。
  3. firstDayStringloc.[[FirstDayOfWeek]]とする。
  4. firstDayStringundefinedでないならば、
    1. firstDayWeekdayUValueToNumber(firstDayString)とする。
    2. firstDayundefinedでないならば、weekInfo.[[FirstDay]]firstDayに設定する。
  5. weekInfoを返す。
Note
Recordの戻り値は、Unicode Technical Standard #35 Part 4 Dates, Week DataおよびFirst Day Overridesで概説される仕様に従い、localeによって決定される。
Table 27: WeekInfo Recordフィールド
フィールド名 意味
[[FirstDay]] カレンダー日のISO 8601のカレンダー曜日。これは、月曜日を1𝔽として始まり日曜日を7𝔽として終わる週カレンダー日の列における、1始まりの序数位置である。 カレンダー上の目的で、週のどの日が「最初」と見なされるか。
[[Weekend]] ISO 8601のカレンダー曜日整数Number値1𝔽(月曜日)から7𝔽(日曜日)までの1つ以上からなるListで、数値の昇順で並ぶ。 カレンダー上の目的で、「週末」の一部と見なされる曜日を示す曜日値のList。週末の日数はロケールごとに異なる場合があり、連続していない場合があることに注意。

16 NumberFormatオブジェクト

16.1 Intl.NumberFormatコンストラクタ

Intl.NumberFormatコンストラクタは、次のとおりである:

  • %Intl.NumberFormat%である。
  • Intlオブジェクト"NumberFormat"プロパティの初期値である。

Intlオブジェクトのすべてのサービスコンストラクタプロパティに共通する挙動は、9.1で規定される。

16.1.1 Intl.NumberFormat ( [ locales [ , options ] ] )

Intl.NumberFormat関数が省略可能な引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. NewTargetがundefinedならばnewTargetを実行中の関数オブジェクトとし、そうでなければnewTargetをNewTargetとする。
  2. numberFormatを? OrdinaryCreateFromConstructor(newTarget, "%Intl.NumberFormat.prototype%", « [[InitializedNumberFormat]], [[Locale]], [[LocaleData]], [[NumberingSystem]], [[Style]], [[Unit]], [[UnitDisplay]], [[Currency]], [[CurrencyDisplay]], [[CurrencySign]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[RoundingType]], [[Notation]], [[CompactDisplay]], [[UseGrouping]], [[SignDisplay]], [[RoundingIncrement]], [[RoundingMode]], [[ComputedRoundingPriority]], [[TrailingZeroDisplay]], [[BoundFormat]] »)とする。
  3. optionsResolutionを? ResolveOptions(%Intl.NumberFormat%, %Intl.NumberFormat%.[[LocaleData]], locales, options, « coerce-options »)とする。
  4. optionsoptionsResolution.[[Options]]に設定する。
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]]とする。
  6. numberFormat.[[Locale]]resolvedLocale.[[Locale]]に設定する。
  7. numberFormat.[[LocaleData]]resolvedLocale.[[LocaleData]]に設定する。
  8. numberFormat.[[NumberingSystem]]resolvedLocale.[[nu]]に設定する。
  9. SetNumberFormatUnitOptions(numberFormat, options)を実行する。
  10. stylenumberFormat.[[Style]]とする。
  11. notationを? GetOption(options, "notation", string, « "standard", "scientific", "engineering", "compact" », "standard")とする。
  12. numberFormat.[[Notation]]notationに設定する。
  13. style"currency"であり、かつnotation"standard"ならば、
    1. currencynumberFormat.[[Currency]]とする。
    2. cDigitsCurrencyDigits(currency)とする。
    3. mnfdDefaultcDigitsとする。
    4. mxfdDefaultcDigitsとする。
  14. そうでなければ、
    1. mnfdDefaultを0とする。
    2. style"percent"ならば、
      1. mxfdDefaultを0とする。
    3. そうでなければ、
      1. mxfdDefaultを3とする。
  15. SetNumberFormatDigitOptions(numberFormat, options, mnfdDefault, mxfdDefault, notation)を実行する。
  16. compactDisplayを? GetOption(options, "compactDisplay", string, « "short", "long" », "short")とする。
  17. defaultUseGrouping"auto"とする。
  18. notation"compact"ならば、
    1. numberFormat.[[CompactDisplay]]compactDisplayに設定する。
    2. defaultUseGrouping"min2"に設定する。
  19. NOTE: 歴史的理由により、文字列"true"および"false"は受け入れられ、デフォルト値に置き換えられる。
  20. useGroupingを? GetBooleanOrStringNumberFormatOption(options, "useGrouping", « "min2", "auto", "always", "true", "false" », defaultUseGrouping)とする。
  21. useGrouping"true"またはuseGrouping"false"ならば、useGroupingdefaultUseGroupingに設定する。
  22. useGroupingtrueならば、useGrouping"always"に設定する。
  23. numberFormat.[[UseGrouping]]useGroupingに設定する。
  24. signDisplayを? GetOption(options, "signDisplay", string, « "auto", "never", "always", "exceptZero", "negative" », "auto")とする。
  25. numberFormat.[[SignDisplay]]signDisplayに設定する。
  26. 実装が4.3 Note 1の規範的任意コンストラクタモードをサポートするならば、
    1. thisthis値とする。
    2. ChainNumberFormat(numberFormat, NewTarget, this)を返す。
  27. numberFormatを返す。

16.1.1.1 ChainNumberFormat ( numberFormat, newTarget, this )

The abstract operation ChainNumberFormat takes arguments numberFormat (Intl.NumberFormat), newTarget (ECMAScript言語値), and this (ECMAScript言語値) and returns Objectを含む通常完了またはthrow完了. It performs the following steps when called:

  1. newTargetundefinedであり、かつ? OrdinaryHasInstance(%Intl.NumberFormat%, this)がtrueならば、
    1. DefinePropertyOrThrow(this, %Intl%.[[FallbackSymbol]], PropertyDescriptor { [[Value]]: numberFormat, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false })を実行する。
    2. thisを返す。
  2. numberFormatを返す。

16.1.2 SetNumberFormatDigitOptions ( intlObj, options, mnfdDefault, mxfdDefault, notation )

The abstract operation SetNumberFormatDigitOptions takes arguments intlObj (Object), options (Object), mnfdDefault (整数), mxfdDefault (整数), and notation (String) and returns unusedを含む通常完了またはthrow完了. ロケール非依存の数値丸めに影響するintlObjの内部スロットを設定する(16.5.3参照)。 It performs the following steps when called:

  1. mnidを? GetNumberOption(options, "minimumIntegerDigits", 1, 21, 1)とする。
  2. mnfdを? Get(options, "minimumFractionDigits")とする。
  3. mxfdを? Get(options, "maximumFractionDigits")とする。
  4. mnsdを? Get(options, "minimumSignificantDigits")とする。
  5. mxsdを? Get(options, "maximumSignificantDigits")とする。
  6. intlObj.[[MinimumIntegerDigits]]mnidに設定する。
  7. roundingIncrementを? GetNumberOption(options, "roundingIncrement", 1, 5000, 1)とする。
  8. roundingIncrementが« 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000 »内にないならば、RangeError例外を投げる。
  9. roundingModeを? GetOption(options, "roundingMode", string, « "ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven" », "halfExpand")とする。
  10. roundingPriorityを? GetOption(options, "roundingPriority", string, « "auto", "morePrecision", "lessPrecision" », "auto")とする。
  11. trailingZeroDisplayを? GetOption(options, "trailingZeroDisplay", string, « "auto", "stripIfInteger" », "auto")とする。
  12. NOTE: SetNumberFormatDigitOptionsに必要なすべてのフィールドは、すでにoptionsから読み取られている。このAOの残りはオプションを解釈し、例外を投げる可能性がある。
  13. roundingIncrementが1でないならば、mxfdDefaultmnfdDefaultに設定する。
  14. intlObj.[[RoundingIncrement]]roundingIncrementに設定する。
  15. intlObj.[[RoundingMode]]roundingModeに設定する。
  16. intlObj.[[TrailingZeroDisplay]]trailingZeroDisplayに設定する。
  17. mnsdundefinedであり、かつmxsdundefinedならばhasSdfalseとする。そうでなければ、hasSdtrueとする。
  18. mnfdundefinedであり、かつmxfdundefinedならばhasFdfalseとする。そうでなければ、hasFdtrueとする。
  19. needSdtrueとする。
  20. needFdtrueとする。
  21. roundingPriority"auto"ならば、
    1. needSdhasSdに設定する。
    2. needSdtrueである、またはhasFdfalseかつnotation"compact"であるならば、
      1. needFdfalseに設定する。
  22. needSdtrueならば、
    1. hasSdtrueならば、
      1. intlObj.[[MinimumSignificantDigits]]を? DefaultNumberOption(mnsd, 1, 21, 1)に設定する。
      2. intlObj.[[MaximumSignificantDigits]]を? DefaultNumberOption(mxsd, intlObj.[[MinimumSignificantDigits]], 21, 21)に設定する。
    2. そうでなければ、
      1. intlObj.[[MinimumSignificantDigits]]を1に設定する。
      2. intlObj.[[MaximumSignificantDigits]]を21に設定する。
  23. needFdtrueならば、
    1. hasFdtrueならば、
      1. mnfdを? DefaultNumberOption(mnfd, 0, 100, undefined)に設定する。
      2. mxfdを? DefaultNumberOption(mxfd, 0, 100, undefined)に設定する。
      3. mnfdundefinedならば、mnfdmin(mnfdDefault, mxfd)に設定する。
      4. そうでなく、mxfdundefinedならば、mxfdmax(mxfdDefault, mnfd)に設定する。
      5. そうでなく、mnfdmxfdより大きいならば、RangeError例外を投げる。
      6. intlObj.[[MinimumFractionDigits]]mnfdに設定する。
      7. intlObj.[[MaximumFractionDigits]]mxfdに設定する。
    2. そうでなければ、
      1. intlObj.[[MinimumFractionDigits]]mnfdDefaultに設定する。
      2. intlObj.[[MaximumFractionDigits]]mxfdDefaultに設定する。
  24. needSdfalseであり、かつneedFdfalseならば、
    1. intlObj.[[MinimumFractionDigits]]を0に設定する。
    2. intlObj.[[MaximumFractionDigits]]を0に設定する。
    3. intlObj.[[MinimumSignificantDigits]]を1に設定する。
    4. intlObj.[[MaximumSignificantDigits]]を2に設定する。
    5. intlObj.[[RoundingType]]more-precisionに設定する。
    6. intlObj.[[ComputedRoundingPriority]]"morePrecision"に設定する。
  25. そうでなく、roundingPriority"morePrecision"ならば、
    1. intlObj.[[RoundingType]]more-precisionに設定する。
    2. intlObj.[[ComputedRoundingPriority]]"morePrecision"に設定する。
  26. そうでなく、roundingPriority"lessPrecision"ならば、
    1. intlObj.[[RoundingType]]less-precisionに設定する。
    2. intlObj.[[ComputedRoundingPriority]]"lessPrecision"に設定する。
  27. そうでなく、hasSdtrueならば、
    1. intlObj.[[RoundingType]]significant-digitsに設定する。
    2. intlObj.[[ComputedRoundingPriority]]"auto"に設定する。
  28. そうでなければ、
    1. intlObj.[[RoundingType]]fraction-digitsに設定する。
    2. intlObj.[[ComputedRoundingPriority]]"auto"に設定する。
  29. roundingIncrementが1でないならば、
    1. intlObj.[[RoundingType]]fraction-digitsでないならば、TypeError例外を投げる。
    2. intlObj.[[MaximumFractionDigits]]intlObj.[[MinimumFractionDigits]]でないならば、RangeError例外を投げる。
  30. unusedを返す。

16.1.3 SetNumberFormatUnitOptions ( intlObj, options )

The abstract operation SetNumberFormatUnitOptions takes arguments intlObj (Intl.NumberFormat) and options (Object) and returns unusedを含む通常完了またはthrow完了. 単位に関するユーザー指定オプションをintlObjへ解決する。 It performs the following steps when called:

  1. styleを? GetOption(options, "style", string, « "decimal", "percent", "currency", "unit" », "decimal")とする。
  2. intlObj.[[Style]]styleに設定する。
  3. currencyを? GetOption(options, "currency", string, empty, undefined)とする。
  4. currencyundefinedならば、
    1. style"currency"ならば、TypeError例外を投げる。
  5. そうでなければ、
    1. IsWellFormedCurrencyCode(currency)がfalseならば、RangeError例外を投げる。
  6. currencyDisplayを? GetOption(options, "currencyDisplay", string, « "code", "symbol", "narrowSymbol", "name" », "symbol")とする。
  7. currencySignを? GetOption(options, "currencySign", string, « "standard", "accounting" », "standard")とする。
  8. unitを? GetOption(options, "unit", string, empty, undefined)とする。
  9. unitundefinedならば、
    1. style"unit"ならば、TypeError例外を投げる。
  10. そうでなければ、
    1. IsWellFormedUnitIdentifier(unit)がfalseならば、RangeError例外を投げる。
  11. unitDisplayを? GetOption(options, "unitDisplay", string, « "short", "narrow", "long" », "short")とする。
  12. style"currency"ならば、
    1. intlObj.[[Currency]]currencyASCII-uppercaseに設定する。
    2. intlObj.[[CurrencyDisplay]]currencyDisplayに設定する。
    3. intlObj.[[CurrencySign]]currencySignに設定する。
  13. style"unit"ならば、
    1. intlObj.[[Unit]]unitに設定する。
    2. intlObj.[[UnitDisplay]]unitDisplayに設定する。
  14. unusedを返す。

16.2 Intl.NumberFormatコンストラクタのプロパティ

Intl.NumberFormatコンストラクタは、次のとおりである:

  • 値が%Function.prototype%である[[Prototype]]内部スロットを持つ。
  • 次のプロパティを持つ:

16.2.1 Intl.NumberFormat.prototype

Intl.NumberFormat.prototypeの値は%Intl.NumberFormat.prototype%である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }を持つ。

16.2.2 Intl.NumberFormat.supportedLocalesOf ( locales [ , options ] )

supportedLocalesOfメソッドが引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. availableLocales%Intl.NumberFormat%.[[AvailableLocales]]とする。
  2. requestedLocalesを? CanonicalizeLocaleList(locales)とする。
  3. FilterLocales(availableLocales, requestedLocales, options)を返す。

16.2.3 内部スロット

[[AvailableLocales]]内部スロットの値は、9.1で述べられた制約の範囲内で実装定義である。

[[RelevantExtensionKeys]]内部スロットの値は« "nu" »である。

[[ResolutionOptionDescriptors]]内部スロットの値は« { [[Key]]: "nu", [[Property]]: "numberingSystem" } »である。

Note 1
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitionsは、数値整形に関連する3つのロケール拡張キーを記述している。通貨を表す"cu"、通貨形式スタイルを表す"cf"、および番号体系を表す"nu"である。しかし、Intl.NumberFormatは、通貨形式の通貨がオプションオブジェクト内のcurrencyプロパティを通じて指定され、通貨形式の通貨形式スタイルがオプションオブジェクト内のcurrencySignプロパティを通じて指定されることを要求する。

[[LocaleData]]内部スロットの値は、9.1で述べられた制約および次の追加制約の範囲内で実装定義である:

  • [[LocaleData]]の任意のロケールフィールドの"nu"フィールドの値であるListは、値"native""traditio"、または"finance"を含んではならない。
  • [[LocaleData]].[[<locale>]]は、すべてのロケール値localeについて[[patterns]]フィールドを持たなければならない。このフィールドの値はRecordでなければならず、4つの数値形式スタイル、すなわち"decimal""percent""currency"、および"unit"の名前を持つフィールドを持たなければならない。
  • 上記の2つのフィールド"currency"および"unit"は、少なくとも1つのフィールド"fallback"を持つRecordでなければならない。 "currency"は、6.3に従って通貨コードに対応するキーを持つ追加フィールドを持ってよい。 "currency"の各フィールドは、可能なcurrencyDisplay値、すなわち"code""symbol""narrowSymbol"、および"name"に対応するフィールドを持つRecordでなければならない。 それらの各フィールドは、可能なcurrencySign値、すなわち"standard"または"accounting"に対応するフィールドを持つRecordを含まなければならない。"unit"フィールド([[LocaleData]].[[<locale>]]の)は、必須フィールド"fallback"を超えて、6.6に対応するcore measurement unit identifierに対応するキーを持つ追加フィールドを持ってよい。 "unit"の各フィールドは、可能なunitDisplay値、すなわち"narrow""short"、および"long"に対応するフィールドを持つRecordでなければならない。
  • ここまでに述べたpatternsツリーの葉フィールド("decimal""percent""currency"のひ孫、および"unit"の孫)はすべて、キー"positivePattern""zeroPattern"、および"negativePattern"を持つRecordでなければならない。
  • 前述のフィールド(符号依存パターンフィールド)の値は文字列値でなければならず、部分文字列"{number}"を含まなければならない。 "positivePattern"は部分文字列"{plusSign}"を含み、かつ"{minusSign}"を含んではならない。"negativePattern"は部分文字列"{minusSign}"を含み、かつ"{plusSign}"を含んではならない。そして"zeroPattern""{plusSign}"または"{minusSign}"のいずれも含んではならない。 さらに、"percent"フィールド内の値は部分文字列"{percentSign}"も含まなければならない。"currency"フィールド内の値は次の部分文字列の1つ以上も含まなければならない:"{currencyCode}""{currencyPrefix}"、または"{currencySuffix}"。そして"unit"フィールド内の値は次の部分文字列の1つ以上も含まなければならない:"{unitPrefix}"または"{unitSuffix}"。 パターン文字列は、ECMA-2626.1.4で述べられるとおりUTF-16符号化コードポイント列として解釈されるとき、Unicode Standardで規定されるGeneral Category "Number, decimal digit"内のコードポイントを含んではならない。
  • [[LocaleData]].[[<locale>]]は、すべてのロケール値localeについて[[notationSubPatterns]]フィールドも持たなければならない。このフィールドの値はRecordでなければならず、2つのフィールド[[scientific]]および[[compact]]を持たなければならない。[[scientific]]フィールドは、部分文字列"{number}""{scientificSeparator}"、および"{scientificExponent}"を含む文字列値でなければならない。[[compact]]フィールドは、2つのフィールド"short"および"long"を持つRecordでなければならない。これらの各フィールドは、実装がcompact notationでサポートするすべての離散的な桁規模に対応する整数キーを持つRecordでなければならない。これらの各フィールドは、部分文字列"{number}"を含んでよい文字列値でなければならない。"short"から派生する文字列は部分文字列"{compactSymbol}"を含まなければならず、"long"から派生する文字列は部分文字列"{compactName}"を含まなければならない。
Note 2
実装は、Common Locale Data Repository(https://cldr.unicode.org/で入手可能)が提供するロケールデータを使用することが推奨される。

16.3 Intl.NumberFormatプロトタイプオブジェクトのプロパティ

Intl.NumberFormatプロトタイプオブジェクトは、次のとおりである:

  • %Intl.NumberFormat.prototype%である。
  • 通常のオブジェクトである。
  • Intl.NumberFormatインスタンスではなく、[[InitializedNumberFormat]]内部スロットまたはIntl.NumberFormatインスタンスオブジェクトのその他の内部スロットを持たない。
  • 値が%Object.prototype%である[[Prototype]]内部スロットを持つ。

16.3.1 Intl.NumberFormat.prototype.constructor

Intl.NumberFormat.prototype.constructorの初期値は%Intl.NumberFormat%である。

16.3.2 Intl.NumberFormat.prototype.resolvedOptions ( )

この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。

  1. nfthis値とする。
  2. 実装が4.3 Note 1の規範的任意コンストラクタモードをサポートするならば、
    1. nfを? UnwrapNumberFormat(nf)に設定する。
  3. RequireInternalSlot(nf, [[InitializedNumberFormat]])を実行する。
  4. optionsOrdinaryObjectCreate(%Object.prototype%)とする。
  5. Table 28の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. propertyKeyを現在の行のProperty値とする。
    2. valueを、その名前が現在の行のInternal Slot値であるnfの内部スロットの値とする。
    3. valueundefinedでないならば、
      1. 現在の行にConversion値があるならば、
        1. Assert: 現在の行のConversion値はnumberである。
        2. value𝔽(value)に設定する。
      2. CreateDataPropertyOrThrow(options, propertyKey, value)を実行する。
  6. optionsを返す。
Table 28: NumberFormatインスタンスのResolved Options
内部スロット プロパティ 変換
[[Locale]] "locale"
[[NumberingSystem]] "numberingSystem"
[[Style]] "style"
[[Currency]] "currency"
[[CurrencyDisplay]] "currencyDisplay"
[[CurrencySign]] "currencySign"
[[Unit]] "unit"
[[UnitDisplay]] "unitDisplay"
[[MinimumIntegerDigits]] "minimumIntegerDigits" number
[[MinimumFractionDigits]] "minimumFractionDigits" number
[[MaximumFractionDigits]] "maximumFractionDigits" number
[[MinimumSignificantDigits]] "minimumSignificantDigits" number
[[MaximumSignificantDigits]] "maximumSignificantDigits" number
[[UseGrouping]] "useGrouping"
[[Notation]] "notation"
[[CompactDisplay]] "compactDisplay"
[[SignDisplay]] "signDisplay"
[[RoundingIncrement]] "roundingIncrement" number
[[RoundingMode]] "roundingMode"
[[ComputedRoundingPriority]] "roundingPriority"
[[TrailingZeroDisplay]] "trailingZeroDisplay"

16.3.3 get Intl.NumberFormat.prototype.format

Intl.NumberFormat.prototype.formatは、setアクセサ関数がundefinedであるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:

  1. nfthis値とする。
  2. 実装が4.3 Note 1の規範的任意コンストラクタモードをサポートするならば、
    1. nfを? UnwrapNumberFormat(nf)に設定する。
  3. RequireInternalSlot(nf, [[InitializedNumberFormat]])を実行する。
  4. nf.[[BoundFormat]]undefinedならば、
    1. Number Format Functions(16.5.2)で定義される新しい組込み関数オブジェクトfuncを作成する。
    2. func.[[NumberFormat]]nfに設定する。
    3. nf.[[BoundFormat]]funcに設定する。
  5. nf.[[BoundFormat]]を返す。
Note
返される関数はnfに束縛されるため、Array.prototype.mapまたはその他の関数へ直接渡すことができる。 これは歴史的な遺物と見なされる。新機能ではもはや従われていない慣例の一部であるが、既存プログラムとの互換性を維持するために保持されている。

16.3.4 Intl.NumberFormat.prototype.formatRange ( start, end )

formatRangeメソッドが引数startおよびendとともに呼び出されるとき、次の手順が実行される:

  1. nfthis値とする。
  2. RequireInternalSlot(nf, [[InitializedNumberFormat]])を実行する。
  3. startundefinedまたはendundefinedならば、TypeError例外を投げる。
  4. xを? ToIntlMathematicalValue(start)とする。
  5. yを? ToIntlMathematicalValue(end)とする。
  6. FormatNumericRange(nf, x, y)を返す。

16.3.5 Intl.NumberFormat.prototype.formatRangeToParts ( start, end )

formatRangeToPartsメソッドが引数startおよびendとともに呼び出されるとき、次の手順が実行される:

  1. nfthis値とする。
  2. RequireInternalSlot(nf, [[InitializedNumberFormat]])を実行する。
  3. startundefinedまたはendundefinedならば、TypeError例外を投げる。
  4. xを? ToIntlMathematicalValue(start)とする。
  5. yを? ToIntlMathematicalValue(end)とする。
  6. FormatNumericRangeToParts(nf, x, y)を返す。

16.3.6 Intl.NumberFormat.prototype.formatToParts ( value )

formatToPartsメソッドが省略可能な引数valueとともに呼び出されるとき、次の手順が実行される:

  1. nfthis値とする。
  2. RequireInternalSlot(nf, [[InitializedNumberFormat]])を実行する。
  3. xを? ToIntlMathematicalValue(value)とする。
  4. FormatNumericToParts(nf, x)を返す。

16.3.7 Intl.NumberFormat.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag%プロパティの初期値はString値"Intl.NumberFormat"である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }を持つ。

16.4 Intl.NumberFormatインスタンスのプロパティ

Intl.NumberFormatインスタンスは、%Intl.NumberFormat.prototype%からプロパティを継承する通常のオブジェクトである。

Intl.NumberFormatインスタンスは[[InitializedNumberFormat]]内部スロットを持つ。

Intl.NumberFormatインスタンスは、Intl.NumberFormatコンストラクタによって計算されるいくつかの内部スロットも持つ:

  • [[Locale]]は、整形に使用されるローカライズのロケールの言語タグを持つString値である。
  • [[LocaleData]]は、整形のために実装が利用できるデータを表すRecordである。これは、[[Locale]]の値またはその接頭部のいずれかに関連付けられた%Intl.NumberFormat%.[[LocaleData]]内のエントリの値である。
  • [[NumberingSystem]]は、整形に使用されるUnicode Number System Identifierを表すString値である。
  • [[Style]]は、測定される量の型を識別する、String値"decimal""currency""percent"、または"unit"のいずれかである。
  • [[Currency]]は、"currency"単位型で整形する場合に使用される通貨を識別する通貨コードを持つString値である。これは[[Style]]"currency"の値を持つ場合にのみ使用される。
  • [[CurrencyDisplay]]は、"currency"スタイルで整形する場合に、通貨をISO 4217英字通貨コード、ローカライズされた通貨記号、またはローカライズされた通貨名として表示するかどうかを指定する、String値"code""symbol""narrowSymbol"、または"name"のいずれかである。これは[[Style]]"currency"の値を持つ場合にのみ使用される。
  • [[CurrencySign]]は、負数を会計形式で描画するかどうかを指定する、String値"standard"または"accounting"のいずれかであり、多くの場合括弧で示される。これは[[Style]]"currency"の値を持ち、かつ[[SignDisplay]]"never"でない場合にのみ使用される。
  • [[Unit]]core unit identifierである。これは[[Style]]"unit"の値を持つ場合にのみ使用される。
  • [[UnitDisplay]]は、"unit"スタイルで整形する場合に、単位を記号、狭い記号、またはローカライズされた長い名前として表示するかどうかを指定する、String値"short""narrow"、または"long"のいずれかである。これは[[Style]]"unit"の値を持つ場合にのみ使用される。
  • [[MinimumIntegerDigits]]は、使用される最小整数桁数を示す非負整数である。必要に応じて、数値は先頭ゼロで埋められる。
  • [[MinimumFractionDigits]]および[[MaximumFractionDigits]]は、使用される最小および最大の小数部桁数を示す非負整数である。必要に応じて、数値は丸められるか末尾ゼロで埋められる。これらのプロパティは、[[RoundingType]]fraction-digitsmore-precision、またはless-precisionである場合にのみ使用される。
  • [[MinimumSignificantDigits]]および[[MaximumSignificantDigits]]は、表示される最小および最大の有効桁数を示す正整数である。存在する場合、フォーマッタは指定された有効桁数を表示するために必要な数の小数部桁数を使用する。これらのプロパティは、[[RoundingType]]significant-digitsmore-precision、またはless-precisionである場合にのみ使用される。
  • [[UseGrouping]]は、桁区切り記号が使用される条件を示すBooleanまたはString値である。桁区切り記号の位置、および整形された数値に桁区切り記号を表示するかどうかは実装定義である。値"always"は、可能であれば桁区切り記号を表示するよう実装に示唆する。"min2"は、グループ内に少なくとも2桁がある場合、"auto"は、ロケールが整形された数値に桁区切り記号を使用することを好む場合である。値falseは桁区切り記号を無効にする。
  • [[RoundingType]]は、使用する丸め戦略を示す値fraction-digitssignificant-digitsmore-precision、またはless-precisionのいずれかである。fraction-digitsの場合、整形された数値は上記のとおり[[MinimumFractionDigits]]および[[MaximumFractionDigits]]に従って丸められる。significant-digitsの場合、整形された数値は上記のとおり[[MinimumSignificantDigits]]および[[MaximumSignificantDigits]]に従って丸められる。more-precisionまたはless-precisionの場合、これら4つの設定すべてが使用され、一方の集合と他方の集合のどちらを使用するかを曖昧性解消するための特定の規則がある。[[RoundingType]]"roundingPriority"オプションから導出される。
  • [[ComputedRoundingPriority]]は、String値"auto""morePrecision"、または"lessPrecision"のいずれかである。これは16.3.2で、[[RoundingType]]を有効な"roundingPriority"オプションへ戻すためにのみ使用される。
  • [[Notation]]は、整形された数値を、スケーリングなしで表示するか、科学表記で10の累乗を伴って一の位へスケーリングするか、工学表記で10の累乗を伴って最も近い千へスケーリングするか、または対応するコンパクト10進表記接辞を伴って最も近いILD compact decimal notationの10の累乗へスケーリングするかを指定する、String値"standard""scientific""engineering"、または"compact"のいずれかである。
  • [[CompactDisplay]]は、コンパクト表記接辞を短い形式("5K")または長い形式("5 thousand")で表示するかを指定する、"short""long"、またはundefinedのいずれかである。これは、[[Notation]]"compact"以外の値を持つ場合に限りundefinedである。
  • [[SignDisplay]]は、符号をいつ含めるかを指定する、String値"auto""always""never""exceptZero"、または"negative"のいずれかである("auto"以外のオプションは、それぞれ常に含める、決して含めない、非ゼロ数値のみ、または非ゼロ負数のみ、に対応する)。 科学表記では、このスロットは仮数部の符号表示に影響するが、指数には影響しない。
  • [[RoundingIncrement]]は、10、100、1000、または10000を十分の一、五分の一、四分の一、または二分の一に均等に割り切る整数である。これは、計算された丸め桁に対して丸めが行われる増分を示す。例えば、[[MaximumFractionDigits]]が2であり、[[RoundingIncrement]]が5である場合、整形された数値は最も近い0.05に丸められる("nickel rounding")。
  • [[RoundingMode]]rounding modeであり、Table 29のIdentifier列にあるString値のいずれかである。
  • [[TrailingZeroDisplay]]は、整形された数値が整数である場合(すなわち、非ゼロ小数部桁を持たない場合)に末尾ゼロを削除するかどうかを示す、String値"auto"または"stripIfInteger"のいずれかである。
Table 29: Intl.NumberFormatにおける丸めモード
識別子 説明 例:小数部0桁に丸める
-1.5 0.4 0.5 0.6 1.5
"ceil" 正の無限大に向かう ⬆️ [-1] ⬆️ [1] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"floor" 負の無限大に向かう ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬇️ [0] ⬇️ [1]
"expand" ゼロから離れる ⬇️ [-2] ⬆️ [1] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"trunc" ゼロに向かう ⬆️ [-1] ⬇️ [0] ⬇️ [0] ⬇️ [0] ⬇️ [1]
"halfCeil" 同値の場合は正の無限大に向かう ⬆️ [-1] ⬇️ [0] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"halfFloor" 同値の場合は負の無限大に向かう ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬇️ [1]
"halfExpand" 同値の場合はゼロから離れる ⬇️ [-2] ⬇️ [0] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"halfTrunc" 同値の場合はゼロに向かう ⬆️ [-1] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬇️ [1]
"halfEven" 同値の場合は偶数の丸め増分倍数に向かう ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬆️ [2]
Note
例は各オプションの一意な挙動を説明するものである。⬆️は「正の無限大に向かって解決される」ことを意味し、⬇️は「負の無限大に向かって解決される」ことを意味する。

最後に、Intl.NumberFormatインスタンスは、formatアクセサ(16.3.3)によって返される関数をキャッシュする[[BoundFormat]]内部スロットを持つ。

16.5 NumberFormatオブジェクトのための抽象操作

16.5.1 CurrencyDigits ( currency )

The implementation-defined abstract operation CurrencyDigits takes argument currency (String) and returns 非負整数. It performs the following steps when called:

  1. Assert: IsWellFormedCurrencyCode(currency)はtrueである。
  2. currencyに対応する通貨の数量を整形するときに使用される小数部桁数を示す非負整数を返す。使用される桁数に関する利用可能な情報がない場合は、2を返す。

16.5.2 数値整形関数

数値整形関数は、[[NumberFormat]]内部スロットを持つ無名の組込み関数である。

数値整形関数funcが省略可能な引数valueとともに呼び出されるとき、次の手順が実行される:

  1. nffunc.[[NumberFormat]]とする。
  2. Assert: nfはObjectであり、nf[[InitializedNumberFormat]]内部スロットを持つ。
  3. valueが提供されていないならば、valueundefinedとする。
  4. xを? ToIntlMathematicalValue(value)とする。
  5. FormatNumeric(nf, x)を返す。

数値整形関数の"length"プロパティは1𝔽である。

16.5.3 FormatNumericToString ( intlObj, x )

The abstract operation FormatNumericToString takes arguments intlObj (Object) and x (数学的値またはnegative-zero) and returns フィールド[[RoundedNumber]](数学的値またはnegative-zero)および[[FormattedString]](String)を持つRecord. intlObjの内部スロットに従ってxIntl数学的値へ丸める。[[RoundedNumber]]フィールドは丸め結果値を含み、[[FormattedString]]フィールドはintlObjの内部スロットに従って整形されたその結果のString値表現を含む。 It performs the following steps when called:

  1. Assert: intlObj[[RoundingMode]][[RoundingType]][[MinimumSignificantDigits]][[MaximumSignificantDigits]][[MinimumIntegerDigits]][[MinimumFractionDigits]][[MaximumFractionDigits]][[RoundingIncrement]]、および[[TrailingZeroDisplay]]内部スロットを持つ。
  2. xnegative-zeroならば、
    1. signnegativeとする。
    2. xを0に設定する。
  3. そうでなければ、
    1. Assert: xは数学的値である。
    2. x < 0ならばsignnegativeとし、そうでなければsignpositiveとする。
    3. signnegativeならば、
      1. xを-xに設定する。
  4. unsignedRoundingModeGetUnsignedRoundingMode(intlObj.[[RoundingMode]], sign)とする。
  5. intlObj.[[RoundingType]]significant-digitsならば、
    1. resultToRawPrecision(x, intlObj.[[MinimumSignificantDigits]], intlObj.[[MaximumSignificantDigits]], unsignedRoundingMode)とする。
  6. そうでなく、intlObj.[[RoundingType]]fraction-digitsならば、
    1. resultToRawFixed(x, intlObj.[[MinimumFractionDigits]], intlObj.[[MaximumFractionDigits]], intlObj.[[RoundingIncrement]], unsignedRoundingMode)とする。
  7. そうでなければ、
    1. significantResultToRawPrecision(x, intlObj.[[MinimumSignificantDigits]], intlObj.[[MaximumSignificantDigits]], unsignedRoundingMode)とする。
    2. fractionResultToRawFixed(x, intlObj.[[MinimumFractionDigits]], intlObj.[[MaximumFractionDigits]], intlObj.[[RoundingIncrement]], unsignedRoundingMode)とする。
    3. fractionResult.[[RoundingMagnitude]] < significantResult.[[RoundingMagnitude]]ならばfixedIsMorePrecisetrueとし、そうでなければfixedIsMorePrecisefalseとする。
    4. intlObj.[[RoundingType]]more-precisionであり、かつfixedIsMorePrecisetrueならば、
      1. resultfractionResultとする。
    5. そうでなく、intlObj.[[RoundingType]]less-precisionであり、かつfixedIsMorePrecisefalseならば、
      1. resultfractionResultとする。
    6. そうでなければ、
      1. resultsignificantResultとする。
  8. xresult.[[RoundedNumber]]に設定する。
  9. stringresult.[[FormattedString]]とする。
  10. intlObj.[[TrailingZeroDisplay]]"stripIfInteger"であり、かつx modulo 1 = 0ならば、
    1. iStringIndexOf(string, ".", 0)とする。
    2. inot-foundでないならば、stringstringの0からiまでの部分文字列に設定する。
  11. intresult.[[IntegerDigitsCount]]とする。
  12. minIntDigitsintlObj.[[MinimumIntegerDigits]]とする。
  13. int < minIntDigitsならば、
    1. forwardZerosを、コード単位0x0030(DIGIT ZERO)がminIntDigits - int回出現するStringとする。
    2. stringforwardZerosstringの文字列連結に設定する。
  14. signnegativeならば、
    1. xが0ならば、xnegative-zeroに設定する。そうでなければ、xを-xに設定する。
  15. Record { [[RoundedNumber]]: x, [[FormattedString]]: string }を返す。

16.5.4 PartitionNumberPattern ( numberFormat, x )

The abstract operation PartitionNumberPattern takes arguments numberFormat (NumberFormatとして初期化されたオブジェクト) and x (Intl数学的値) and returns フィールド[[Type]](String)および[[Value]](String)を持つRecordList. numberFormatの有効なロケールおよび整形オプションに従って、xの数学的値を表す部分を作成する。 It performs the following steps when called:

  1. exponentを0とする。
  2. xnot-a-numberならば、
    1. formattedStringNaN値を示すILD String値とする。
  3. そうでなく、xpositive-infinityならば、
    1. formattedStringを正の無限大を示すILD String値とする。
  4. そうでなく、xnegative-infinityならば、
    1. formattedStringを負の無限大を示すILD String値とする。
  5. そうでなければ、
    1. xnegative-zeroでないならば、
      1. Assert: xは数学的値である。
      2. numberFormat.[[Style]]"percent"ならば、xを100 × xに設定する。
      3. exponentComputeExponent(numberFormat, x)に設定する。
      4. xx × 10-exponentに設定する。
    2. formatNumberResultFormatNumericToString(numberFormat, x)とする。
    3. formattedStringformatNumberResult.[[FormattedString]]とする。
    4. xformatNumberResult.[[RoundedNumber]]に設定する。
  6. patternGetNumberFormatPattern(numberFormat, x)とする。
  7. resultを新しい空のListとする。
  8. patternPartsPartitionPattern(pattern)とする。
  9. patternPartsの各Record { [[Type]], [[Value]] } patternPartについて、次を行う:
    1. partTypepatternPart.[[Type]]とする。
    2. partType"literal"ならば、
      1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }をresultに追加する。
    3. そうでなく、partType"number"ならば、
      1. notationSubPartsPartitionNotationSubPattern(numberFormat, x, formattedString, exponent)とする。
      2. resultresultnotationSubPartsのリスト連結に設定する。
    4. そうでなく、partType"plusSign"ならば、
      1. plusSignSymbolをプラス記号を表すILND Stringとする。
      2. Record { [[Type]]: "plusSign", [[Value]]: plusSignSymbol }をresultに追加する。
    5. そうでなく、partType"minusSign"ならば、
      1. minusSignSymbolをマイナス記号を表すILND Stringとする。
      2. Record { [[Type]]: "minusSign", [[Value]]: minusSignSymbol }をresultに追加する。
    6. そうでなく、partType"percentSign"であり、かつnumberFormat.[[Style]]"percent"ならば、
      1. percentSignSymbolをパーセント記号を表すILND Stringとする。
      2. Record { [[Type]]: "percentSign", [[Value]]: percentSignSymbol }をresultに追加する。
    7. そうでなく、partType"unitPrefix"であり、かつnumberFormat.[[Style]]"unit"ならば、
      1. unitnumberFormat.[[Unit]]とする。
      2. unitDisplaynumberFormat.[[UnitDisplay]]とする。
      3. unitStringを、unitDisplay形式でxの前にあるunitを表すILD String値とする。これは、異なる複数形を持つ言語ではxに依存することがある。
      4. Record { [[Type]]: "unit", [[Value]]: unitString }をresultに追加する。
    8. そうでなく、partType"unitSuffix"であり、かつnumberFormat.[[Style]]"unit"ならば、
      1. unitnumberFormat.[[Unit]]とする。
      2. unitDisplaynumberFormat.[[UnitDisplay]]とする。
      3. unitStringを、unitDisplay形式でxの後にあるunitを表すILD String値とする。これは、異なる複数形を持つ言語ではxに依存することがある。
      4. Record { [[Type]]: "unit", [[Value]]: unitString }をresultに追加する。
    9. そうでなく、partType"currencyCode"であり、かつnumberFormat.[[Style]]"currency"ならば、
      1. currencynumberFormat.[[Currency]]とする。
      2. Record { [[Type]]: "currency", [[Value]]: currency }をresultに追加する。
    10. そうでなく、partType"currencyPrefix"であり、かつnumberFormat.[[Style]]"currency"ならば、
      1. currencynumberFormat.[[Currency]]とする。
      2. currencyDisplaynumberFormat.[[CurrencyDisplay]]とする。
      3. currencyStringを、currencyDisplay形式でxの前にあるcurrencyを表すILD String値とする。これは、異なる複数形を持つ言語ではxに依存することがある。
      4. Record { [[Type]]: "currency", [[Value]]: currencyString }をresultに追加する。
    11. そうでなく、partType"currencySuffix"であり、かつnumberFormat.[[Style]]"currency"ならば、
      1. currencynumberFormat.[[Currency]]とする。
      2. currencyDisplaynumberFormat.[[CurrencyDisplay]]とする。
      3. currencyStringを、currencyDisplay形式でxの後にあるcurrencyを表すILD String値とする。これは、異なる複数形を持つ言語ではxに依存することがある。実装がcurrencyのそのような表現を持たない場合は、currency自体を使用する。
      4. Record { [[Type]]: "currency", [[Value]]: currencyString }をresultに追加する。
    12. そうでなければ、
      1. unknownxおよびpartTypeに基づくILND Stringとする。
      2. Record { [[Type]]: "unknown", [[Value]]: unknown }をresultに追加する。
  10. resultを返す。

16.5.5 PartitionNotationSubPattern ( numberFormat, x, formattedString, exponent )

The abstract operation PartitionNotationSubPattern takes arguments numberFormat (Intl.NumberFormat), x (Intl数学的値), formattedString (String), and exponent (整数) and returns フィールド[[Type]](String)および[[Value]](String)を持つRecordList. xは丸めが適用された後のIntl数学的値であり、formattedStringは中間の整形済み文字列である。 numberFormatの有効なロケールおよび整形オプションに従って、数値および表記に対応する部分を作成する。 It performs the following steps when called:

  1. resultを新しい空のListとする。
  2. xnot-a-numberならば、
    1. Record { [[Type]]: "nan", [[Value]]: formattedString }をresultに追加する。
  3. そうでなく、xpositive-infinityまたはnegative-infinityならば、
    1. Record { [[Type]]: "infinity", [[Value]]: formattedString }をresultに追加する。
  4. そうでなければ、
    1. notationSubPatternGetNotationSubPattern(numberFormat, exponent)とする。
    2. patternPartsPartitionPattern(notationSubPattern)とする。
    3. patternPartsの各Record { [[Type]], [[Value]] } patternPartについて、次を行う:
      1. partTypepatternPart.[[Type]]とする。
      2. partType"literal"ならば、
        1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }をresultに追加する。
      3. そうでなく、partType"number"ならば、
        1. numberFormat.[[NumberingSystem]]が下のTable 30のNumbering System列内の値の1つに一致するならば、
          1. digitsを、Table 30の一致する行のDigits列で指定されたコードポイントを要素とするListとする。
          2. Assert: digitsの長さは10である。
          3. transliteratedを空のStringとする。
          4. lengthformattedStringの長さとする。
          5. positionを0とする。
          6. position < lengthである間、繰り返す:
            1. cformattedString内のインデックスpositionにあるコード単位とする。
            2. 0x0030 ≤ c ≤ 0x0039ならば、
              1. NOTE: cはASCII数字である。
              2. ic - 0x0030とする。
              3. cCodePointsToStringdigits[i] »)に設定する。
            3. transliteratedtransliteratedcの文字列連結に設定する。
            4. positionposition + 1に設定する。
          7. formattedStringtransliteratedに設定する。
        2. そうでなければ、
          1. 実装依存アルゴリズムを使用して、formattedStringを所与の番号体系におけるformattedStringの適切な表現へ対応付ける。
        3. decimalSepIndexStringIndexOf(formattedString, ".", 0)とする。
        4. decimalSepIndexnot-foundでなく、かつdecimalSepIndex > 0ならば、
          1. intDigitsformattedStringの0からdecimalSepIndexまでの部分文字列とする。
          2. fractionDigitsformattedStringdecimalSepIndex + 1からの部分文字列とする。
        5. そうでなければ、
          1. intDigitsformattedStringとする。
          2. fractionDigitsundefinedとする。
        6. numberFormat.[[UseGrouping]]falseならば、
          1. Record { [[Type]]: "integer", [[Value]]: intDigits }をresultに追加する。
        7. そうでなければ、
          1. groupSepSymbolを桁区切り記号を表すILND Stringとする。
          2. groupsを、intDigits内のILNDの位置集合によって定義される部分文字列を左から右の順序で要素とするListとする。これはnumberFormat.[[UseGrouping]]の値に依存することがある。
          3. Assert: groups List内の要素数は0より大きい。
          4. groups Listが空でない間、繰り返す:
            1. groupsから最初の要素を削除し、intGroupをその要素の値とする。
            2. Record { [[Type]]: "integer", [[Value]]: intGroup }をresultに追加する。
            3. groups Listが空でないならば、
              1. Record { [[Type]]: "group", [[Value]]: groupSepSymbol }をresultに追加する。
        8. fractionDigitsundefinedでないならば、
          1. decimalSepSymbolを小数点記号を表すILND Stringとする。
          2. Record { [[Type]]: "decimal", [[Value]]: decimalSepSymbol }をresultに追加する。
          3. Record { [[Type]]: "fraction", [[Value]]: fractionDigits }をresultに追加する。
      4. そうでなく、partType"compactSymbol"ならば、
        1. compactSymbolを、exponentを短い形式で表すILD stringとする。これは、異なる複数形を持つ言語ではxに依存することがある。実装はこの文字列を提供できなければならず、そうでなければパターンに"{compactSymbol}"プレースホルダーが存在しないはずである。
        2. Record { [[Type]]: "compact", [[Value]]: compactSymbol }をresultに追加する。
      5. そうでなく、partType"compactName"ならば、
        1. compactNameを、exponentを長い形式で表すILD stringとする。これは、異なる複数形を持つ言語ではxに依存することがある。実装はこの文字列を提供できなければならず、そうでなければパターンに"{compactName}"プレースホルダーが存在しないはずである。
        2. Record { [[Type]]: "compact", [[Value]]: compactName }をresultに追加する。
      6. そうでなく、partType"scientificSeparator"ならば、
        1. scientificSeparatorを指数区切りを表すILND Stringとする。
        2. Record { [[Type]]: "exponentSeparator", [[Value]]: scientificSeparator }をresultに追加する。
      7. そうでなく、partType"scientificExponent"ならば、
        1. exponent < 0ならば、
          1. minusSignSymbolをマイナス記号を表すILND Stringとする。
          2. Record { [[Type]]: "exponentMinusSign", [[Value]]: minusSignSymbol }をresultに追加する。
          3. exponentを-exponentとする。
        2. exponentResultToRawFixed(exponent, 0, 0, 1, undefined)とする。
        3. Record { [[Type]]: "exponentInteger", [[Value]]: exponentResult.[[FormattedString]] }をresultに追加する。
      8. そうでなければ、
        1. unknownxおよびpartTypeに基づくILND Stringとする。
        2. Record { [[Type]]: "unknown", [[Value]]: unknown }をresultに追加する。
  5. resultを返す。
Table 30: 単純な数字マッピングを持つ番号体系
番号体系 数字
adlm U+1E950 to U+1E959
ahom U+11730 to U+11739
arab U+0660 to U+0669
arabext U+06F0 to U+06F9
bali U+1B50 to U+1B59
beng U+09E6 to U+09EF
bhks U+11C50 to U+11C59
brah U+11066 to U+1106F
cakm U+11136 to U+1113F
cham U+AA50 to U+AA59
deva U+0966 to U+096F
diak U+11950 to U+11959
fullwide U+FF10 to U+FF19
gara U+10D40 to U+10D49
gong U+11DA0 to U+11DA9
gonm U+11D50 to U+11D59
gujr U+0AE6 to U+0AEF
gukh U+16130 to U+16139
guru U+0A66 to U+0A6F
hanidec U+3007, U+4E00, U+4E8C, U+4E09, U+56DB, U+4E94, U+516D, U+4E03, U+516B, U+4E5D
hmng U+16B50 to U+16B59
hmnp U+1E140 to U+1E149
java U+A9D0 to U+A9D9
kali U+A900 to U+A909
kawi U+11F50 to U+11F59
khmr U+17E0 to U+17E9
knda U+0CE6 to U+0CEF
krai U+16D70 to U+16D79
lana U+1A80 to U+1A89
lanatham U+1A90 to U+1A99
laoo U+0ED0 to U+0ED9
latn U+0030 to U+0039
lepc U+1C40 to U+1C49
limb U+1946 to U+194F
mathbold U+1D7CE to U+1D7D7
mathdbl U+1D7D8 to U+1D7E1
mathmono U+1D7F6 to U+1D7FF
mathsanb U+1D7EC to U+1D7F5
mathsans U+1D7E2 to U+1D7EB
mlym U+0D66 to U+0D6F
modi U+11650 to U+11659
mong U+1810 to U+1819
mroo U+16A60 to U+16A69
mtei U+ABF0 to U+ABF9
mymr U+1040 to U+1049
mymrepka U+116DA to U+116E3
mymrpao U+116D0 to U+116D9
mymrshan U+1090 to U+1099
mymrtlng U+A9F0 to U+A9F9
nagm U+1E4F0 to U+1E4F9
newa U+11450 to U+11459
nkoo U+07C0 to U+07C9
olck U+1C50 to U+1C59
onao U+1E5F1 to U+1E5FA
orya U+0B66 to U+0B6F
osma U+104A0 to U+104A9
outlined U+1CCF0 to U+1CCF9
rohg U+10D30 to U+10D39
saur U+A8D0 to U+A8D9
segment U+1FBF0 to U+1FBF9
shrd U+111D0 to U+111D9
sind U+112F0 to U+112F9
sinh U+0DE6 to U+0DEF
sora U+110F0 to U+110F9
sund U+1BB0 to U+1BB9
sunu U+11BF0 to U+11BF9
takr U+116C0 to U+116C9
talu U+19D0 to U+19D9
tamldec U+0BE6 to U+0BEF
telu U+0C66 to U+0C6F
thai U+0E50 to U+0E59
tibt U+0F20 to U+0F29
tirh U+114D0 to U+114D9
tnsa U+16AC0 to U+16AC9
tols U+11DE0 to U+11DE9
vaii U+A620 to U+A629
wara U+118E0 to U+118E9
wcho U+1E2F0 to U+1E2F9
Note 1
計算は、numberFormatの有効なロケール、またはnumberFormatの有効なロケールおよび番号体系に依存する、数値文字列内のILDおよびILND String値ならびに位置に依存する。言及されたILDおよびILND String値は、通貨名のものを除き、Unicode Standardで規定されるGeneral Category "Number, decimal digit"内のコードポイントを含んではならない。
Note 2
実装は、Common Locale Data Repository(https://cldr.unicode.org/で入手可能)が提供するロケールを使用することが推奨される。

16.5.6 FormatNumeric ( numberFormat, x )

The abstract operation FormatNumeric takes arguments numberFormat (Intl.NumberFormat) and x (Intl数学的値) and returns String. It performs the following steps when called:

  1. partsPartitionNumberPattern(numberFormat, x)とする。
  2. resultを空のStringとする。
  3. partsの各Record { [[Type]], [[Value]] } partについて、次を行う:
    1. resultresultpart.[[Value]]の文字列連結に設定する。
  4. resultを返す。

16.5.7 FormatNumericToParts ( numberFormat, x )

The abstract operation FormatNumericToParts takes arguments numberFormat (Intl.NumberFormat) and x (Intl数学的値) and returns Array. It performs the following steps when called:

  1. partsPartitionNumberPattern(numberFormat, x)とする。
  2. resultを! ArrayCreate(0)とする。
  3. nを0とする。
  4. partsの各Record { [[Type]], [[Value]] } partについて、次を行う:
    1. partObjOrdinaryObjectCreate(%Object.prototype%)とする。
    2. CreateDataPropertyOrThrow(partObj, "type", part.[[Type]])を実行する。
    3. CreateDataPropertyOrThrow(partObj, "value", part.[[Value]])を実行する。
    4. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), partObj)を実行する。
    5. nn + 1 に設定する。
  5. resultを返す。

16.5.8 ToRawPrecision ( x, minPrecision, maxPrecision, unsignedRoundingMode )

The abstract operation ToRawPrecision takes arguments x (非負の数学的値), minPrecision (1から21までの包含区間内の整数), maxPrecision (1から21までの包含区間内の整数), and unsignedRoundingMode (Table 31のUnsigned Rounding Mode列からの仕様型、またはundefined) and returns フィールド[[FormattedString]](String)、[[RoundedNumber]](数学的値)、[[IntegerDigitsCount]](整数)、および[[RoundingMagnitude]](整数)を持つRecord.

これは次の方程式を解くことを伴う。この方程式は整数入力が与えられたとき、有効な数学的値を返す:

ToRawPrecisionFn(n, e, p) = n × 10ep+1
where 10p–1n < 10p

It performs the following steps when called:

  1. pmaxPrecisionとする。
  2. x = 0ならば、
    1. mを、コード単位0x0030(DIGIT ZERO)がp回出現するStringとする。
    2. eを0とする。
    3. xFinalを0とする。
  3. そうでなければ、
    1. n1およびe1をそれぞれ整数とし、r1を数学的値とする。ただし、r1 = ToRawPrecisionFn(n1, e1, p)であり、r1xであり、r1は最大化される。
    2. n2およびe2をそれぞれ整数とし、r2を数学的値とする。ただし、r2 = ToRawPrecisionFn(n2, e2, p)であり、r2xであり、r2は最小化される。
    3. xFinalApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode)とする。
    4. xFinalr1ならば、
      1. nn1とする。
      2. ee1とする。
    5. そうでなければ、
      1. nn2とする。
      2. ee2とする。
    6. mを、nの10進表現の数字からなるString(順序どおり、先頭ゼロなし)とする。
  4. e ≥ (p - 1)ならば、
    1. mmと、コード単位0x0030(DIGIT ZERO)のe - p + 1回の出現との文字列連結に設定する。
    2. inte + 1とする。
  5. そうでなく、e ≥ 0ならば、
    1. mを、mの最初のe + 1個のコード単位、コード単位0x002E(FULL STOP)、およびmの残りのp - (e + 1)個のコード単位の文字列連結に設定する。
    2. inte + 1とする。
  6. そうでなければ、
    1. Assert: e < 0である。
    2. mを、"0."、コード単位0x0030(DIGIT ZERO)の-(e + 1)回の出現、およびmの文字列連結に設定する。
    3. intを1とする。
  7. mがコード単位0x002E(FULL STOP)を含み、かつmaxPrecision > minPrecisionならば、
    1. cutmaxPrecision - minPrecisionとする。
    2. cut > 0であり、かつmの最後のコード単位が0x0030(DIGIT ZERO)である間、繰り返す:
      1. mから最後のコード単位を削除する。
      2. cutcut - 1に設定する。
    3. mの最後のコード単位が0x002E(FULL STOP)ならば、
      1. mから最後のコード単位を削除する。
  8. Record { [[FormattedString]]: m, [[RoundedNumber]]: xFinal, [[IntegerDigitsCount]]: int, [[RoundingMagnitude]]: ep+1 }を返す。

16.5.9 ToRawFixed ( x, minFraction, maxFraction, roundingIncrement, unsignedRoundingMode )

The abstract operation ToRawFixed takes arguments x (非負の数学的値), minFraction (0から100までの包含区間内の整数), maxFraction (0から100までの包含区間内の整数), roundingIncrement (整数), and unsignedRoundingMode (Table 31のUnsigned Rounding Mode列からの仕様型、またはundefined) and returns フィールド[[FormattedString]](String)、[[RoundedNumber]](数学的値)、[[IntegerDigitsCount]](整数)、および[[RoundingMagnitude]](整数)を持つRecord.

これは次の方程式を解くことを伴う。この方程式は整数入力が与えられたとき、有効な数学的値を返す:

ToRawFixedFn(n, f) = n × 10f

It performs the following steps when called:

  1. fmaxFractionとする。
  2. n1を整数とし、r1を数学的値とする。ただし、r1 = ToRawFixedFn(n1, f)であり、n1 modulo roundingIncrement = 0であり、r1xであり、r1は最大化される。
  3. n2を整数とし、r2を数学的値とする。ただし、r2 = ToRawFixedFn(n2, f)であり、n2 modulo roundingIncrement = 0であり、r2xであり、r2は最小化される。
  4. xFinalApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode)とする。
  5. xFinalr1ならばnn1とする。そうでなければnn2とする。
  6. n = 0ならばm"0"とする。そうでなければ、mnの10進表現の数字からなるString(順序どおり、先頭ゼロなし)とする。
  7. f ≠ 0ならば、
    1. kmの長さとする。
    2. kfならば、
      1. zを、コード単位0x0030(DIGIT ZERO)がf + 1 - k回出現するString値とする。
      2. mzmの文字列連結に設定する。
      3. kf + 1に設定する。
    3. amの最初のk - f個のコード単位とし、bmの残りのf個のコード単位とする。
    4. ma"."、およびbの文字列連結に設定する。
    5. intaの長さとする。
  8. そうでなければ、
    1. intmの長さとする。
  9. cutmaxFraction - minFractionとする。
  10. cut > 0であり、かつmの最後のコード単位が0x0030(DIGIT ZERO)である間、繰り返す:
    1. mから最後のコード単位を削除する。
    2. cutcut - 1に設定する。
  11. mの最後のコード単位が0x002E(FULL STOP)ならば、
    1. mから最後のコード単位を削除する。
  12. Record { [[FormattedString]]: m, [[RoundedNumber]]: xFinal, [[IntegerDigitsCount]]: int, [[RoundingMagnitude]]: –f }を返す。

16.5.10 UnwrapNumberFormat ( nf )

The abstract operation UnwrapNumberFormat takes argument nf (ECMAScript言語値) and returns ECMAScript言語値を含む通常完了またはthrow完了. 入力オブジェクトのNumberFormatインスタンスを返す。これは、その値自体、または4.3 Note 1の規範的任意コンストラクタモードに従って%Intl.NumberFormat%によって関連付けられた値のいずれかである。 It performs the following steps when called:

  1. nfがObjectでないならば、TypeError例外を投げる。
  2. nf[[InitializedNumberFormat]]内部スロットを持たず、かつ? OrdinaryHasInstance(%Intl.NumberFormat%, nf)がtrueならば、
    1. Get(nf, %Intl%.[[FallbackSymbol]])を返す。
  3. nfを返す。

16.5.11 GetNumberFormatPattern ( numberFormat, x )

The abstract operation GetNumberFormatPattern takes arguments numberFormat (Intl.NumberFormat) and x (Intl数学的値) and returns String. 数値形式オブジェクト内の解決済み単位関連オプションを、整形される最終的にスケーリングおよび丸められた数値(Intl数学的値)とともに考慮し、16.2.3で述べられるString値であるパターンを返す。 It performs the following steps when called:

  1. resolvedLocaleDatanumberFormat.[[LocaleData]]とする。
  2. patternsresolvedLocaleData.[[patterns]]とする。
  3. Assert: patternsRecordである(16.2.3参照)。
  4. stylenumberFormat.[[Style]]とする。
  5. style"percent"ならば、
    1. patternspatterns.[[percent]]に設定する。
  6. そうでなく、style"unit"ならば、
    1. unitnumberFormat.[[Unit]]とする。
    2. unitDisplaynumberFormat.[[UnitDisplay]]とする。
    3. patternspatterns.[[unit]]に設定する。
    4. patternsがフィールド[[<unit>]]を持たないならば、
      1. unit"fallback"に設定する。
    5. patternspatterns.[[<unit>]]に設定する。
    6. patternspatterns.[[<unitDisplay>]]に設定する。
  7. そうでなく、style"currency"ならば、
    1. currencynumberFormat.[[Currency]]とする。
    2. currencyDisplaynumberFormat.[[CurrencyDisplay]]とする。
    3. currencySignnumberFormat.[[CurrencySign]]とする。
    4. patternspatterns.[[currency]]に設定する。
    5. patternsがフィールド[[<currency>]]を持たないならば、
      1. currency"fallback"に設定する。
    6. patternspatterns.[[<currency>]]に設定する。
    7. patternspatterns.[[<currencyDisplay>]]に設定する。
    8. patternspatterns.[[<currencySign>]]に設定する。
  8. そうでなければ、
    1. Assert: style"decimal"である。
    2. patternspatterns.[[decimal]]に設定する。
  9. xnegative-infinityならば、
    1. categorynegative-non-zeroとする。
  10. そうでなく、xnegative-zeroならば、
    1. categorynegative-zeroとする。
  11. そうでなく、xnot-a-numberならば、
    1. categorypositive-zeroとする。
  12. そうでなく、xpositive-infinityならば、
    1. categorypositive-non-zeroとする。
  13. そうでなければ、
    1. Assert: xは数学的値である。
    2. x < 0ならば、
      1. categorynegative-non-zeroとする。
    3. そうでなく、x > 0ならば、
      1. categorypositive-non-zeroとする。
    4. そうでなければ、
      1. categorypositive-zeroとする。
  14. signDisplaynumberFormat.[[SignDisplay]]とする。
  15. signDisplay"never"ならば、
    1. patternpatterns.[[zeroPattern]]とする。
  16. そうでなく、signDisplay"auto"ならば、
    1. categorypositive-non-zeroまたはpositive-zeroならば、
      1. patternpatterns.[[zeroPattern]]とする。
    2. そうでなければ、
      1. patternpatterns.[[negativePattern]]とする。
  17. そうでなく、signDisplay"always"ならば、
    1. categorypositive-non-zeroまたはpositive-zeroならば、
      1. patternpatterns.[[positivePattern]]とする。
    2. そうでなければ、
      1. patternpatterns.[[negativePattern]]とする。
  18. そうでなく、signDisplay"exceptZero"ならば、
    1. categorypositive-zeroまたはnegative-zeroならば、
      1. patternpatterns.[[zeroPattern]]とする。
    2. そうでなく、categorypositive-non-zeroならば、
      1. patternpatterns.[[positivePattern]]とする。
    3. そうでなければ、
      1. patternpatterns.[[negativePattern]]とする。
  19. そうでなければ、
    1. Assert: signDisplay"negative"である。
    2. categorynegative-non-zeroならば、
      1. patternpatterns.[[negativePattern]]とする。
    3. そうでなければ、
      1. patternpatterns.[[zeroPattern]]とする。
  20. patternを返す。

16.5.12 GetNotationSubPattern ( numberFormat, exponent )

The abstract operation GetNotationSubPattern takes arguments numberFormat (Intl.NumberFormat) and exponent (整数) and returns String. 解決済み表記およびexponentを考慮し、16.2.3で述べられる表記サブパターンのString値を返す。 It performs the following steps when called:

  1. resolvedLocaleDatanumberFormat.[[LocaleData]]とする。
  2. notationSubPatternsresolvedLocaleData.[[notationSubPatterns]]とする。
  3. Assert: notationSubPatternsRecordである(16.2.3参照)。
  4. notationnumberFormat.[[Notation]]とする。
  5. notation"scientific"またはnotation"engineering"ならば、
    1. notationSubPatterns.[[scientific]]を返す。
  6. そうでなく、exponentが0でないならば、
    1. Assert: notation"compact"である。
    2. compactDisplaynumberFormat.[[CompactDisplay]]とする。
    3. compactPatternsnotationSubPatterns.[[compact]].[[<compactDisplay>]]とする。
    4. compactPatterns.[[<exponent>]]を返す。
  7. そうでなければ、
    1. "{number}"を返す。

16.5.13 ComputeExponent ( numberFormat, x )

The abstract operation ComputeExponent takes arguments numberFormat (Intl.NumberFormat) and x (数学的値) and returns 整数. 数値整形設定に従ってxをスケーリングする指数(10の累乗)を計算する。 999が1000に丸め上げられ、異なる指数が必要になるような場合を処理する。 It performs the following steps when called:

  1. x = 0 なら、
    1. 0 を返す。
  2. x < 0 なら、
    1. x = -x とする。
  3. magnitudefloor(log10(x)) とする。
  4. exponentComputeExponentForMagnitude(numberFormat, magnitude) とする。
  5. xx × 10-exponent に設定する。
  6. formatNumberResultFormatNumericToString(numberFormat, x) とする。
  7. formatNumberResult.[[RoundedNumber]] = 0 なら、
    1. exponent を返す。
  8. newMagnitudefloor(log10(formatNumberResult.[[RoundedNumber]])) とする。
  9. newMagnitudemagnitude - exponent なら、
    1. exponent を返す。
  10. ComputeExponentForMagnitude(numberFormat, magnitude + 1) を返す。

16.5.14 ComputeExponentForMagnitude ( numberFormat, magnitude )

The abstract operation ComputeExponentForMagnitude takes arguments numberFormat (Intl.NumberFormat) and magnitude (整数) and returns 整数. ロケールおよび望ましい表記(scientific、engineering、またはcompact)に従って、所与の桁規模(最上位桁の10の累乗)の数値をスケーリングする指数を計算する。 It performs the following steps when called:

  1. notationnumberFormat.[[Notation]]とする。
  2. notation"standard"ならば、
    1. 0を返す。
  3. そうでなく、notation"scientific"ならば、
    1. magnitudeを返す。
  4. そうでなく、notation"engineering"ならば、
    1. thousandsmagnitude / 3以下である最大の整数とする。
    2. thousands × 3を返す。
  5. そうでなければ、
    1. Assert: notation"compact"である。
    2. exponentを、現在のロケールに対するcompact notationにおいて所与の桁規模の数値をスケーリングするILD整数とする。
    3. exponentを返す。

16.5.15 Runtime Semantics: StringIntlMV

The syntax-directed operation StringIntlMV takes no arguments.

Note

StringNumericLiteralからNumber値への変換は、全体としてNumericLiteralNumericValueの決定(12.9.3参照)に似ているが、一部の詳細は異なる。

It is defined piecewise over the following productions:

StringNumericLiteral ::: StrWhiteSpaceopt
  1. 0を返す。
StringNumericLiteral ::: StrWhiteSpaceopt StrNumericLiteral StrWhiteSpaceopt
  1. StrNumericLiteralStringIntlMVを返す。
StrNumericLiteral ::: NonDecimalIntegerLiteral
  1. NonDecimalIntegerLiteralのMVを返す。
StrDecimalLiteral ::: - StrUnsignedDecimalLiteral
  1. aStrUnsignedDecimalLiteralStringIntlMVとする。
  2. aが0ならば、negative-zeroを返す。
  3. apositive-infinityならば、negative-infinityを返す。
  4. -aを返す。
StrUnsignedDecimalLiteral ::: Infinity
  1. positive-infinityを返す。
StrUnsignedDecimalLiteral ::: DecimalDigits . DecimalDigitsopt ExponentPartopt
  1. aを最初のDecimalDigitsのMVとする。
  2. 2番目のDecimalDigitsが存在するならば、
    1. bを2番目のDecimalDigitsのMVとする。
    2. nを2番目のDecimalDigits内のコードポイント数とする。
  3. そうでなければ、
    1. bを0とする。
    2. nを0とする。
  4. ExponentPartが存在するならばeExponentPartのMVとする。そうでなければeを0とする。
  5. (a + (b × 10-n)) × 10eを返す。
StrUnsignedDecimalLiteral ::: . DecimalDigits ExponentPartopt
  1. bDecimalDigitsのMVとする。
  2. ExponentPartが存在するならばeExponentPartのMVとする。そうでなければeを0とする。
  3. nDecimalDigits内のコードポイント数とする。
  4. b × 10e - nを返す。
StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPartopt
  1. aDecimalDigitsのMVとする。
  2. ExponentPartが存在するならばeExponentPartのMVとする。そうでなければeを0とする。
  3. a × 10eを返す。

16.5.16 ToIntlMathematicalValue ( value )

The abstract operation ToIntlMathematicalValue takes argument value (ECMAScript言語値) and returns Intl数学的値を含む通常完了またはthrow完了. valueIntl数学的値へ変換して返す。これは数学的値にpositive-infinitynegative-infinitynot-a-number、およびnegative-zeroを合わせたものである。 この抽象操作は7.1.3に似ているが、NumberまたはBigIntの代わりに数学的値を返すことができるため、正確な10進値を表現できる。 It performs the following steps when called:

  1. primValueを? ToPrimitive(value, number)とする。
  2. primValueがBigIntならば、(primValue)を返す。
  3. primValueがStringならば、
    1. strprimValueとする。
  4. そうでなければ、
    1. xを? ToNumber(primValue)とする。
    2. x-0𝔽ならば、negative-zeroを返す。
    3. strNumber::toString(x, 10)とする。
  5. textStringToCodePoints(str)とする。
  6. literalParseText(text, StringNumericLiteral)とする。
  7. literalがエラーのListならば、not-a-numberを返す。
  8. intlMVliteralStringIntlMVとする。
  9. intlMVが数学的値ならば、
    1. roundedRoundMVResult(abs(intlMV))とする。
    2. rounded+∞𝔽であり、かつintlMV < 0ならば、negative-infinityを返す。
    3. rounded+∞𝔽ならば、positive-infinityを返す。
    4. rounded+0𝔽であり、かつintlMV < 0ならば、negative-zeroを返す。
    5. rounded+0𝔽ならば、0を返す。
  10. intlMVを返す。

16.5.17 GetUnsignedRoundingMode ( roundingMode, sign )

The abstract operation GetUnsignedRoundingMode takes arguments roundingMode (rounding mode) and sign (negativeまたはpositive) and returns Table 31のUnsigned Rounding Mode列からの仕様型. roundingModeが数値の符号付き値に適用された場合と同じ結果を生成するために、数値の絶対値に適用されるべきrounding modeを返す(signnegativeならば負、それ以外ならば正)。 It performs the following steps when called:

  1. Identifier列の値がroundingModeであり、Sign列の値がsignである行について、Table 31のUnsigned Rounding Mode列にある仕様型を返す。
Table 31: rounding modeからunsigned rounding modeへの変換
識別子 符号 Unsigned Rounding Mode
"ceil" positive infinity
negative zero
"floor" positive zero
negative infinity
"expand" positive infinity
negative infinity
"trunc" positive zero
negative zero
"halfCeil" positive half-infinity
negative half-zero
"halfFloor" positive half-zero
negative half-infinity
"halfExpand" positive half-infinity
negative half-infinity
"halfTrunc" positive half-zero
negative half-zero
"halfEven" positive half-even
negative half-even

16.5.18 ApplyUnsignedRoundingMode ( x, r1, r2, unsignedRoundingMode )

The abstract operation ApplyUnsignedRoundingMode takes arguments x (数学的値), r1 (数学的値), r2 (数学的値), and unsignedRoundingMode (Table 31のUnsigned Rounding Mode列からの仕様型、またはundefined) and returns 数学的値. 下側をr1、上側をr2で挟まれたxを考慮し、unsignedRoundingModeに従ってr1またはr2のいずれかを返す。 It performs the following steps when called:

  1. xr1ならば、r1を返す。
  2. Assert: r1 < x < r2である。
  3. Assert: unsignedRoundingModeundefinedでない。
  4. unsignedRoundingModezeroならば、r1を返す。
  5. unsignedRoundingModeinfinityならば、r2を返す。
  6. d1xr1とする。
  7. d2r2xとする。
  8. d1 < d2ならば、r1を返す。
  9. d2 < d1ならば、r2を返す。
  10. Assert: d1d2である。
  11. unsignedRoundingModehalf-zeroならば、r1を返す。
  12. unsignedRoundingModehalf-infinityならば、r2を返す。
  13. Assert: unsignedRoundingModehalf-evenである。
  14. cardinality(r1 / (r2r1)) modulo 2とする。
  15. cardinalityが0ならば、r1を返す。
  16. r2を返す。

16.5.19 PartitionNumberRangePattern ( numberFormat, x, y )

The abstract operation PartitionNumberRangePattern takes arguments numberFormat (Intl.NumberFormat), x (Intl数学的値), and y (Intl数学的値) and returns フィールド[[Type]](String)、[[Value]](String)、および[[Source]](String)を持つRecordListを含む通常完了、またはthrow完了. xy、およびnumberFormatの整形オプションに従って、ローカライズされた数値範囲の部分を作成する。 It performs the following steps when called:

  1. xnot-a-numberまたはynot-a-numberならば、RangeError例外を投げる。
  2. xResultPartitionNumberPattern(numberFormat, x)とする。
  3. yResultPartitionNumberPattern(numberFormat, y)とする。
  4. FormatNumeric(numberFormat, x)がFormatNumeric(numberFormat, y)ならば、
    1. approximateResultFormatApproximately(numberFormat, xResult)とする。
    2. approximateResultの各要素partについて、次を行う:
      1. part.[[Source]]"shared"に設定する。
    3. approximateResultを返す。
  5. resultを新しい空のListとする。
  6. xResultの各要素partについて、次を行う:
    1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Source]]: "startRange" }をresultに追加する。
  7. rangeSeparatorを、2つの数値を区切るために使用されるILND String値とする。
  8. Record { [[Type]]: "literal", [[Value]]: rangeSeparator, [[Source]]: "shared" }をresultに追加する。
  9. yResultの各要素partについて、次を行う:
    1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Source]]: "endRange" }をresultに追加する。
  10. CollapseNumberRange(numberFormat, result)を返す。

16.5.20 FormatApproximately ( numberFormat, result )

The abstract operation FormatApproximately takes arguments numberFormat (Intl.NumberFormat) and result (フィールド[[Type]](String)および[[Value]](String)を持つRecordList) and returns フィールド[[Type]](String)および[[Value]](String)を持つRecordList. PartitionNumberPatternで述べられるRecord値のListでなければならないresultを、numberFormatに依存することがある概数記号のための新しいRecordを追加することにより変更する。 It performs the following steps when called:

  1. approximatelySignを、数値が概数であることを示すために使用されるILND String値とする。
  2. approximatelySignが空でないならば、Record { [[Type]]: "approximatelySign", [[Value]]: approximatelySign }をresult内のILNDインデックスに挿入する。例えば、numberFormat[[Locale]] "en-US"[[NumberingSystem]] "latn"、および[[Style]] "decimal"を持つ場合、新しいRecordresultの最初の要素の前に挿入されることがある。
  3. resultを返す。

16.5.21 CollapseNumberRange ( numberFormat, result )

The implementation-defined abstract operation CollapseNumberRange takes arguments numberFormat (Intl.NumberFormat) and result (フィールド[[Type]](String)、[[Value]](String)、および[[Source]](String)を持つRecordList) and returns フィールド[[Type]](String)、[[Value]](String)、および[[Source]](String)を持つRecordList. 有効なロケールおよびnumberFormatの整形オプションに従って、冗長な情報を削除し、内部不整合を解決し、必要に応じて文字を置換し、必要に応じて空白を挿入することにより、resultPartitionNumberRangePattern内で構築されるRecordListでなければならない)を変更する。その後、結果のListを返す。このアルゴリズムはILNDであるが、CollapseNumberRangeの単純な実装が常にresultを変更せずに返す場合に同じ引数Listに対する結果が等しくならないならば、引数List « start1, end1 »を持つIntl.NumberFormat.prototype.formatRange ( start, end )の結果が、引数List « start2, end2 »を持つ結果と等しくなるような曖昧さを導入してはならない。

例えば、実装は、範囲区切りの後の通貨記号を表すRecordを削除して、"$3–$5"を表すresults List"$3–5"を表すものへ変換してもよい。

実装は文法的正しさのためにRecord [[Value]]フィールドを変更してもよい。例えば、"0.5 miles–1 mile"を表すresults List"0.5–1 miles"を表すものへ変換する。

resultを変更せずに返すことは、CollapseNumberRangeの正しい実装であることが保証されている。

16.5.22 FormatNumericRange ( numberFormat, x, y )

The abstract operation FormatNumericRange takes arguments numberFormat (Intl.NumberFormat), x (Intl数学的値), and y (Intl数学的値) and returns Stringを含む通常完了またはthrow完了. It performs the following steps when called:

  1. partsを? PartitionNumberRangePattern(numberFormat, x, y)とする。
  2. resultを空のStringとする。
  3. partsの各要素partについて、次を行う:
    1. resultresultpart.[[Value]]の文字列連結に設定する。
  4. resultを返す。

16.5.23 FormatNumericRangeToParts ( numberFormat, x, y )

The abstract operation FormatNumericRangeToParts takes arguments numberFormat (Intl.NumberFormat), x (Intl数学的値), and y (Intl数学的値) and returns Arrayを含む通常完了またはthrow完了. It performs the following steps when called:

  1. partsを? PartitionNumberRangePattern(numberFormat, x, y)とする。
  2. resultを! ArrayCreate(0)とする。
  3. nを0とする。
  4. partsの各要素partについて、次を行う:
    1. partObjOrdinaryObjectCreate(%Object.prototype%)とする。
    2. CreateDataPropertyOrThrow(partObj, "type", part.[[Type]])を実行する。
    3. CreateDataPropertyOrThrow(partObj, "value", part.[[Value]])を実行する。
    4. CreateDataPropertyOrThrow(partObj, "source", part.[[Source]])を実行する。
    5. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), partObj)を実行する。
    6. nn + 1 に設定する。
  5. resultを返す。

17 PluralRulesオブジェクト

17.1 Intl.PluralRulesコンストラクタ

Intl.PluralRulesコンストラクタは、次のとおりである:

  • %Intl.PluralRules%である。
  • Intlオブジェクト"PluralRules"プロパティの初期値である。

Intlオブジェクトのすべてのサービスコンストラクタプロパティに共通する挙動は、9.1で規定される。

17.1.1 Intl.PluralRules ( [ locales [ , options ] ] )

Intl.PluralRules関数が省略可能な引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. NewTargetがundefinedならば、TypeError例外を投げる。
  2. pluralRulesを? OrdinaryCreateFromConstructor(NewTarget, "%Intl.PluralRules.prototype%", « [[InitializedPluralRules]], [[Locale]], [[Type]], [[Notation]], [[CompactDisplay]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[RoundingType]], [[RoundingIncrement]], [[RoundingMode]], [[ComputedRoundingPriority]], [[TrailingZeroDisplay]] »)とする。
  3. optionsResolutionを? ResolveOptions(%Intl.PluralRules%, %Intl.PluralRules%.[[LocaleData]], locales, options, « coerce-options »)とする。
  4. optionsoptionsResolution.[[Options]]に設定する。
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]]とする。
  6. pluralRules.[[Locale]]resolvedLocale.[[Locale]]に設定する。
  7. typeを? GetOption(options, "type", string, « "cardinal", "ordinal" », "cardinal")とする。
  8. pluralRules.[[Type]]typeに設定する。
  9. notationを? GetOption(options, "notation", string, « "standard", "scientific", "engineering", "compact" », "standard")とする。
  10. pluralRules.[[Notation]]notationに設定する。
  11. compactDisplayを? GetOption(options, "compactDisplay", string, « "short", "long" », "short")とする。
  12. notation"compact"ならば、
    1. pluralRules.[[CompactDisplay]]compactDisplayに設定する。
  13. SetNumberFormatDigitOptions(pluralRules, options, 0, 3, notation)を実行する。
  14. pluralRulesを返す。

17.2 Intl.PluralRulesコンストラクタのプロパティ

Intl.PluralRulesコンストラクタは、次のとおりである:

  • 値が%Function.prototype%である[[Prototype]]内部スロットを持つ。
  • 次のプロパティを持つ:

17.2.1 Intl.PluralRules.prototype

Intl.PluralRules.prototypeの値は%Intl.PluralRules.prototype%である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }を持つ。

17.2.2 Intl.PluralRules.supportedLocalesOf ( locales [ , options ] )

supportedLocalesOfメソッドが引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. availableLocales%Intl.PluralRules%.[[AvailableLocales]]とする。
  2. requestedLocalesを? CanonicalizeLocaleList(locales)とする。
  3. FilterLocales(availableLocales, requestedLocales, options)を返す。

17.2.3 内部スロット

[[AvailableLocales]]内部スロットの値は、9.1で述べられた制約の範囲内で実装定義である。

[[RelevantExtensionKeys]]内部スロットの値は« »である。

[[ResolutionOptionDescriptors]]内部スロットの値は« »である。

Note 1
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitionsは、複数形化処理に関連するロケール拡張キーを記述していない。

[[LocaleData]]内部スロットの値は、9.1で述べられた制約の範囲内で実装定義である。

Note 2
実装は、Common Locale Data Repository(https://cldr.unicode.org/で入手可能)が提供するロケールデータを使用することが推奨される。

17.3 Intl.PluralRulesプロトタイプオブジェクトのプロパティ

Intl.PluralRulesプロトタイプオブジェクトは、次のとおりである:

  • %Intl.PluralRules.prototype%である。
  • 通常のオブジェクトである。
  • Intl.PluralRulesインスタンスではなく、[[InitializedPluralRules]]内部スロットまたはIntl.PluralRulesインスタンスオブジェクトのその他の内部スロットを持たない。
  • 値が%Object.prototype%である[[Prototype]]内部スロットを持つ。

17.3.1 Intl.PluralRules.prototype.constructor

Intl.PluralRules.prototype.constructorの初期値は%Intl.PluralRules%である。

17.3.2 Intl.PluralRules.prototype.resolvedOptions ( )

この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。

  1. prthis値とする。
  2. RequireInternalSlot(pr, [[InitializedPluralRules]])を実行する。
  3. optionsOrdinaryObjectCreate(%Object.prototype%)とする。
  4. pluralCategoriesを、選択されたロケールpr.[[Locale]]についてPluralRuleSelectのすべての可能な結果を含み、次の順序:"zero""one""two""few""many""other"に従ってソートされたStringのListとする。
  5. Table 32の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. propertyKeyを現在の行のProperty値とする。
    2. propertyKey"pluralCategories"ならば、
      1. valueCreateArrayFromList(pluralCategories)とする。
    3. そうでなければ、
      1. valueを、その名前が現在の行のInternal Slot値であるprの内部スロットの値とする。
    4. valueundefinedでないならば、
      1. 現在の行にConversion値があるならば、
        1. Assert: 現在の行のConversion値はnumberである。
        2. value𝔽(value)に設定する。
      2. CreateDataPropertyOrThrow(options, propertyKey, value)を実行する。
  6. optionsを返す。
Table 32: PluralRulesインスタンスのResolved Options
内部スロット プロパティ 変換
[[Locale]] "locale"
[[Type]] "type"
[[Notation]] "notation"
[[CompactDisplay]] "compactDisplay"
[[MinimumIntegerDigits]] "minimumIntegerDigits" number
[[MinimumFractionDigits]] "minimumFractionDigits" number
[[MaximumFractionDigits]] "maximumFractionDigits" number
[[MinimumSignificantDigits]] "minimumSignificantDigits" number
[[MaximumSignificantDigits]] "maximumSignificantDigits" number
"pluralCategories"
[[RoundingIncrement]] "roundingIncrement" number
[[RoundingMode]] "roundingMode"
[[ComputedRoundingPriority]] "roundingPriority"
[[TrailingZeroDisplay]] "trailingZeroDisplay"

17.3.3 Intl.PluralRules.prototype.select ( value )

selectメソッドが引数valueとともに呼び出されるとき、次の手順が実行される:

  1. prthis値とする。
  2. RequireInternalSlot(pr, [[InitializedPluralRules]])を実行する。
  3. nを? ToIntlMathematicalValue(value)とする。
  4. ResolvePlural(pr, n).[[PluralCategory]]を返す。

17.3.4 Intl.PluralRules.prototype.selectRange ( start, end )

selectRangeメソッドが引数startおよびendとともに呼び出されるとき、次の手順が実行される:

  1. prthis値とする。
  2. RequireInternalSlot(pr, [[InitializedPluralRules]])を実行する。
  3. startundefinedまたはendundefinedならば、TypeError例外を投げる。
  4. xを? ToIntlMathematicalValue(start)とする。
  5. yを? ToIntlMathematicalValue(end)とする。
  6. ResolvePluralRange(pr, x, y)を返す。

17.3.5 Intl.PluralRules.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag%プロパティの初期値はString値"Intl.PluralRules"である。

このプロパティは属性{ [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }を持つ。

17.4 Intl.PluralRulesインスタンスのプロパティ

Intl.PluralRulesインスタンスは、%Intl.PluralRules.prototype%からプロパティを継承する通常のオブジェクトである。

Intl.PluralRulesインスタンスは[[InitializedPluralRules]]内部スロットを持つ。

Intl.PluralRulesインスタンスは、Intl.PluralRulesコンストラクタによって計算されるいくつかの内部スロットも持つ:

  • [[Locale]]は、複数形規則によって使用されるローカライズのロケールの言語タグを持つString値である。
  • [[Type]]は、使用される複数形規則を識別する、String値"cardinal"または"ordinal"のいずれかである。
  • [[Notation]]は、使用される表記を識別する、String値"standard""scientific""engineering"、または"compact"のいずれかである。
  • [[CompactDisplay]]は、コンパクト表記接辞を短い形式("5K")または長い形式("5 thousand")で表示するかを指定する、"short""long"、またはundefinedのいずれかであり、これは場合によって複数形の選択に影響し得る。これは、[[Notation]]"compact"以外の値を持つ場合に限りundefinedである。
  • [[MinimumIntegerDigits]]は、使用される最小整数桁数を示す非負整数である。
  • [[MinimumFractionDigits]]および[[MaximumFractionDigits]]は、使用される最小および最大の小数部桁数を示す非負整数である。必要に応じて、数値は丸められるか末尾ゼロで埋められる。
  • [[MinimumSignificantDigits]]および[[MaximumSignificantDigits]]は、使用される最小および最大の有効桁数を示す正整数である。これらのプロパティは、存在しないか、両方存在するかのいずれかである。存在する場合、それらは最小および最大の整数桁数と小数部桁数を上書きする。
  • [[RoundingType]]は、使用する丸め戦略を示す値fraction-digitssignificant-digitsmore-precision、またはless-precisionのいずれかであり、16.4で論じられている。
  • [[ComputedRoundingPriority]]は、String値"auto""morePrecision"、または"lessPrecision"のいずれかである。これは17.3.2で、[[RoundingType]]を有効な"roundingPriority"オプションへ戻すためにのみ使用される。
  • [[RoundingIncrement]]は、10、100、1000、または10000を十分の一、五分の一、四分の一、または二分の一に均等に割り切る整数である。これは、計算された丸め桁に対して丸めが行われる増分を示す。例えば、[[MaximumFractionDigits]]が2であり、[[RoundingIncrement]]が5である場合、整形された数値は最も近い0.05に丸められる("nickel rounding")。
  • [[RoundingMode]]は、使用する丸めモードを識別する。
  • [[TrailingZeroDisplay]]は、整形された数値が整数である場合(すなわち、非ゼロ小数部桁を持たない場合)に末尾ゼロを削除するかどうかを示す、String値"auto"または"stripIfInteger"のいずれかである。

17.5 PluralRulesオブジェクトのための抽象操作

17.5.1 PluralRuleSelect ( locale, type, notation, compactDisplay, decimalString )

The implementation-defined abstract operation PluralRuleSelect takes arguments locale (言語タグ), type ("cardinal"または"ordinal"), notation (String), compactDisplay ("short"または"long"), and decimalString (10進String) and returns "zero""one""two""few""many"、または"other". 返されるStringは、対応するlocaleについてtypenotation、およびcompactDisplayに従ったdecimalStringの複数形カテゴリを特徴付ける。

17.5.2 ResolvePlural ( pluralRules, n )

The abstract operation ResolvePlural takes arguments pluralRules (Intl.PluralRules) and n (Intl数学的値) and returns フィールド[[PluralCategory]]"zero""one""two""few""many"、または"other")および[[FormattedString]](String)を持つRecord. 返されるRecordは、pluralRulesの有効なロケールおよび内部スロットに従ってnを記述する2つの文字列値フィールド、すなわちその複数形カテゴリを特徴付ける[[PluralCategory]]、およびその整形済み表現を含む[[FormattedString]]を含む。 It performs the following steps when called:

  1. nnot-a-numberならば、
    1. formattedStringNaN値を示すILD String値とする。
    2. Record { [[PluralCategory]]: "other", [[FormattedString]]: formattedString }を返す。
  2. npositive-infinityならば、
    1. formattedStringを正の無限大を示すILD String値とする。
    2. Record { [[PluralCategory]]: "other", [[FormattedString]]: formattedString }を返す。
  3. nnegative-infinityならば、
    1. formattedStringを負の無限大を示すILD String値とする。
    2. Record { [[PluralCategory]]: "other", [[FormattedString]]: formattedString }を返す。
  4. resFormatNumericToString(pluralRules, n)とする。
  5. formattedStringres.[[FormattedString]]とする。
  6. localepluralRules.[[Locale]]とする。
  7. typepluralRules.[[Type]]とする。
  8. notationpluralRules.[[Notation]]とする。
  9. compactDisplaypluralRules.[[CompactDisplay]]とする。
  10. pluralCategoryPluralRuleSelect(locale, type, notation, compactDisplay, formattedString)とする。
  11. Record { [[PluralCategory]]: pluralCategory, [[FormattedString]]: formattedString }を返す。

17.5.3 PluralRuleSelectRange ( locale, type, notation, compactDisplay, xp, yp )

The implementation-defined abstract operation PluralRuleSelectRange takes arguments locale (言語タグ), type ("cardinal"または"ordinal"), notation (String), compactDisplay ("short"または"long"), xp ("zero""one""two""few""many"、または"other"), and yp ("zero""one""two""few""many"、または"other") and returns "zero""one""two""few""many"、または"other". 範囲の始点と終点をそれぞれ特徴付ける複数形カテゴリString値xpおよびypを、対応するlocaleについてtypenotation、およびcompactDisplayによって示される範囲全体の複数形に対する解決済みString値、またはString値"other"へ対応付ける、実装依存アルゴリズムを実行する。

17.5.4 ResolvePluralRange ( pluralRules, x, y )

The abstract operation ResolvePluralRange takes arguments pluralRules (Intl.PluralRules), x (Intl数学的値), and y (Intl数学的値) and returns "zero""one""two""few""many"、または"other"のいずれかを含む通常完了、またはthrow完了. 返されるString値は、pluralRulesの有効なロケールおよび内部スロットに従って、xから始まりyで終わる範囲の複数形を表す。 It performs the following steps when called:

  1. xnot-a-numberまたはynot-a-numberならば、RangeError例外を投げる。
  2. xResultResolvePlural(pluralRules, x)とする。
  3. yResultResolvePlural(pluralRules, y)とする。
  4. xResult.[[FormattedString]]yResult.[[FormattedString]]ならば、
    1. xResult.[[PluralCategory]]を返す。
  5. localepluralRules.[[Locale]]とする。
  6. typepluralRules.[[Type]]とする。
  7. notationpluralRules.[[Notation]]とする。
  8. compactDisplaypluralRules.[[CompactDisplay]]とする。
  9. PluralRuleSelectRange(locale, type, notation, compactDisplay, xResult.[[PluralCategory]], yResult.[[PluralCategory]])を返す。

18 RelativeTimeFormat オブジェクト

18.1 Intl.RelativeTimeFormat コンストラクター

Intl.RelativeTimeFormat コンストラクターは次の通りである:

  • %Intl.RelativeTimeFormat% である。
  • Intl オブジェクトの "RelativeTimeFormat" プロパティの初期値である。

Intl オブジェクトのすべてのサービスコンストラクタープロパティに共通する挙動は、9.1 で規定される。

18.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] )

Intl.RelativeTimeFormat 関数が任意の引数 locales および options とともに呼び出されたとき、次の手順が実行される:

  1. NewTarget が undefined なら、TypeError 例外を投げる。
  2. relativeTimeFormat を ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.RelativeTimeFormat.prototype%", « [[InitializedRelativeTimeFormat]], [[Locale]], [[LocaleData]], [[Style]], [[Numeric]], [[NumberFormat]], [[NumberingSystem]], [[PluralRules]] ») とする。
  3. optionsResolution を ? ResolveOptions(%Intl.RelativeTimeFormat%, %Intl.RelativeTimeFormat%.[[LocaleData]], locales, options, « coerce-options ») とする。
  4. optionsoptionsResolution.[[Options]] に設定する。
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]] とする。
  6. localeresolvedLocale.[[Locale]] とする。
  7. relativeTimeFormat.[[Locale]]locale に設定する。
  8. relativeTimeFormat.[[LocaleData]]resolvedLocale.[[LocaleData]] に設定する。
  9. relativeTimeFormat.[[NumberingSystem]]resolvedLocale.[[nu]] に設定する。
  10. style を ? GetOption(options, "style", string, « "long", "short", "narrow" », "long") とする。
  11. relativeTimeFormat.[[Style]]style に設定する。
  12. numeric を ? GetOption(options, "numeric", string, « "always", "auto" », "always") とする。
  13. relativeTimeFormat.[[Numeric]]numeric に設定する。
  14. nfOptionsOrdinaryObjectCreate(null) とする。
  15. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", relativeTimeFormat.[[NumberingSystem]]) を実行する。
  16. relativeTimeFormat.[[NumberFormat]] を ! Construct(%Intl.NumberFormat%, « locale, nfOptions ») とする。
  17. relativeTimeFormat.[[PluralRules]] を ! Construct(%Intl.PluralRules%, « locale ») とする。
  18. relativeTimeFormat を返す。

18.2 Intl.RelativeTimeFormat コンストラクターのプロパティ

Intl.RelativeTimeFormat コンストラクターは次の通りである:

  • 値が %Function.prototype% である [[Prototype]] 内部スロットを持つ。
  • 次のプロパティを持つ:

18.2.1 Intl.RelativeTimeFormat.prototype

Intl.RelativeTimeFormat.prototype の値は %Intl.RelativeTimeFormat.prototype% である。

このプロパティは属性 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } を持つ。

18.2.2 Intl.RelativeTimeFormat.supportedLocalesOf ( locales [ , options ] )

supportedLocalesOf メソッドが引数 locales および options とともに呼び出されたとき、次の手順が実行される:

  1. availableLocales%Intl.RelativeTimeFormat%.[[AvailableLocales]] とする。
  2. requestedLocales を ? CanonicalizeLocaleList(locales) とする。
  3. FilterLocales(availableLocales, requestedLocales, options) を返す。

18.2.3 内部スロット

[[AvailableLocales]] 内部スロットの値は、9.1 で記述される制約内で実装定義である。

[[RelevantExtensionKeys]] 内部スロットの値は « "nu" » である。

[[ResolutionOptionDescriptors]] 内部スロットの値は « { [[Key]]: "nu", [[Property]]: "numberingSystem" } » である。

Note 1
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions は、相対時刻整形に関連する 1 つのロケール拡張キーを説明している: (整形された数値の) 数体系用の "nu" である。

[[LocaleData]] 内部スロットの値は、9.1 で記述される制約、およびすべてのロケール値 locale について次の追加制約の範囲内で、実装定義である:

  • [[LocaleData]].[[<locale>]] は、"second""minute""hour""day""week""month""quarter"、および "year" の各フィールドを持つ。追加のフィールドは、前述の名前に文字列 "-narrow" または "-short" を連結した名前で存在してよい。これらのフィールドに対応する値は Records であり、次の 2 種類のフィールドを含む:
    • "future" および "past" フィールド。これらは locale に関連する各複数カテゴリ用のフィールドを持つ Records である。それらのフィールドに対応する値は、整形された数値で置き換えられる "{0}" を含んでよいパターンである。
    • 任意で、key が Number の ToString の結果であり、値がテンプレートとして扱われないリテラル Strings である追加フィールド。
  • [[LocaleData]] の任意のロケールフィールドの "nu" フィールドの値である List は、値 "native""traditio"、または "finance" を含んではならない。
Note 2
実装は、Common Locale Data Repository が提供するロケールデータ (https://cldr.unicode.org/ で利用可能) を使用することが推奨される。

18.3 Intl.RelativeTimeFormat プロトタイプオブジェクトのプロパティ

Intl.RelativeTimeFormat プロトタイプオブジェクトは次の通りである:

  • %Intl.RelativeTimeFormat.prototype% である。
  • 通常のオブジェクトである。
  • Intl.RelativeTimeFormat インスタンスではなく、[[InitializedRelativeTimeFormat]] 内部スロットも、Intl.RelativeTimeFormat インスタンスオブジェクトの他の内部スロットも持たない。
  • 値が %Object.prototype% である [[Prototype]] 内部スロットを持つ。

18.3.1 Intl.RelativeTimeFormat.prototype.constructor

Intl.RelativeTimeFormat.prototype.constructor の初期値は %Intl.RelativeTimeFormat% である。

18.3.2 Intl.RelativeTimeFormat.prototype.resolvedOptions ( )

この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。

  1. relativeTimeFormatthis 値とする。
  2. RequireInternalSlot(relativeTimeFormat, [[InitializedRelativeTimeFormat]]) を実行する。
  3. optionsOrdinaryObjectCreate(%Object.prototype%) とする。
  4. Table 33 の各行について、ヘッダー行を除き、表の順序で、次を行う。
    1. propertyKey を現在の行の Property 値とする。
    2. value を、現在の行の Internal Slot 値を名前とする relativeTimeFormat の内部スロットの値とする。
    3. Assert: valueundefined でない。
    4. CreateDataPropertyOrThrow(options, propertyKey, value) を実行する。
  5. options を返す。
Table 33: RelativeTimeFormat インスタンスの解決済みオプション
内部スロット プロパティ
[[Locale]] "locale"
[[Style]] "style"
[[Numeric]] "numeric"
[[NumberingSystem]] "numberingSystem"

18.3.3 Intl.RelativeTimeFormat.prototype.format ( value, unit )

format メソッドが引数 value および unit とともに呼び出されたとき、次の手順が実行される:

  1. relativeTimeFormatthis 値とする。
  2. RequireInternalSlot(relativeTimeFormat, [[InitializedRelativeTimeFormat]]) を実行する。
  3. value を ? ToNumber(value) に設定する。
  4. unit を ? ToString(unit) に設定する。
  5. FormatRelativeTime(relativeTimeFormat, value, unit) を返す。

18.3.4 Intl.RelativeTimeFormat.prototype.formatToParts ( value, unit )

formatToParts メソッドが引数 value および unit とともに呼び出されたとき、次の手順が実行される:

  1. relativeTimeFormatthis 値とする。
  2. RequireInternalSlot(relativeTimeFormat, [[InitializedRelativeTimeFormat]]) を実行する。
  3. value を ? ToNumber(value) に設定する。
  4. unit を ? ToString(unit) に設定する。
  5. FormatRelativeTimeToParts(relativeTimeFormat, value, unit) を返す。

18.3.5 Intl.RelativeTimeFormat.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag% プロパティの初期値は String 値 "Intl.RelativeTimeFormat" である。

このプロパティは属性 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } を持つ。

18.4 Intl.RelativeTimeFormat インスタンスのプロパティ

Intl.RelativeTimeFormat インスタンスは、%Intl.RelativeTimeFormat.prototype% からプロパティを継承する通常のオブジェクトである。

Intl.RelativeTimeFormat インスタンスは [[InitializedRelativeTimeFormat]] 内部スロットを持つ。

Intl.RelativeTimeFormat インスタンスは、Intl.RelativeTimeFormat コンストラクター によって計算されるいくつかの内部スロットも持つ:

  • [[Locale]] は、整形に使用されるローカライズのロケールの言語タグを持つ String 値である。
  • [[LocaleData]] は、整形のために実装が利用可能なデータを表す Record である。これは、[[Locale]] の値またはその接頭辞に関連付けられた %Intl.RelativeTimeFormat%.[[LocaleData]] 内のエントリーの値である。
  • [[Style]] は、使用される相対時刻書式スタイルを識別する String 値 "long""short"、または "narrow" のいずれかである。
  • [[Numeric]] は、数値による記述が常に使用されるか、より具体的なバージョンが利用できない場合にのみ使用されるかを識別する String 値 "always" または "auto" のいずれかである (例: "1 day ago" と "yesterday")。
  • [[NumberFormat]] は、整形に使用される Intl.NumberFormat オブジェクトである。
  • [[NumberingSystem]] は、整形に使用される Unicode Number System Identifier を表す String 値である。
  • [[PluralRules]] は、整形に使用される Intl.PluralRules オブジェクトである。

18.5 RelativeTimeFormat オブジェクトの抽象操作

18.5.1 SingularRelativeTimeUnit ( unit )

The abstract operation SingularRelativeTimeUnit takes argument unit (String) and returns String を含む正常完了、または throw 完了. It performs the following steps when called:

  1. unit"seconds" なら、"second" を返す。
  2. unit"minutes" なら、"minute" を返す。
  3. unit"hours" なら、"hour" を返す。
  4. unit"days" なら、"day" を返す。
  5. unit"weeks" なら、"week" を返す。
  6. unit"months" なら、"month" を返す。
  7. unit"quarters" なら、"quarter" を返す。
  8. unit"years" なら、"year" を返す。
  9. unit"second""minute""hour""day""week""month""quarter"、または "year" のいずれでもないなら、RangeError 例外を投げる。
  10. unit を返す。

18.5.2 PartitionRelativeTimePattern ( relativeTimeFormat, value, unit )

The abstract operation PartitionRelativeTimePattern takes arguments relativeTimeFormat (Intl.RelativeTimeFormat), value (Number), and unit (String) and returns フィールド [[Type]] (String)、[[Value]] (String)、および [[Unit]] (String または empty) を持つ RecordsList を含む正常完了、または throw 完了. 返される List は、relativeTimeFormat の実効ロケールおよび整形オプションに従って value を表す。 It performs the following steps when called:

  1. valueNaN+∞𝔽、または -∞𝔽 なら、RangeError 例外を投げる。
  2. unit を ? SingularRelativeTimeUnit(unit) に設定する。
  3. fieldsrelativeTimeFormat.[[LocaleData]] とする。
  4. patternsfields.[[<unit>]] とする。
  5. stylerelativeTimeFormat.[[Style]] とする。
  6. style"short" または "narrow" なら、
    1. keyunit"-"、および style の文字列連結とする。
    2. fields がフィールド [[<key>]] を持つなら、patternsfields.[[<key>]] に設定する。
  7. relativeTimeFormat.[[Numeric]]"auto" なら、
    1. valueString を ! ToString(value) とする。
    2. patterns がフィールド [[<valueString>]] を持つなら、
      1. resultpatterns.[[<valueString>]] とする。
      2. Record { [[Type]]: "literal", [[Value]]: result, [[Unit]]: empty } を含む List を返す。
  8. value-0𝔽 または value < -0𝔽 なら、
    1. tense"past" とする。
  9. そうでなければ、
    1. tense"future" とする。
  10. tensePatternspatterns.[[<tense>]] とする。
  11. formattedValuePartitionNumberPattern(relativeTimeFormat.[[NumberFormat]], (value)) とする。
  12. pluralCategoryResolvePlural(relativeTimeFormat.[[PluralRules]], value).[[PluralCategory]] とする。
  13. patterntensePatterns.[[<pluralCategory>]] とする。
  14. MakePartsList(pattern, unit, formattedValue) を返す。

18.5.3 MakePartsList ( pattern, unit, parts )

The abstract operation MakePartsList takes arguments pattern (Pattern String), unit (String), and parts (整形された Number を表す RecordsList) and returns フィールド [[Type]] (String)、[[Value]] (String)、および [[Unit]] (String または empty) を持つ RecordsList. It performs the following steps when called:

  1. patternPartsPartitionPattern(pattern) とする。
  2. result を新しい空の List とする。
  3. patternParts の各 Record { [[Type]], [[Value]] } patternPart について、次を行う。
    1. patternPart.[[Type]]"literal" なら、
      1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]], [[Unit]]: empty } を result に追加する。
    2. そうでなければ、
      1. Assert: patternPart.[[Type]]"0" である。
      2. parts の各 Record { [[Type]], [[Value]] } part について、次を行う。
        1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: unit } を result に追加する。
  4. result を返す。
Note
例:
  1. MakePartsList("AA{0}BB", "hour", « Record { [[Type]]: "integer", [[Value]]: "15" } ») を返す。
これは、次のような RecordsList を返す « { [[Type]]: "literal", [[Value]]: "AA", [[Unit]]: empty}, { [[Type]]: "integer", [[Value]]: "15", [[Unit]]: "hour"}, { [[Type]]: "literal", [[Value]]: "BB", [[Unit]]: empty} »

18.5.4 FormatRelativeTime ( relativeTimeFormat, value, unit )

The abstract operation FormatRelativeTime takes arguments relativeTimeFormat (Intl.RelativeTimeFormat), value (Number), and unit (String) and returns String を含む正常完了、または throw 完了. It performs the following steps when called:

  1. parts を ? PartitionRelativeTimePattern(relativeTimeFormat, value, unit) とする。
  2. result を空の String とする。
  3. parts の各 Record { [[Type]], [[Value]], [[Unit]] } part について、次を行う。
    1. resultresultpart.[[Value]] の文字列連結に設定する。
  4. result を返す。

18.5.5 FormatRelativeTimeToParts ( relativeTimeFormat, value, unit )

The abstract operation FormatRelativeTimeToParts takes arguments relativeTimeFormat (Intl.RelativeTimeFormat), value (Number), and unit (String) and returns Array を含む正常完了、または throw 完了. It performs the following steps when called:

  1. parts を ? PartitionRelativeTimePattern(relativeTimeFormat, value, unit) とする。
  2. result を ! ArrayCreate(0) とする。
  3. n を 0 とする。
  4. parts の各 Record { [[Type]], [[Value]], [[Unit]] } part について、次を行う。
    1. partObjOrdinaryObjectCreate(%Object.prototype%) とする。
    2. CreateDataPropertyOrThrow(partObj, "type", part.[[Type]]) を実行する。
    3. CreateDataPropertyOrThrow(partObj, "value", part.[[Value]]) を実行する。
    4. part.[[Unit]]empty でないなら、
      1. CreateDataPropertyOrThrow(partObj, "unit", part.[[Unit]]) を実行する。
    5. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), partObj) を実行する。
    6. nn + 1 に設定する。
  5. result を返す。

19 Segmenter オブジェクト

19.1 Intl.Segmenter コンストラクター

Intl.Segmenter コンストラクターは次の通りである:

  • %Intl.Segmenter% である。
  • Intl オブジェクトの "Segmenter" プロパティの初期値である。

Intl オブジェクトのすべてのサービスコンストラクタープロパティに共通する挙動は、9.1 で規定される。

19.1.1 Intl.Segmenter ( [ locales [ , options ] ] )

Intl.Segmenter 関数が任意の引数 locales および options とともに呼び出されたとき、次の手順が実行される:

  1. NewTarget が undefined なら、TypeError 例外を投げる。
  2. internalSlotsList を « [[InitializedSegmenter]], [[Locale]], [[SegmenterGranularity]] » とする。
  3. segmenter を ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.Segmenter.prototype%", internalSlotsList) とする。
  4. optionsResolution を ? ResolveOptions(%Intl.Segmenter%, %Intl.Segmenter%.[[LocaleData]], locales, options) とする。
  5. optionsoptionsResolution.[[Options]] に設定する。
  6. resolvedLocaleoptionsResolution.[[ResolvedLocale]] とする。
  7. segmenter.[[Locale]]resolvedLocale.[[Locale]] に設定する。
  8. granularity を ? GetOption(options, "granularity", string, « "grapheme", "word", "sentence" », "grapheme") とする。
  9. segmenter.[[SegmenterGranularity]]granularity に設定する。
  10. segmenter を返す。

19.2 Intl.Segmenter コンストラクターのプロパティ

Intl.Segmenter コンストラクターは次の通りである:

  • 値が %Function.prototype% である [[Prototype]] 内部スロットを持つ。
  • 次のプロパティを持つ:

19.2.1 Intl.Segmenter.prototype

Intl.Segmenter.prototype の値は %Intl.Segmenter.prototype% である。

このプロパティは属性 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } を持つ。

19.2.2 Intl.Segmenter.supportedLocalesOf ( locales [ , options ] )

supportedLocalesOf メソッドが引数 locales および options とともに呼び出されたとき、次の手順が実行される:

  1. availableLocales%Intl.Segmenter%.[[AvailableLocales]] とする。
  2. requestedLocales を ? CanonicalizeLocaleList(locales) とする。
  3. FilterLocales(availableLocales, requestedLocales, options) を返す。

19.2.3 内部スロット

[[AvailableLocales]] 内部スロットの値は、9.1 で記述される制約内で実装定義である。

[[RelevantExtensionKeys]] 内部スロットの値は « » である。

[[ResolutionOptionDescriptors]] 内部スロットの値は « » である。

Note
Intl.Segmenter には関連する拡張キーが存在しない。

[[LocaleData]] 内部スロットの値は、9.1 で記述される制約内で実装定義である。

19.3 Intl.Segmenter プロトタイプオブジェクトのプロパティ

Intl.Segmenter プロトタイプオブジェクトは次の通りである:

  • %Intl.Segmenter.prototype% である。
  • 通常のオブジェクトである。
  • Intl.Segmenter インスタンスではなく、[[InitializedSegmenter]] 内部スロットも、Intl.Segmenter インスタンスオブジェクトの他の内部スロットも持たない。
  • 値が %Object.prototype% である [[Prototype]] 内部スロットを持つ。

19.3.1 Intl.Segmenter.prototype.constructor

Intl.Segmenter.prototype.constructor の初期値は %Intl.Segmenter% である。

19.3.2 Intl.Segmenter.prototype.resolvedOptions ( )

この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。

  1. segmenterthis 値とする。
  2. RequireInternalSlot(segmenter, [[InitializedSegmenter]]) を実行する。
  3. optionsOrdinaryObjectCreate(%Object.prototype%) とする。
  4. Table 34 の各行について、ヘッダー行を除き、表の順序で、次を行う。
    1. propertyKey を現在の行の Property 値とする。
    2. value を、現在の行の Internal Slot 値を名前とする segmenter の内部スロットの値とする。
    3. Assert: valueundefined でない。
    4. CreateDataPropertyOrThrow(options, propertyKey, value) を実行する。
  5. options を返す。
Table 34: Segmenter インスタンスの解決済みオプション
内部スロット プロパティ
[[Locale]] "locale"
[[SegmenterGranularity]] "granularity"

19.3.3 Intl.Segmenter.prototype.segment ( string )

Intl.Segmenter.prototype.segment メソッドは、引数 string とともに Intl.Segmenter インスタンス上で呼び出され、Intl.Segmenter インスタンスのロケールおよびオプションを使用して、その文字列用の Segments インスタンスを作成する。次の手順が実行される:

  1. segmenterthis 値とする。
  2. RequireInternalSlot(segmenter, [[InitializedSegmenter]]) を実行する。
  3. string を ? ToString(string) に設定する。
  4. CreateSegmentsObject(segmenter, string) を返す。

19.3.4 Intl.Segmenter.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag% プロパティの初期値は String 値 "Intl.Segmenter" である。

このプロパティは属性 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } を持つ。

19.4 Intl.Segmenter インスタンスのプロパティ

Intl.Segmenter インスタンスは、%Intl.Segmenter.prototype% からプロパティを継承する通常のオブジェクトである。

Intl.Segmenter インスタンスは [[InitializedSegmenter]] 内部スロットを持つ。

Intl.Segmenter インスタンスは、Intl.Segmenter コンストラクター によって計算される内部スロットも持つ:

  • [[Locale]] は、セグメント化に使用されるローカライズのロケールの言語タグを持つ String 値である。
  • [[SegmenterGranularity]] は、セグメント化するテキスト要素の種類を識別する String 値 "grapheme""word"、または "sentence" のいずれかである。

19.5 Segments オブジェクト

Segments インスタンスは、構築元の Intl.Segmenter インスタンスのロケールおよびオプションに従う、特定の文字列のセグメントを表すオブジェクトである。

19.5.1 CreateSegmentsObject ( segmenter, string )

The abstract operation CreateSegmentsObject takes arguments segmenter (Intl.Segmenter) and string (String) and returns Segments インスタンス. Segments インスタンスsegmenter および string を参照する。 It performs the following steps when called:

  1. internalSlotsList を « [[SegmentsSegmenter]], [[SegmentsString]] » とする。
  2. segmentsOrdinaryObjectCreate(%IntlSegmentsPrototype%, internalSlotsList) とする。
  3. segments.[[SegmentsSegmenter]]segmenter に設定する。
  4. segments.[[SegmentsString]]string に設定する。
  5. segments を返す。

19.5.2 %IntlSegmentsPrototype% オブジェクト

%IntlSegmentsPrototype% オブジェクトは次の通りである:

  • すべての Segments オブジェクトのプロトタイプである。
  • 通常のオブジェクトである。
  • 値が %Object.prototype% である [[Prototype]] 内部スロットを持つ。
  • 次のプロパティを持つ:

19.5.2.1 %IntlSegmentsPrototype%.containing ( index )

containing メソッドは、引数 index とともに Segments インスタンス上で呼び出され、Segments インスタンスの構築元の Intl.Segmenter インスタンスのロケールおよびオプションに従って、指定されたインデックスのコード単位を含む文字列内のセグメントを記述する Segment Data オブジェクトを返す。次の手順が実行される:

  1. segmentsthis 値とする。
  2. RequireInternalSlot(segments, [[SegmentsSegmenter]]) を実行する。
  3. segmentersegments.[[SegmentsSegmenter]] とする。
  4. stringsegments.[[SegmentsString]] とする。
  5. lengthstring の長さとする。
  6. n を ? ToIntegerOrInfinity(index) とする。
  7. n < 0 または nlength なら、undefined を返す。
  8. startIndexFindBoundary(segmenter, string, n, before) とする。
  9. endIndexFindBoundary(segmenter, string, n, after) とする。
  10. CreateSegmentDataObject(segmenter, string, startIndex, endIndex) を返す。

19.5.2.2 %IntlSegmentsPrototype% [ %Symbol.iterator% ] ( )

%Symbol.iterator% メソッドは、Segments インスタンス上で呼び出され、その構築元の Intl.Segmenter インスタンスのロケールおよびオプションを使用して、その文字列上の Segment Iterator を作成する。次の手順が実行される:

  1. segmentsthis 値とする。
  2. RequireInternalSlot(segments, [[SegmentsSegmenter]]) を実行する。
  3. segmentersegments.[[SegmentsSegmenter]] とする。
  4. stringsegments.[[SegmentsString]] とする。
  5. CreateSegmentIterator(segmenter, string) を返す。

この関数の "name" プロパティの値は "[Symbol.iterator]" である。

19.5.3 Segments インスタンスのプロパティ

Segments インスタンスは、%IntlSegmentsPrototype% からプロパティを継承する通常のオブジェクトである。

Segments インスタンスは、構築元の Intl.Segmenter インスタンスを参照する [[SegmentsSegmenter]] 内部スロットを持つ。

Segments インスタンスは、自身が公開するセグメントの対象である String 値を参照する [[SegmentsString]] 内部スロットを持つ。

19.6 Segment Iterator オブジェクト

Segment Iterator は、特定の文字列のセグメントに対する特定の反復を表すオブジェクトである。

19.6.1 CreateSegmentIterator ( segmenter, string )

The abstract operation CreateSegmentIterator takes arguments segmenter (Intl.Segmenter) and string (String) and returns Segment Iterator. Segment Iterator は、segmenter のロケールおよびオプションを使用して string を反復処理する。 It performs the following steps when called:

  1. internalSlotsList を « [[IteratingSegmenter]], [[IteratedString]], [[IteratedStringNextSegmentCodeUnitIndex]] » とする。
  2. iteratorOrdinaryObjectCreate(%IntlSegmentIteratorPrototype%, internalSlotsList) とする。
  3. iterator.[[IteratingSegmenter]]segmenter に設定する。
  4. iterator.[[IteratedString]]string に設定する。
  5. iterator.[[IteratedStringNextSegmentCodeUnitIndex]] を 0 に設定する。
  6. iterator を返す。

19.6.2 %IntlSegmentIteratorPrototype% オブジェクト

%IntlSegmentIteratorPrototype% オブジェクトは次の通りである:

  • すべての Segment Iterator オブジェクトのプロトタイプである。
  • 通常のオブジェクトである。
  • 値が %Iterator.prototype% である [[Prototype]] 内部スロットを持つ。
  • 次のプロパティを持つ:

19.6.2.1 %IntlSegmentIteratorPrototype%.next ( )

next メソッドは、Segment Iterator インスタンス上で呼び出され、それを 1 セグメント分前進させ、新しいセグメントを記述するか反復の完了を宣言する IteratorResult オブジェクトを返す。次の手順が実行される:

  1. iteratorthis 値とする。
  2. RequireInternalSlot(iterator, [[IteratingSegmenter]]) を実行する。
  3. segmenteriterator.[[IteratingSegmenter]] とする。
  4. stringiterator.[[IteratedString]] とする。
  5. startIndexiterator.[[IteratedStringNextSegmentCodeUnitIndex]] とする。
  6. lengthstring の長さとする。
  7. startIndexlength なら、
    1. CreateIteratorResultObject(undefined, true) を返す。
  8. endIndexFindBoundary(segmenter, string, startIndex, after) とする。
  9. iterator.[[IteratedStringNextSegmentCodeUnitIndex]]endIndex に設定する。
  10. segmentDataCreateSegmentDataObject(segmenter, string, startIndex, endIndex) とする。
  11. CreateIteratorResultObject(segmentData, false) を返す。

19.6.2.2 %IntlSegmentIteratorPrototype% [ %Symbol.toStringTag% ]

%Symbol.toStringTag% プロパティの初期値は String 値 "Segmenter String Iterator" である。

このプロパティは属性 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } を持つ。

19.6.3 Segment Iterator インスタンスのプロパティ

Segment Iterator インスタンスは、%SegmentIteratorPrototype% からプロパティを継承する通常のオブジェクトである。Segment Iterator インスタンスは、Table 35 で記述される内部スロットを持つものとして最初に作成される。

Table 35: Segment Iterator インスタンスの内部スロット
内部スロット 説明
[[IteratingSegmenter]] 反復処理に使用される Intl.Segmenter インスタンス。
[[IteratedString]] 反復処理されている String 値。
[[IteratedStringNextSegmentCodeUnitIndex]] 反復処理されている String 値内で、次のセグメントの開始位置にあるコード単位インデックス。

19.7 Segment Data オブジェクト

Segment Data オブジェクトは、文字列からの特定のセグメントを表すオブジェクトである。

19.7.1 CreateSegmentDataObject ( segmenter, string, startIndex, endIndex )

The abstract operation CreateSegmentDataObject takes arguments segmenter (Intl.Segmenter), string (String), startIndex (非負整数), and endIndex (非負整数) and returns Segment Data オブジェクト. Segment Data オブジェクトは、segmenter から得られる string 内の、インデックス startIndex および endIndex によって境界付けられるセグメントを記述する。 It performs the following steps when called:

  1. lengthstring の長さとする。
  2. Assert: endIndexlength である。
  3. Assert: startIndex < endIndex である。
  4. resultOrdinaryObjectCreate(%Object.prototype%) とする。
  5. segmentstringstartIndex から endIndex までの部分文字列とする。
  6. CreateDataPropertyOrThrow(result, "segment", segment) を実行する。
  7. CreateDataPropertyOrThrow(result, "index", 𝔽(startIndex)) を実行する。
  8. CreateDataPropertyOrThrow(result, "input", string) を実行する。
  9. granularitysegmenter.[[SegmenterGranularity]] とする。
  10. granularity"word" なら、
    1. isWordLike を、string 内の segment がロケール segmenter.[[Locale]] に従って「word-like」であるかどうかを示す Boolean とする。
    2. CreateDataPropertyOrThrow(result, "isWordLike", isWordLike) を実行する。
  11. result を返す。
Note
セグメントが「word-like」であるかどうかは実装依存であり、実装はロケールに依存した調整を使用することが推奨される。一般に、空白および/または句読点のみから構成されるセグメント (ICU [International Components for Unicode、https://unicode-org.github.io/icu-docs/ に文書化されている] によって "WORD_NONE" 境界で終了されるものなど) は、「word-like」とは見なされない。

19.8 Segmenter オブジェクトの抽象操作

19.8.1 FindBoundary ( segmenter, string, startIndex, direction )

The abstract operation FindBoundary takes arguments segmenter (Intl.Segmenter), string (String), startIndex (非負整数), and direction (before または after) and returns 非負整数. segmenter のロケールおよびオプションに従って、startIndex のインデックスにあるコード単位から指定された direction に、string 内の 2 つのコード単位の間のセグメンテーション境界を見つけ、その直後のコード単位インデックスを返す。 It performs the following steps when called:

  1. lengthstring の長さとする。
  2. Assert: startIndex < length である。
  3. localesegmenter.[[Locale]] とする。
  4. granularitysegmenter.[[SegmenterGranularity]] とする。
  5. directionbefore なら、
    1. ロケール locale およびテキスト要素粒度 granularity を使用して、先頭から最大で startIndex 個のコード単位が前にある最後のセグメンテーション境界を string 内で検索する。
    2. 境界が見つかったなら、その前にある string 内のコード単位数を返す。
    3. 0 を返す。
  6. Assert: directionafter である。
  7. ロケール locale およびテキスト要素粒度 granularity を使用して、インデックス startIndex にあるコード単位の後に続く最初のセグメンテーション境界を string 内で検索する。
  8. 境界が見つかったなら、その前にある string 内のコード単位数を返す。
  9. length を返す。
Note
境界決定は実装依存であるが、一般的な既定のアルゴリズムは Unicode Standard Annex #29 で規定されている。実装は、Common Locale Data Repository (https://cldr.unicode.org で利用可能) によって提供されるものなど、ロケールに依存した調整を使用することが推奨される。

20 ECMAScript言語仕様のロケール依存関数

ECMA-262は、いくつかのロケール依存関数を記述している。この仕様を実装するECMAScript実装は、ここで記述されるとおりにこれらの関数を実装しなければならない。

Note
この節のアルゴリズム内で作成されるCollator、NumberFormat、またはDateTimeFormatオブジェクトは、これらのアルゴリズム内でのみ使用される。これらはECMAScriptコードから直接アクセスされることはなく、実装内に実際に存在する必要はない。

20.1 Stringプロトタイプオブジェクトのプロパティ

20.1.1 String.prototype.localeCompare ( that [ , locales [ , options ] ] )

この定義は、ECMA-26222.1.3.12で提供される定義を置き換える。

localeCompareメソッドが引数thatおよび省略可能な引数localesoptionsとともに呼び出されるとき、次の手順が実行される:

  1. thisValueを? RequireObjectCoercible(this value)とする。
  2. stringを? ToString(thisValue)とする。
  3. thatValueを? ToString(that)とする。
  4. collatorを? Construct(%Intl.Collator%, « locales, options »)とする。
  5. CompareStrings(collator, string, thatValue)を返す。

この関数の"length"プロパティは1𝔽である。

Note 1
localeCompareメソッド自体は、Array.prototype.sortへの引数として直接適していない。後者は2つの引数を持つ関数を必要とするためである。
Note 2
localeCompare関数は意図的に汎用的である。そのthis値がStringオブジェクトであることを必要としない。したがって、メソッドとして使用するために他の種類のオブジェクトへ転用できる。

20.1.2 String.prototype.toLocaleLowerCase ( [ locales ] )

この定義は、ECMA-26222.1.3.26で提供される定義を置き換える。

この関数は、ECMA-2626.1.4で述べられるとおり、String値をコードポイントの列として解釈する。次の手順が実行される:

  1. thisValueを? RequireObjectCoercible(this value)とする。
  2. stringを? ToString(thisValue)とする。
  3. TransformCase(string, locales, lower)を返す。
Note
toLocaleLowerCase関数は意図的に汎用的である。そのthis値がStringオブジェクトであることを必要としない。したがって、メソッドとして使用するために他の種類のオブジェクトへ転用できる。

20.1.2.1 TransformCase ( string, locales, targetCase )

The abstract operation TransformCase takes arguments string (String), locales (ECMAScript言語値), and targetCase (lowerまたはupper). ECMA-2626.1.4で述べられるとおり、stringをUTF-16符号化コードポイントの列として解釈し、targetCaseへのILD変換の結果を新しいString値として返す。 It performs the following steps when called:

  1. requestedLocalesを? CanonicalizeLocaleList(locales)とする。
  2. requestedLocalesが空のListでないならば、
    1. requestedLocalerequestedLocales[0]とする。
  3. そうでなければ、
    1. requestedLocaleDefaultLocale()とする。
  4. availableLocalesを、Unicode Character Databaseが言語依存のケースマッピングを含む言語タグを含むAvailable Locales Listとする。実装が追加のロケール依存ケースマッピングをサポートする場合、availableLocalesはそれらに対応する言語タグも含むべきである。
  5. matchLookupMatchingLocaleByPrefix(availableLocales, « requestedLocale »)とする。
  6. matchundefinedでないならばlocalematch.[[locale]]とし、そうでなければlocale"und"とする。
  7. codePointsStringToCodePoints(string)とする。
  8. targetCaselowerならば、
    1. newCodePointsを、localeを使用する実装由来のアルゴリズムまたはUnicode Default Case Conversionアルゴリズムに従ったcodePointsの小文字変換の結果を要素とするListとする。
  9. そうでなければ、
    1. Assert: targetCaseupperである。
    2. newCodePointsを、localeを使用する実装由来のアルゴリズムまたはUnicode Default Case Conversionアルゴリズムに従ったcodePointsの大文字変換の結果を要素とするListとする。
  10. CodePointsToString(newCodePoints)を返す。

コードポイントマッピングは、Unicode StandardのDefault Case Conversion Algorithmsを調整した版に従って導出してもよい。実装は、Unicode Character DatabaseのファイルSpecialCasing.txtで定義されるロケール依存の調整、および/またはCLDR、および/またはその他の任意のカスタム調整を使用してもよい。調整の有無にかかわらず、適合する実装のケース変換アルゴリズムは、同じ入力コードポイント、ロケール、および対象ケースが与えられた場合、常に同じ結果を生成しなければならない。

Note
一部のコードポイントのケースマッピングは複数のコードポイントを生成することがあり、そのため結果は入力と同じ長さにならない場合がある。toLocaleUpperCasetoLocaleLowerCaseはいずれも文脈依存の挙動を持つため、これらの関数は対称ではない。言い換えると、s.toLocaleUpperCase().toLocaleLowerCase()は必ずしもs.toLocaleLowerCase()と等しくなく、s.toLocaleLowerCase().toLocaleUpperCase()は必ずしもs.toLocaleUpperCase()と等しくない。

20.1.3 String.prototype.toLocaleUpperCase ( [ locales ] )

この定義は、ECMA-26222.1.3.27で提供される定義を置き換える。

この関数は、ECMA-2626.1.4で述べられるとおり、String値をコードポイントの列として解釈する。次の手順が実行される:

  1. thisValueを? RequireObjectCoercible(this value)とする。
  2. stringを? ToString(thisValue)とする。
  3. TransformCase(string, locales, upper)を返す。
Note
toLocaleUpperCase関数は意図的に汎用的である。そのthis値がStringオブジェクトであることを必要としない。したがって、メソッドとして使用するために他の種類のオブジェクトへ転用できる。

20.2 Numberプロトタイプオブジェクトのプロパティ

次の定義は、ECMA-26221.1.3で定義される抽象操作thisNumberValueを参照する。

20.2.1 Number.prototype.toLocaleString ( [ locales [ , options ] ] )

この定義は、ECMA-26221.1.3.4で提供される定義を置き換える。

toLocaleStringメソッドが省略可能な引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. xを? ThisNumberValue(this value)とする。
  2. numberFormatを? Construct(%Intl.NumberFormat%, « locales, options »)とする。
  3. FormatNumeric(numberFormat, ! ToIntlMathematicalValue(x))を返す。

20.3 BigIntプロトタイプオブジェクトのプロパティ

次の定義は、ECMA-26221.2.3で定義される抽象操作thisBigIntValueを参照する。

20.3.1 BigInt.prototype.toLocaleString ( [ locales [ , options ] ] )

この定義は、ECMA-26221.2.3.2で提供される定義を置き換える。

toLocaleStringメソッドが省略可能な引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. xを? ThisBigIntValue(this value)とする。
  2. numberFormatを? Construct(%Intl.NumberFormat%, « locales, options »)とする。
  3. FormatNumeric(numberFormat, (x))を返す。

20.4 Dateプロトタイプオブジェクトのプロパティ

次の定義は、ECMA-26221.4.4で定義される抽象操作thisTimeValueを参照する。

20.4.1 Date.prototype.toLocaleString ( [ locales [ , options ] ] )

この定義は、ECMA-26221.4.4.39で提供される定義を置き換える。

toLocaleStringメソッドが省略可能な引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. dateObjthis値とする。
  2. RequireInternalSlot(dateObj, [[DateValue]])を実行する。
  3. xdateObj.[[DateValue]]とする。
  4. xNaNならば、"Invalid Date"を返す。
  5. dateFormatを? CreateDateTimeFormat(%Intl.DateTimeFormat%, locales, options, any, all)とする。
  6. FormatDateTime(dateFormat, x)を返す。

20.4.2 Date.prototype.toLocaleDateString ( [ locales [ , options ] ] )

この定義は、Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] )で提供される定義を置き換える。

toLocaleDateStringメソッドが省略可能な引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. dateObjthis値とする。
  2. RequireInternalSlot(dateObj, [[DateValue]])を実行する。
  3. xdateObj.[[DateValue]]とする。
  4. xNaNならば、"Invalid Date"を返す。
  5. dateFormatを? CreateDateTimeFormat(%Intl.DateTimeFormat%, locales, options, date, date)とする。
  6. FormatDateTime(dateFormat, x)を返す。

20.4.3 Date.prototype.toLocaleTimeString ( [ locales [ , options ] ] )

この定義は、Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] )で提供される定義を置き換える。

toLocaleTimeStringメソッドが省略可能な引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. dateObjthis値とする。
  2. RequireInternalSlot(dateObj, [[DateValue]])を実行する。
  3. xdateObj.[[DateValue]]とする。
  4. xNaNならば、"Invalid Date"を返す。
  5. timeFormatを? CreateDateTimeFormat(%Intl.DateTimeFormat%, locales, options, time, time)とする。
  6. FormatDateTime(timeFormat, x)を返す。

20.5 Arrayプロトタイプオブジェクトのプロパティ

20.5.1 Array.prototype.toLocaleString ( [ locales [ , options ] ] )

この定義は、Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )で提供される定義を置き換える。

toLocaleStringメソッドが省略可能な引数localesおよびoptionsとともに呼び出されるとき、次の手順が実行される:

  1. arrayを? ToObject(this value)とする。
  2. lengthを? LengthOfArrayLike(array)とする。
  3. separatorを、ホスト環境の現在のロケールに適した実装定義のリスト区切り文字String値(例えば", ")とする。
  4. resultを空のStringとする。
  5. kを0とする。
  6. k < lengthである間、繰り返す:
    1. k > 0ならば、
      1. resultresultseparatorの文字列連結に設定する。
    2. elementを? Get(array, ! ToString(𝔽(k)))とする。
    3. elementundefinedでもnullでもないならば、
      1. elementStringを? ToString(? Invoke(element, "toLocaleString", « locales, options »))とする。
      2. resultresultelementStringの文字列連結に設定する。
    4. kk + 1に設定する。
  7. resultを返す。
Note 1
このアルゴリズムの手順は、Invoke(nextElement, "toLocaleString")がlocalesおよびoptionsを引数として取るようになった点を除き、Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )で実行される手順を反映している。
Note 2
配列の要素は、それぞれのtoLocaleStringメソッドを使用してStringに変換され、これらのStringは、実装定義のロケール依存区切り文字Stringの出現によって区切られて連結される。この関数はtoStringに類似するが、ホスト環境の現在のロケールの慣習に対応するロケール依存の結果を生成することを意図している点が異なる。
Note 3
toLocaleString関数は意図的に汎用的である。そのthis値がArrayオブジェクトであることを必要としない。したがって、メソッドとして使用するために他の種類のオブジェクトへ転用できる。

Annex A (informative) 実装依存の動作

この仕様書の以下の側面は実装依存です:

Annex B (informative) 以前の版との非互換性を導入する追加と変更

Annex C (informative) コロフォン

この仕様書は、GitHub上で、Ecmarkupというプレーンテキストソース形式で作成されています。Ecmarkupは、HTMLとMarkdownの方言であり、プレーンテキストでECMAScript仕様書を作成し、この文書の編集上の慣例に従った完全なHTMLレンダリングに処理するためのフレームワークとツールセットを提供します。Ecmarkupは、構文定義のためのGrammarkdownや、アルゴリズムステップの作成のためのEcmarkdownなど、他の多くのフォーマットや技術を統合しています。この仕様書のPDFレンダリングは、CSS Paged Media仕様を活用した印刷用スタイルシートを使用し、PrinceXMLで変換されています。

以前の版の仕様書はWordで作成されていました—この版の基礎となったEcmarkupソーステキストは、ECMAScript 2015のWordドキュメントを自動変換ツールでEcmarkupに変換して作成されました。

Copyright & Software License

Ecma International

Rue du Rhone 114

CH-1204 Geneva

Tel: +41 22 849 6000

Fax: +41 22 849 6001

Web: https://ecma-international.org/

Software License

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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. 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.
  3. 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.