Multipage preference

Draft ECMA-402 / October 12, 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上:toLocaleString;String.prototype上:localeCompare、toLocaleLowerCase、toLocaleUpperCase;Number.prototype上:toLocaleString;Date.prototype上:toLocaleString、toLocaleDateString、toLocaleTimeString)、実際の動作はほとんど実装依存です。本仕様は、追加機能、言語や動作の詳細の制御、必要な機能のより完全な仕様を提供します。

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

  1. サービスコンストラクタを直接使用してオブジェクトを構築し、優先言語リストと動作を構成するオプションを指定します。オブジェクトは主要な関数(compare、select、formatなど)を提供し、繰り返し呼び出すことができます。また、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)
%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値stringのASCII-uppercaseは、string内のASCII小文字コード単位(0x0061から0x007Aまで、両端を含む)の各出現を、対応するASCII大文字コード単位(0x0041から0x005Aまで、両端を含む)に置き換え、他のすべてのコード単位を保持することによりstringから導出されるString値である。

String値stringのASCII-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は、BがCodePointsToString(A)に対するASCII-case-insensitive matchである場合、Bに対するASCII-case-insensitive matchである。

6.2 言語タグ

この仕様では、ロケールを識別するために、Unicode 技術標準 #35 第 1 部 Core、3.3 節 BCP 47 適合性で定義されるUnicode BCP 47 ロケール識別子を使用し、そのアルゴリズムでは、3 節 Unicode 言語およびロケール識別子の文法で定義されるUnicode ロケール非終端記号を参照する。 このような識別子はそれぞれ言語タグとも呼ばれ、実際にBCP 47 のRFC 5646 の 2.1 節で使用される意味での整形式の言語タグである(ただし、その逆は成り立たない。"en-GB-oed"、"i-navajo"、"x-foo" のようなタグは BCP 47 に従えば有効だが、Unicode BCP 47 ロケール識別子ではない)。 Unicode 技術標準 #35 第 1 部 Core、3.2.1 節 正規 Unicode ロケール識別子で規定される正規形式のロケール識別子を「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. これは、locale が BCP 47 の langtag ABNF 非終端記号に一致し、ukey および tkey の重複に関する制約を除いて、unicode_bcp47_locale_id の整形式性制約に適合する整形式の言語タグであるかどうかを判定する。locale が意味のあるセマンティクスを持つかどうかは考慮せず、別名のサブタグとその推奨される置換サブタグを区別することも、正規の大文字・小文字の使用やサブタグの順序を要求することもない。 It performs the following steps when called:

  1. lowerLocaleをlocaleのASCII-lowercaseとする。
  2. lowerLocaleがunicode_locale_id Unicodeロケール非終端記号により一致させることができないならば、falseを返す。
  3. lowerLocaleがUnicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformanceで述べられる後方互換性構文のいずれかを使用するならば、falseを返す。
  4. baseNameをGetLocaleBaseName(lowerLocale)とする。
  5. variantsをGetLocaleVariants(baseName)とする。
  6. variantsがundefinedでないならば、
    1. variantsが重複サブタグを含むならば、falseを返す。
  7. extensionsをbaseNameの後に続くlowerLocaleの接尾部とする。
  8. NOTE: pu_extensions Unicodeロケール非終端記号により一致する"-x-…"私用サブタグ列は無視されなければならないが、後続内容を伴わない孤立した末尾の"x"サブタグは、以下の検査には影響しない。
  9. puIndexをStringIndexOf(extensions, "-x-", 0)とする。
  10. puIndexがnot-foundでないならば、extensionsをextensionsの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. tPrefixをtransformExtensionの3からの部分文字列とする。
    5. tlangを、tlang Unicodeロケール非終端記号により一致するtPrefixの最長の接頭部とする。そのような接頭部がない場合は、trueを返す。
    6. tlangVariantsをGetLocaleVariants(tlang)とする。
    7. tlangVariantsがundefinedでないならば、
      1. tlangVariantsが重複サブタグを含むならば、falseを返す。
  12. trueを返す。
Note
この「整形式の言語タグ」の定義と Unicode BCP 47 ロケール識別子の文法および整形式性制約との間には、微妙な違いがある。前者では ukey および tkey サブタグの重複が許可される(したがって、この操作には影響しない)が、後者では(あらゆる unicode_locale_id と同様に)許可されない。この違いは、CanonicalizeUnicodeLocaleId において、特定の ukey に対する最初の ufield 以外をすべて破棄することで解消される。

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. localeIdがUnicodeロケール拡張シーケンスであるsubstringを含むならば、
    1. extensionを、localeId内のUnicodeロケール拡張シーケンスのsubstringからなるString値とする。
    2. newExtensionを"-u"とする。
    3. componentsをUnicodeExtensionComponents(extension)とする。
    4. components.[[Attributes]]の各要素attrについて、次を行う:
      1. newExtensionをnewExtension、"-"、およびattrの文字列連結に設定する。
    5. components.[[Keywords]]の各Record { [[Key]], [[Value]] } keywordについて、次を行う:
      1. newExtensionをnewExtension、"-"、およびkeyword.[[Key]]の文字列連結に設定する。
      2. keyword.[[Value]]が空のStringでないならば、
        1. newExtensionをnewExtension、"-"、および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. normalizedをcurrencyのASCII-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 RecordのList. その結果は、この実装内のすべての利用可能な名前付きタイムゾーン識別子、および各利用可能な名前付きタイムゾーン識別子に対応する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. primaryをidentifierとする。
    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. primaryをzoneに設定する。
      3. そうでなければ、
        1. identifierCountryCodeを、identifierに対応する地理的領域を領土に含むISO 3166-1 Alpha-2国コードとする。
        2. zoneCountryCodeを、zoneに対応する地理的領域を領土に含むISO 3166-1 Alpha-2国コードとする。
        3. identifierCountryCodeがzoneCountryCodeであるならば、
          1. primaryをzoneに設定する。
        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. primaryをcountryCodeLineの“TZ”列の内容に設定する。
          3. そうでなければ、
            1. backzoneをundefinedとする。
            2. backzoneLinkLinesを、IANA Time Zone Databaseのファイルbackzone内で"Link "または"#PACKRATLIST zone.tab Link "のいずれかで始まる行のListとする。
            3. backzoneLinkLinesの各要素lineについて、次を行う:
              1. iをStringIndexOf(line, "Link ", 0)とする。
              2. lineをlineのi + 5からの部分文字列に設定する。
              3. backzoneAndLinkをStringSplitToList(line, " ")とする。
              4. Assert: backzoneAndLinkは少なくとも2つの要素を持ち、backzoneAndLink[0]とbackzoneAndLink[1]はいずれも利用可能な名前付きタイムゾーン識別子である。
              5. backzoneAndLink[1]がidentifierであるならば、
                1. Assert: backzoneはundefinedである。
                2. backzoneをbackzoneAndLink[0]に設定する。
            4. Assert: backzoneはundefinedでない。
            5. primaryをbackzoneに設定する。
    3. primaryが"Etc/UTC"、"Etc/GMT"、または"GMT"のいずれかならば、primaryを"UTC"に設定する。
    4. primaryがreplacement time zone identifierであり、そのrename waiting periodが終了していないならば、
      1. renamedIdentifierを、primaryが置き換えたrenamed time zone identifierとする。
      2. primaryをrenamedIdentifierに設定する。
    5. recordをTime Zone Identifier Record { [[Identifier]]: identifier, [[PrimaryIdentifier]]: primary }とする。
    6. recordをresultに追加する。
  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. recordsをAvailableNamedTimeZoneIdentifiers()とする。
  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. separatorLengthをseparatorの長さとする。
  4. substringsを新しい空のListとする。
  5. iを0とする。
  6. jをStringIndexOf(string, separator, 0)とする。
  7. jがnot-foundでない間、繰り返す:
    1. substringをstringのiからjまでの部分文字列とする。
    2. substringをsubstringsに追加する。
    3. iをj + separatorLengthに設定する。
    4. jをStringIndexOf(string, separator, i)に設定する。
  8. substringをstringのiからの部分文字列とする。
  9. substringをsubstringsに追加する。
  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. numeratorAndDenominatorをStringSplitToList(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. canonical を CanonicalizeUValue("ca", identifier) とする。
      2. identifier が canonical なら、
        1. identifier を list に追加する。
  3. そうでなく key が "collation" なら、
    1. list を AvailableCanonicalCollations( ) とする。
  4. そうでなく key が "currency" なら、
    1. list を AvailableCanonicalCurrencies( ) とする。
  5. そうでなく key が "numberingSystem" なら、
    1. list を AvailableCanonicalNumberingSystems( ) とする。
  6. そうでなく key が "timeZone" なら、
    1. list を AvailablePrimaryTimeZoneIdentifiers( ) とする。
  7. そうでなく key が "unit" なら、
    1. list を AvailableCanonicalUnits( ) とする。
  8. そうでなければ、
    1. RangeError 例外を投げる。
  9. CreateArrayFromList( list ) を返す。

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

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

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

言語優先順位リストは、優先順位の降順でロケールの選好の列を表す、整形式かつ正規化された言語タグの List である。これは、RFC 4647 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 DescriptorのListである。
  • [[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. localesがundefinedならば、
    1. 新しい空のListを返す。
  2. seenを新しい空のListとする。
  3. localesがStringである、またはlocalesがObjectであり、かつlocalesが[[InitializedLocale]]内部スロットを持つならば、
    1. localesObjをCreateArrayFromList(« locales »)とする。
  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. existsがtrueならば、
      1. elementを? Get(localesObj, propertyKey)とする。
      2. elementがStringでもObjectでもないならば、TypeError例外を投げる。
      3. elementがObjectであり、かつelementが[[InitializedLocale]]内部スロットを持つならば、
        1. tagをelement.[[Locale]]とする。
      4. そうでなければ、
        1. tagを? ToString(element)とする。
      5. IsWellFormedLanguageTag(tag)がfalseならば、RangeError例外を投げる。
      6. canonicalizedTagをCanonicalizeUnicodeLocaleId(tag)とする。
      7. seenがcanonicalizedTagを含まないならば、canonicalizedTagをseenに追加する。
    4. kをk + 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. lowerValueをuvalueのASCII-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 3.4 節の BCP 47 で定義されている lookup アルゴリズムを使用して、requestedLocales を満たすための availableLocales の最適な要素を決定する。デフォルトでない一致が見つかった場合、availableLocales から一致する言語タグを含む [[locale]] フィールドと、requestedLocales の対応する要素の Unicode ロケール拡張シーケンスを含む [[extension]] フィールド(要求された言語タグにそのようなシーケンスがない場合は empty)を持つ Record を返す。 It performs the following steps when called:

  1. requestedLocalesの各要素localeについて、次を行う:
    1. extensionをemptyとする。
    2. localeがUnicodeロケール拡張シーケンスを含むならば、
      1. extensionをlocaleのUnicodeロケール拡張シーケンスに設定する。
      2. localeを、任意のUnicodeロケール拡張シーケンスが削除されたlocaleであるString値に設定する。
    3. prefixをlocaleとする。
    4. prefixが空のStringでない間、繰り返す:
      1. availableLocalesがprefixを含むならば、Record { [[locale]]: prefix, [[extension]]: extension }を返す。
      2. prefixが"-"(コード単位0x002D HYPHEN-MINUS)を含むならばposをprefix内の"-"の最後の出現のインデックスとし、そうでなければposを0とする。
      3. pos ≥ 2であり、かつprefixのpos - 2からpos - 1までの部分文字列が"-"である間、繰り返す:
        1. posをpos - 2に設定する。
      4. prefixをprefixの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と、一意なキーを持つkeywordのListへ分解する。属性またはkeywordキーの最初以降の反復出現はすべて無視される。 It performs the following steps when called:

  1. Assert: extension の ASCII-lowercase は extension である。
  2. Assert: extension の 0 から 3 までの部分文字列は "-u-" である。
  3. attributes を新しい空の List とする。
  4. keywords を新しい空の List とする。
  5. keyword を undefined とする。
  6. size を extension の長さとする。
  7. k を 3 とする。
  8. k < size の間、繰り返す。
    1. e を StringIndexOf(extension, "-", k) とする。
    2. e が not-found なら length を size - k とする。そうでなければ length を e - k とする。
    3. subtag を extension の k から k + length までの部分文字列とする。
    4. NOTE: keyword は、一連のサブタグであり、その最初のものは長さ 2 の key で、後続するものがあれば長さが 3 から 8 までの閉区間内にあり、それらは間にある "-" 区切りとともに collectively value を構成する。attribute は、すべての keywords に先行する、長さが 3 から 8 までの閉区間内にある単一のサブタグである。
    5. Assert: length ≥ 2 である。
    6. keyword が undefined で、かつ length ≠ 2 なら、
      1. subtag が attributes の要素でないなら、subtag を attributes に追加する。
    7. そうでなく length = 2 なら、
      1. keyword を Record { [[Key]]: subtag, [[Value]]: 空の String } に設定する。
      2. keywords が [[Key]] が keyword.[[Key]] である要素を含まないなら、keyword を keywords に追加する。
    8. そうでなく keyword.[[Value]] が空の String なら、
      1. keyword.[[Value]] を subtag に設定する。
    9. そうでなければ、
      1. keyword.[[Value]] を keyword.[[Value]]、"-"、および subtag の文字列連結に設定する。
    10. k を k + 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 (RecordのList) and returns Unicode正規化済みロケール識別子. attributesおよびkeywordsをUnicodeロケール拡張シーケンスとしてlocaleへ組み込み、正規化された結果を返す。 It performs the following steps when called:

  1. Assert: localeはUnicodeロケール拡張シーケンスを含まない。
  2. extensionを"-u"とする。
  3. attributesの各要素attrについて、次を行う:
    1. extensionをextension、"-"、およびattrの文字列連結に設定する。
  4. keywordsの各Record { [[Key]], [[Value]] } keywordについて、次を行う:
    1. extensionをextension、"-"、およびkeyword.[[Key]]の文字列連結に設定する。
    2. keyword.[[Value]]が空のStringでないならば、extensionをextension、"-"、およびkeyword.[[Value]]の文字列連結に設定する。
  5. extensionが"-u"ならば、CanonicalizeUnicodeLocaleId(locale)を返す。
  6. privateIndexをStringIndexOf(locale, "-x-", 0)とする。
  7. privateIndexがnot-foundならば、
    1. newLocaleをlocaleとextensionの文字列連結とする。
  8. そうでなければ、
    1. preExtensionをlocaleの0からprivateIndexまでの部分文字列とする。
    2. postExtensionをlocaleのprivateIndexからの部分文字列とする。
    3. newLocaleをpreExtension、extension、および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), and relevantExtensionKeys (StringのList) and optional argument localeData (Record) and returns Record. これは、RFC 4647 3 節の BCP 47 で定義されている「lookup」を実行し、Unicode ロケール拡張シーケンスを無視して、options.[[localeMatcher]] で指定された LookupMatchingLocaleByBestFit アルゴリズムまたは LookupMatchingLocaleByPrefix アルゴリズムのいずれかを使用して、requestedLocales を満たすための availableLocales の最適な要素を決定し、さらに localeData からの対応するデータと relevantExtensionKeys の各要素について解決された値(デフォルトでは一致したロケールのデータを使用し、要求された Unicode ロケール拡張シーケンスが存在する場合はそのデータで、さらに options にデータが存在する場合はそのデータで上書きされる)も含む一致の表現を返す。requestedLocales から一致した要素に Unicode ロケール拡張シーケンスが含まれている場合、それは返される Record の [[Locale]] フィールド内の言語タグにコピーされるが、その key 値が relevantExtensionKeys に含まれていないか、またはその type 値が options の異なる値によって上書きされる keyword Unicode ロケール非終端記号は省略される。 It performs the following steps when called:

  1. matcher を options.[[localeMatcher]] とする。
  2. matcher が "lookup" の場合、
    1. match を LookupMatchingLocaleByPrefix(availableLocales, requestedLocales) とする。
  3. そうでない場合、
    1. match を LookupMatchingLocaleByBestFit(availableLocales, requestedLocales) とする。
  4. match が undefined の場合、match を Record { [[locale]]: DefaultLocale(), [[extension]]: empty } に設定する。
  5. foundLocale を match.[[locale]] とする。
  6. result を新しい Record とする。
  7. localeData が存在しない場合、
    1. Assert: relevantExtensionKeys は空の List である。
    2. result.[[LocaleData]] を undefined に設定する。
  8. そうでない場合、
    1. foundLocaleData を localeData.[[<foundLocale>]] とする。
    2. Assert: foundLocaleData は Record である。
    3. result.[[LocaleData]] を foundLocaleData に設定する。
  9. match.[[extension]] が empty でない場合、
    1. components を UnicodeExtensionComponents(match.[[extension]]) とする。
    2. keywords を components.[[Keywords]] とする。
  10. そうでない場合、
    1. keywords を新しい空の List とする。
  11. supportedKeywords を新しい空の List とする。
  12. relevantExtensionKeys の各要素 key について、次を行う。
    1. keyLocaleData を foundLocaleData.[[<key>]] とする。
    2. Assert: keyLocaleData は List である。
    3. value を keyLocaleData[0] とする。
    4. Assert: value は String または null である。
    5. supportedKeyword を empty とする。
    6. keywords に [[Key]] が key である要素が含まれる場合、
      1. entry を [[Key]] が key である keywords の要素とする。
      2. requestedValue を entry.[[Value]] とする。
      3. requestedValue が空の String でない場合、
        1. keyLocaleData に requestedValue が含まれる場合、
          1. value を requestedValue に設定する。
          2. supportedKeyword を Record { [[Key]]: key, [[Value]]: value } に設定する。
      4. そうではなく keyLocaleData に "true" が含まれる場合、
        1. value を "true" に設定する。
        2. supportedKeyword を Record { [[Key]]: key, [[Value]]: 空の String } に設定する。
    7. Assert: options はフィールド [[<key>]] を持つ。
    8. optionsValue を options.[[<key>]] とする。
    9. Assert: optionsValue は String、または undefined か null のいずれかである。
    10. optionsValue が String の場合、
      1. ukey を key の ASCII 小文字化結果とする。
      2. optionsValue を CanonicalizeUValue(ukey, optionsValue) に設定する。
      3. optionsValue が空の String の場合、
        1. optionsValue を "true" に設定する。
    11. SameValue(optionsValue, value) が false であり、keyLocaleData に optionsValue が含まれる場合、
      1. value を optionsValue に設定する。
      2. supportedKeyword を empty に設定する。
    12. supportedKeyword が empty でない場合、supportedKeyword を supportedKeywords に追加する。
    13. result.[[<key>]] を value に設定する。
  13. supportedKeywords が空でない場合、
    1. supportedAttributes を新しい空の List とする。
    2. foundLocale を InsertUnicodeExtensionAndCanonicalize(foundLocale, supportedAttributes, supportedKeywords) に設定する。
  14. result.[[Locale]] を foundLocale に設定する。
  15. 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 (enumのList) 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 を含み、かつ options が undefined の場合、TypeError 例外をスローする。
  3. specialBehaviours が存在し、coerce-options を含む場合、options を ? CoerceOptionsToObject(options) に設定する。それ以外の場合、options を ? GetOptionsObject(options) に設定する。
  4. matcher を ? GetOption(options, "localeMatcher", string, « "lookup", "best fit" », "best fit") とする。
  5. opt を Record { [[localeMatcher]]: matcher } とする。
  6. ctor.[[ResolutionOptionDescriptors]] の各 Resolution Option Descriptor desc について、次を行う。
    1. desc に [[Type]] フィールドがある場合、type を desc.[[Type]] とする。それ以外の場合、type を string とする。
    2. desc に [[Values]] フィールドがある場合、values を desc.[[Values]] とする。それ以外の場合、values を empty とする。
    3. value を ? GetOption(options, desc.[[Property]], type, values, undefined) とする。
    4. value が undefined でない場合、
      1. value を ! ToString(value) に設定する。
      2. value が type Unicode ロケール非終端記号に一致しない場合、RangeError 例外をスローする。
    5. key を desc.[[Key]] とする。
    6. opt.[[<key>]] を value に設定する。
  7. modifyResolutionOptions が存在する場合、! modifyResolutionOptions(opt) を実行する。
  8. resolution を ResolveLocale(ctor.[[AvailableLocales]], requestedLocales, opt, ctor.[[RelevantExtensionKeys]], localeData) とする。
  9. Assert: resolution.[[LocaleData]] は Record である。
  10. 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 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. matchをLookupMatchingLocaleByPrefix(availableLocales, « locale »)とする。
    2. そうでなければ、
      1. matchをLookupMatchingLocaleByBestFit(availableLocales, « locale »)とする。
    3. matchがundefinedでないならば、localeをsubsetに追加する。
  5. CreateArrayFromList(subset)を返す。

9.2.10 CoerceOptionsToObject ( options )

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

  1. optionsがundefinedならば、
    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へ変換し、valuesがemptyでない場合にその値がvaluesによって許可されるかを検査し、値がundefinedである場合はdefaultを代入する。 It performs the following steps when called:

  1. valueを? Get(options, propertyKey)とする。
  2. valueがundefinedならば、
    1. defaultがrequiredならば、TypeError例外を投げる。
    2. defaultを返す。
  3. typeがbooleanならば、
    1. valueをToBoolean(value)に設定する。
  4. そうでなければ、
    1. Assert: typeはstringである。
    2. valueを? ToString(value)に設定する。
  5. valuesがemptyでなく、かつvaluesがvalueを含まないならば、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. valueがundefinedならば、fallbackを返す。
  3. valueがtrueならば、trueを返す。
  4. ToBoolean(value)がfalseならば、falseを返す。
  5. valueを? ToString(value)に設定する。
  6. stringValuesがvalueを含まないならば、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. valueがundefinedならば、fallbackを返す。
  2. valueを? ToNumber(value)に設定する。
  3. value が有限の Number でない場合、または ℝ(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)を持つRecordのList. [[Value]]フィールドは、[[Type]]が"literal"である場合はString値となり、そうでない場合はundefinedとなる。 It performs the following steps when called:

  1. resultを新しい空のListとする。
  2. placeholderEndを-1とする。
  3. placeholderStartをStringIndexOf(pattern, "{", 0)とする。
  4. placeholderStartがnot-foundでない間、繰り返す:
    1. literalをpatternのplaceholderEnd + 1からplaceholderStartまでの部分文字列とする。
    2. literalが空のStringでないならば、
      1. Record { [[Type]]: "literal", [[Value]]: literal }をresultに追加する。
    3. placeholderEndをStringIndexOf(pattern, "}", placeholderStart)に設定する。
    4. Assert: placeholderEndはnot-foundでなく、かつplaceholderStart < placeholderEndである。
    5. placeholderNameをpatternのplaceholderStart + 1からplaceholderEndまでの部分文字列とする。
    6. Record { [[Type]]: placeholderName, [[Value]]: undefined }をresultに追加する。
    7. placeholderStartをStringIndexOf(pattern, "{", placeholderEnd)に設定する。
  5. tailをpatternのplaceholderEnd + 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 関数がオプション引数 locales と options で呼び出された場合、次の手順を実行する:

  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. resolvedLocale を optionsResolution.[[ResolvedLocale]] とする。
  15. collator.[[Locale]] に resolvedLocale .[[Locale]] を設定する。
  16. resolvedLocale .[[co]] が null なら collation を "default" とし、そうでなければ collation を resolvedLocale .[[co]] とする。
  17. collator.[[Collation]] に collation を設定する。
  18. collator.[[Numeric]] に SameValue(resolvedLocale .[[kn]], "true") を設定する。
  19. collator.[[CaseFirst]] に resolvedLocale .[[kf]] を設定する。
  20. resolvedLocaleData を resolvedLocale .[[LocaleData]] とする。
  21. usage が "sort" なら defaultSensitivity を "variant" とし、そうでなければ defaultSensitivity を resolvedLocaleData.[[sensitivity]] とする。
  22. collator.[[Sensitivity]] に ? GetOption(options, "sensitivity", string, « "base", "accent", "case", "variant" », defaultSensitivity) を設定する。
  23. defaultIgnorePunctuation を resolvedLocaleData.[[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 メソッドが locales と options を引数に呼び出された場合、次の手順を実行する:

  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. collator を this 値とする。
  2. ? RequireInternalSlot(collator, [[InitializedCollator]]) を実行する。
  3. options を OrdinaryObjectCreate(%Object.prototype%) とする。
  4. Table 3 の各行(ヘッダー行を除く)について、テーブル順に次を行う
  5. propertyKey を現在の行の Property 値とする。
  6. value を collator の内部スロットのうち、現在の行の Internal Slot 値の名前を持つものの値とする。
  7. 現在の行に Extension Key 値がある場合、
  8. extensionKey を現在の行の Extension Key 値とする。
  9. %Intl.Collator%.[[RelevantExtensionKeys]] が extensionKey を含まない場合、
  10. value を undefined に設定する。
  11. value が undefined でない場合、
  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. collator を this 値とする。
  2. ? RequireInternalSlot(collator, [[InitializedCollator]]) を実行する。
  3. collator.[[BoundCompare]] が undefined である場合、次の手順を実行する。
    1. closure を、collator をキャプチャし、呼び出されたときに次の手順を実行する、パラメーター (x, y) を持つ新しい抽象クロージャーとする:
      1. xString を ? ToString(x) とする。
      2. yString を ? ToString(y) とする。
      3. CompareStrings(collator, xString, yString) を返す。
    2. collator.[[BoundCompare]] を CreateBuiltinFunction(closure, 2, "", « ») に設定する。
  4. collator.[[BoundCompare]] を返す。
Note
返される関数は、Array.prototype.sort やその他の関数に直接渡せるように collator に束縛されている。 これは、新しい機能ではもはや従われていない慣例の一部として歴史的な名残と見なされているが、既存のプログラムとの互換性を維持するために保持されている。

10.3.3.1 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. 返される数値は x と y の実装依存のロケール感度の文字列比較結果を表す。 この結果は、collator の有効なロケールと照合オプションに従った文字列値の並び順に対応することを意図しており、x が y より前の場合は負、後の場合は正、その他の場合はゼロ(相対的な順序なし)となる。 文字列値は 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 について、x と y の関数として一貫した比較器となり、すべての文字列集合に対して全順序を定義することが要求される。また、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. this を this 値とする。
    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. newTarget が undefined で、かつ ? 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 (date、time、または any), and defaults (date、time、または 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. specialOptions を Record { [[Hour12]]: undefined } とする。
  3. modifyResolutionOptions を、specialOptions をキャプチャし、パラメータ (options) を持つ新しい抽象クロージャとし、呼び出されたときに次の手順を実行するものとする。
    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. hour12 を specialOptions.[[Hour12]] とする。
  6. options を optionsResolution.[[Options]] に設定する。
  7. resolvedLocale を optionsResolution.[[ResolvedLocale]] とする。
  8. dateTimeFormat.[[Locale]] を resolvedLocale.[[Locale]] に設定する。
  9. resolvedCalendar を resolvedLocale.[[ca]] とする。
  10. dateTimeFormat.[[Calendar]] を resolvedCalendar に設定する。
  11. dateTimeFormat.[[NumberingSystem]] を resolvedLocale.[[nu]] に設定する。
  12. resolvedLocaleData を resolvedLocale.[[LocaleData]] とする。
  13. hc を resolvedLocale.[[hc]] とする。
  14. hour12 が true の場合、
    1. hc を resolvedLocaleData.[[hourCycle12]] に設定する。
  15. そうではなく hour12 が false の場合、
    1. hc を resolvedLocaleData.[[hourCycle24]] に設定する。
  16. そうではなく hc が null の場合、
    1. hc を resolvedLocaleData.[[hourCycle]] に設定する。
  17. timeZone を ? GetOption(options, "timeZone", string, empty, SystemTimeZoneIdentifier()) とする。
  18. IsTimeZoneOffsetString(timeZone) が true の場合、
    1. parseResult を ParseText(StringToCodePoints(timeZone), UTCOffset) とする。
    2. Assert: parseResult は Parse Node である。
    3. parseResult に複数の MinuteSecond Parse Node が含まれる場合、RangeError 例外をスローする。
    4. offsetNanoseconds を ParseTimeZoneOffsetString(timeZone) とする。
    5. offsetMinutes を offsetNanoseconds / (6 × 1010) とする。
    6. Assert: offsetMinutes は整数である。
    7. timeZone を FormatOffsetTimeZoneIdentifier(offsetMinutes) に設定する。
  19. そうでない場合、
    1. timeZoneIdentifierRecord を GetAvailableNamedTimeZoneIdentifier(timeZone) とする。
    2. timeZoneIdentifierRecord が empty の場合、RangeError 例外をスローする。
    3. timeZone を timeZoneIdentifierRecord.[[PrimaryIdentifier]] に設定する。
  20. dateTimeFormat.[[TimeZone]] を timeZone に設定する。
  21. formatOptions を新しい Record とする。
  22. formatOptions.[[hourCycle]] を hc に設定する。
  23. hasExplicitFormatComponents を false とする。
  24. 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. value が undefined でない場合、hasExplicitFormatComponents を true に設定する。
  25. formatMatcher を ? GetOption(options, "formatMatcher", string, « "basic", "best fit" », "best fit") とする。
  26. dateStyle を ? GetOption(options, "dateStyle", string, « "full", "long", "medium", "short" », undefined) とする。
  27. dateTimeFormat.[[DateStyle]] を dateStyle に設定する。
  28. timeStyle を ? GetOption(options, "timeStyle", string, « "full", "long", "medium", "short" », undefined) とする。
  29. dateTimeFormat.[[TimeStyle]] を timeStyle に設定する。
  30. dateStyle が undefined でない、または timeStyle が undefined でない場合、
    1. hasExplicitFormatComponents が true の場合、TypeError 例外をスローする。
    2. required が date で、timeStyle が undefined でない場合、TypeError 例外をスローする。
    3. required が time で、dateStyle が undefined でない場合、TypeError 例外をスローする。
    4. styles を resolvedLocaleData.[[styles]].[[<resolvedCalendar>]] とする。
    5. bestFormat を DateTimeStyleFormat(dateStyle, timeStyle, styles) とする。
  31. そうでない場合、
    1. needDefaults を true とする。
    2. propertyKeys を新しい空の List とする。
    3. required が date または any の場合、propertyKeys を propertyKeys と « "weekday", "year", "month", "day" » のリスト連結に設定する。
    4. required が time または any の場合、propertyKeys を propertyKeys と « "dayPeriod", "hour", "minute", "second", "fractionalSecondDigits" » のリスト連結に設定する。
    5. propertyKeys の各プロパティ名 propertyKey について、次を行う。
      1. value を formatOptions.[[<propertyKey>]] とする。
      2. value が undefined でない場合、needDefaults を false に設定する。
    6. needDefaults が true の場合、
      1. numericProperties を新しい空の List とする。
      2. defaults が date または all のいずれかである場合、numericProperties を numericProperties と « "year", "month", "day" » のリスト連結に設定する。
      3. defaults が time または all のいずれかである場合、numericProperties を numericProperties と « "hour", "minute", "second" » のリスト連結に設定する。
      4. numericProperties の各プロパティ名 propertyKey について、次を行う。
        1. formatOptions.[[<propertyKey>]] を "numeric" に設定する。
    7. formats を resolvedLocaleData.[[formats]].[[<resolvedCalendar>]] とする。
    8. formatMatcher が "basic" の場合、bestFormat を BasicFormatMatcher(formatOptions, formats) とし、それ以外の場合、bestFormat を BestFitFormatMatcher(formatOptions, formats) とする。
  32. dateTimeFormat.[[DateTimeFormat]] を bestFormat に設定する。
  33. bestFormat がフィールド [[hour]] を持つ場合、dateTimeFormat.[[HourCycle]] を hc に設定する。
  34. 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. absoluteMinutes を abs(offsetMinutes) とする。
  3. hours を floor(absoluteMinutes / 60) とする。
  4. minutes を absoluteMinutes modulo 60 とする。
  5. sign、ToZeroPaddedDecimalString(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 Records の List でなければならない。そのような 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 Records の List 各レコードは範囲パターンの一部を表す。

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. dtf を this 値とする。
  2. 実装が 4.3 Note 1 の規範的任意コンストラクターモードをサポートするなら、
    1. dtf を ? UnwrapDateTimeFormat(dtf) に設定する。
  3. ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]) を実行する。
  4. options を OrdinaryObjectCreate(%Object.prototype%) とする。
  5. Table 15 の各行について、ヘッダー行を除き、表の順序で、次を行う。
    1. propertyKey を現在の行の Property 値とする。
    2. 現在の行に Internal Slot 値があるなら、
      1. value を、現在の行の Internal Slot 値を名前とする dtf の内部スロットの値とする。
    3. そうでなければ、
      1. format を dtf.[[DateTimeFormat]] とする。
      2. format がフィールド [[<propertyKey>]] を持ち、かつ dtf.[[DateStyle]] が undefined で、かつ dtf.[[TimeStyle]] が undefined なら、
        1. value を format.[[<propertyKey>]] とする。
      3. そうでなければ、
        1. value を undefined とする。
    4. value が undefined でないなら、
      1. 現在の行に Conversion 値があるなら、
        1. conversion を現在の行の Conversion 値とする。
        2. conversion が hour12 なら、
          1. value が "h11" または "h12" なら、value を true に設定する。そうでなければ、value を false に設定する。
        3. そうでなければ、
          1. Assert: conversion は number である。
          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. dtf を this 値とする。
  2. 実装が 4.3 Note 1 の規範的な任意のコンストラクターモードをサポートする場合、次を実行する。
    1. dtf を ? UnwrapDateTimeFormat(dtf) に設定する。
  3. ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]) を実行する。
  4. dtf.[[BoundFormat]] が undefined である場合、次を実行する。
    1. closure を、dtf をキャプチャし、呼び出されたときに次の手順を実行する、パラメーター (date) を持つ新しい抽象クロージャーとする:
      1. date が undefined である場合、x を ! Call(%Date.now%, undefined) とする。それ以外の場合、x を ? ToNumber(date) とする。
      2. ? FormatDateTime(dtf, x) を返す。
    2. dtf.[[BoundFormat]] を CreateBuiltinFunction(closure, 1, "", « ») に設定する。
  5. dtf.[[BoundFormat]] を返す。
Note
返される関数は dtf に束縛されているため、Array.prototype.map または他の関数に直接渡すことができる。 これは、もはや新機能では従われない慣例の一部として歴史的な遺物と見なされるが、既存のプログラムとの互換性を維持するために保存されている。

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

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

  1. dtf を this 値とする。
  2. ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]) を実行する。
  3. startDate が undefined または endDate が undefined なら、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. dtf を this 値とする。
  2. ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]) を実行する。
  3. startDate が undefined または endDate が undefined なら、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. dtf を this 値とする。
  2. ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]) を実行する。
  3. date が undefined なら、
    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 Records の List) 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. bestFormat を undefined とする。
  10. formats の各要素 format について、次を行う。
    1. score を 0 とする。
    2. Table 16 の各行について、ヘッダー行を除き、表の順序で、次を行う。
      1. property を現在の行の Property 列で与えられた名前とする。
      2. options がフィールド [[<property>]] を持つなら、optionsProp を options.[[<property>]] とする。そうでなければ optionsProp を undefined とする。
      3. format がフィールド [[<property>]] を持つなら、formatProp を format.[[<property>]] とする。そうでなければ formatProp を undefined とする。
      4. optionsProp が undefined で、かつ formatProp が undefined でないなら、
        1. score を score - additionPenalty に設定する。
      5. そうでなく optionsProp が undefined でなく、かつ formatProp が undefined なら、
        1. score を score - removalPenalty に設定する。
      6. そうでなく property が "timeZoneName" なら、
        1. optionsProp が "short" または "shortGeneric" なら、
          1. formatProp が "shortOffset" なら、score を score - offsetPenalty に設定する。
          2. そうでなく formatProp が "longOffset" なら、score を score - (offsetPenalty + shortMorePenalty) に設定する。
          3. そうでなく optionsProp が "short" で、かつ formatProp が "long" なら、score を score - shortMorePenalty に設定する。
          4. そうでなく optionsProp が "shortGeneric" で、かつ formatProp が "longGeneric" なら、score を score - shortMorePenalty に設定する。
          5. そうでなく optionsProp ≠ formatProp なら、score を score - removalPenalty に設定する。
        2. そうでなく optionsProp が "shortOffset" で、かつ formatProp が "longOffset" なら、
          1. score を score - shortMorePenalty に設定する。
        3. そうでなく optionsProp が "long" または "longGeneric" なら、
          1. formatProp が "longOffset" なら、score を score - offsetPenalty に設定する。
          2. そうでなく formatProp が "shortOffset" なら、score を score - (offsetPenalty + longLessPenalty) に設定する。
          3. そうでなく optionsProp が "long" で、かつ formatProp が "short" なら、score を score - longLessPenalty に設定する。
          4. そうでなく optionsProp が "longGeneric" で、かつ formatProp が "shortGeneric" なら、score を score - longLessPenalty に設定する。
          5. そうでなく optionsProp ≠ formatProp なら、score を score - removalPenalty に設定する。
        4. そうでなく optionsProp が "longOffset" で、かつ formatProp が "shortOffset" なら、
          1. score を score - longLessPenalty に設定する。
        5. そうでなく optionsProp ≠ formatProp なら、
          1. score を score - removalPenalty に設定する。
      7. そうでなく optionsProp ≠ formatProp なら、
        1. property が "fractionalSecondDigits" なら、
          1. values を « 1, 2, 3 » とする。
        2. そうでなければ、
          1. values を « "2-digit", "numeric", "narrow", "short", "long" » とする。
        3. optionsPropIndex を values 内の optionsProp のインデックスとする。
        4. formatPropIndex を values 内の formatProp のインデックスとする。
        5. delta を max(min(formatPropIndex - optionsPropIndex, 2), -2) とする。
        6. delta = 2 なら、score を score - longMorePenalty に設定する。
        7. そうでなく delta = 1 なら、score を score - shortMorePenalty に設定する。
        8. そうでなく delta = -1 なら、score を score - shortLessPenalty に設定する。
        9. そうでなく delta = -2 なら、score を score - longLessPenalty に設定する。
    3. score > bestScore なら、
      1. bestScore を score に設定する。
      2. bestFormat を format に設定する。
  11. bestFormat を返す。

11.5.3 BestFitFormatMatcher ( options, formats )

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

11.5.4 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) を持つ Records の List. pattern に従い、また dateTimeFormat および format の実効ロケールと整形オプションに従って、エポック時刻 epochNanoseconds に対応する parts を作成する。 It performs the following steps when called:

  1. locale を dateTimeFormat.[[Locale]] とする。
  2. nfOptions を OrdinaryObjectCreate(null) とする。
  3. ! CreateDataPropertyOrThrow(nfOptions, "numberingSystem", dateTimeFormat.[[NumberingSystem]]) を実行する。
  4. ! CreateDataPropertyOrThrow(nfOptions, "useGrouping", false) を実行する。
  5. nf を ! Construct(%Intl.NumberFormat%, « locale, nfOptions ») とする。
  6. nf2Options を OrdinaryObjectCreate(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. fractionalSecondDigits を format.[[fractionalSecondDigits]] とする。
    2. nf3Options を OrdinaryObjectCreate(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. localTime を ToLocalTime(epochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]]) とする。
  13. patternParts を PartitionPattern(pattern) とする。
  14. result を新しい空の List とする。
  15. patternParts の各 Record { [[Type]], [[Value]] } patternPart について、次を行う。
    1. partType を patternPart.[[Type]] とする。
    2. partType が "literal" なら、
      1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] } を result に追加する。
    3. そうでなく partType が "fractionalSecondDigits" なら、
      1. Assert: format はフィールド [[fractionalSecondDigits]] を持つ。
      2. value を localTime.[[Millisecond]] とする。
      3. value を floor(value × 10( fractionalSecondDigits - 3 )) に設定する。
      4. formattedValue を FormatNumeric(nf3, value) とする。
      5. Record { [[Type]]: "fractionalSecond", [[Value]]: formattedValue } を result に追加する。
    4. そうでなく partType が "dayPeriod" なら、
      1. Assert: format はフィールド [[dayPeriod]] を持つ。
      2. fieldFormat を format.[[dayPeriod]] とする。
      3. formattedValue を、fieldFormat によって与えられる形式の localTime の day period を表す ILD String とする。
      4. Record { [[Type]]: partType, [[Value]]: formattedValue } を result に追加する。
    5. そうでなく partType が "timeZoneName" なら、
      1. Assert: format はフィールド [[timeZoneName]] を持つ。
      2. fieldFormat を format.[[timeZoneName]] とする。
      3. value を dateTimeFormat.[[TimeZone]] とする。
      4. formattedValue を、fieldFormat によって与えられる形式の value を表す ILD String とする。その値は、fieldFormat が "short"、"long"、"shortOffset"、または "longOffset" である場合、localTime の [[InDST]] フィールドの値に依存してよい。実装がそのような fieldFormat のローカライズ表現を持たない場合は、value 自体を使用する。
      5. Record { [[Type]]: partType, [[Value]]: formattedValue } を result に追加する。
    6. そうでなく partType が Table 16 の行の Property 列に一致するなら、
      1. Assert: format はフィールド [[<partType>]] を持つ。
      2. fieldFormat を format.[[<partType>]] とする。
      3. value を、一致する行の Internal Slot 列を名前とする localTime のフィールドの値とする。
      4. partType が "year" で、かつ value ≤ 0 なら、value を 1 - value に設定する。
      5. partType が "month" なら、value を value + 1 に設定する。
      6. partType が "hour" で、かつ dateTimeFormat.[[HourCycle]] が "h11" または "h12" なら、
        1. value を value 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. formattedValue を FormatNumeric(nf, value) とする。
      9. そうでなく fieldFormat が "2-digit" なら、
        1. formattedValue を FormatNumeric(nf2, value) とする。
        2. codePoints を StringToCodePoints(formattedValue) とする。
        3. count を codePoints 内の要素数とする。
        4. count > 2 なら、
          1. tens を codePoints[count - 2] とする。
          2. ones を codePoints[count - 1] とする。
          3. formattedValue を CodePointsToString(« tens, 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. value を localTime.[[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. value を localTime.[[RelatedYear]] とする。
      2. formattedValue を FormatNumeric(nf, value) とする。
      3. Record { [[Type]]: "relatedYear", [[Value]]: formattedValue } を result に追加する。
    9. そうでなく partType が "yearName" なら、
      1. value を localTime.[[YearName]] とする。
      2. formattedValue を value を表す ILD String とする。
      3. Record { [[Type]]: "yearName", [[Value]]: formattedValue } を result に追加する。
    10. そうでなければ、
      1. unknown を epochNanoseconds および 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.5 PartitionDateTimePattern ( dateTimeFormat, x )

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

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

11.5.6 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. result を result と part.[[Value]] の文字列連結に設定する。
  4. result を返す。

11.5.7 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. partObj を OrdinaryObjectCreate(%Object.prototype%) とする。
    2. ! CreateDataPropertyOrThrow(partObj, "type", part.[[Type]]) を実行する。
    3. ! CreateDataPropertyOrThrow(partObj, "value", part.[[Value]]) を実行する。
    4. ! CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), partObj) を実行する。
    5. n を n + 1 に設定する。
  5. result を返す。

11.5.8 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) を持つ Records の List を含む正常完了、または throw 完了. x および y を ECMA-262、21.4.1.1 で規定される時刻値として解釈し、dateTimeFormat の実効ロケールおよび整形オプションに従って、対応する parts を作成する。 It performs the following steps when called:

  1. x を TimeClip(x) に設定する。
  2. x が NaN なら、RangeError 例外を投げる。
  3. y を TimeClip(y) に設定する。
  4. y が NaN なら、RangeError 例外を投げる。
  5. xEpochNanoseconds を ℤ(ℝ(x) × 106) とする。
  6. yEpochNanoseconds を ℤ(ℝ(y) × 106) とする。
  7. localTime1 を ToLocalTime(xEpochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]]) とする。
  8. localTime2 を ToLocalTime(yEpochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]]) とする。
  9. format を dateTimeFormat.[[DateTimeFormat]] とする。
  10. dateTimeFormat.[[HourCycle]] が "h11" または "h12" なら、
    1. pattern を format.[[pattern12]] とする。
    2. rangePatterns を format.[[rangePatterns12]] とする。
  11. そうでなければ、
    1. pattern を format.[[pattern]] とする。
    2. rangePatterns を format.[[rangePatterns]] とする。
  12. selectedRangePattern を undefined とする。
  13. relevantFieldsEqual を true とする。
  14. checkMoreFields を true とする。
  15. Table 6 の各行について、ヘッダー行を除き、表の順序で、次を行う。
    1. fieldName をその行の Field Name 列で与えられた名前とする。
    2. rangePatterns が名前 fieldName のフィールドを持つなら、rangePattern を rangePatterns の名前 fieldName のフィールドとする。そうでなければ rangePattern を undefined とする。
    3. selectedRangePattern が undefined でなく、かつ rangePattern が undefined なら、
      1. NOTE: このフィールド以下の差異についての範囲パターンが存在しないため、それ以上のチェックは実行されない。
      2. checkMoreFields を false に設定する。
    4. fieldName が [[Default]] と等しくなく、かつ relevantFieldsEqual が true で、かつ checkMoreFields が true なら、
      1. selectedRangePattern を rangePattern に設定する。
      2. fieldName が [[AmPm]] なら、
        1. localTime1.[[Hour]] が 12 未満なら、v1 を "am" とする。そうでなければ v1 を "pm" とする。
        2. localTime2.[[Hour]] が 12 未満なら、v2 を "am" とする。そうでなければ v2 を "pm" とする。
      3. そうでなく fieldName が [[DayPeriod]] なら、
        1. v1 を localTime1 の day period を表す ILD String とする。
        2. v2 を localTime2 の day period を表す ILD String とする。
      4. そうでなく fieldName が [[FractionalSecondDigits]] なら、
        1. format が [[fractionalSecondDigits]] フィールドを持つなら、
          1. fractionalSecondDigits を format.[[fractionalSecondDigits]] とする。
        2. そうでなければ、
          1. fractionalSecondDigits を 3 とする。
        3. exp を fractionalSecondDigits - 3 とする。
        4. v1 を floor(localTime1.[[Millisecond]] × 10exp) とする。
        5. v2 を floor(localTime2.[[Millisecond]] × 10exp) とする。
      5. そうでなければ、
        1. v1 を fieldName を名前とする localTime1 のフィールドとする。
        2. v2 を fieldName を名前とする localTime2 のフィールドとする。
      6. v1 が v2 と等しくないなら、
        1. relevantFieldsEqual を false に設定する。
  16. relevantFieldsEqual が true なら、
    1. collapsedResult を新しい空の List とする。
    2. resultParts を FormatDateTimePattern(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. selectedRangePattern が undefined なら、
    1. selectedRangePattern を rangePatterns.[[Default]] に設定する。
  19. selectedRangePattern.[[PatternParts]] の各 Record { [[Pattern]], [[Source]] } rangePatternPart について、次を行う。
    1. pattern を rangePatternPart.[[Pattern]] とする。
    2. source を rangePatternPart.[[Source]] とする。
    3. source が "startRange" または "shared" なら、
      1. z を xEpochNanoseconds とする。
    4. そうでなければ、
      1. z を yEpochNanoseconds とする。
    5. resultParts を FormatDateTimePattern(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.9 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. result を result と part.[[Value]] の文字列連結に設定する。
  4. result を返す。

11.5.10 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. partObj を OrdinaryObjectCreate(%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. n を n + 1 に設定する。
  5. result を返す。

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

11.5.12 ToLocalTime Records

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

Table 17: ToLocalTime によって返される Record
フィールド名 値の型 グレゴリオ暦における値の計算
[[Weekday]] 整数 ℝ(WeekDay(𝔽(floor(tz / 106))))
[[Era]] String year を YearFromTime(𝔽(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.13 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. optionsをoptionsResolution.[[Options]]に設定する。
  5. resolvedLocaleをoptionsResolution.[[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. resolvedLocaleDataをresolvedLocale.[[LocaleData]]とする。
  14. typesをresolvedLocaleData.[[types]]とする。
  15. Assert: typesはRecordである(12.2.3を参照)。
  16. languageDisplayを? GetOption(options, "languageDisplay", string, « "dialect", "standard" », "dialect")とする。
  17. typeFieldsをtypes.[[<type>]]とする。
  18. Assert: typeFieldsはRecordである(12.2.3を参照)。
  19. typeが"language"ならば、
    1. displayNames.[[LanguageDisplay]]をlanguageDisplayに設定する。
    2. typeFieldsをtypeFields.[[<languageDisplay>]]に設定する。
    3. Assert: typeFieldsはRecordである(12.2.3を参照)。
  20. styleFieldsをtypeFields.[[<style>]]とする。
  21. Assert: styleFieldsはRecordである(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. displayNamesをthis値とする。
  2. ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]])を実行する。
  3. optionsをOrdinaryObjectCreate(%Object.prototype%)とする。
  4. Table 18の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. propertyKeyを現在の行のProperty値とする。
    2. valueを、その名前が現在の行のInternal Slot値であるdisplayNamesの内部スロットの値とする。
    3. valueがundefinedでないならば、
      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. displayNamesをthis値とする。
  2. ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]])を実行する。
  3. codeを? ToString(code)に設定する。
  4. codeを? CanonicalCodeForDisplayNames(displayNames.[[Type]], code)に設定する。
  5. fieldsをdisplayNames.[[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]]はRecord(12.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完了. codeがtypeに従って整形式コードを表すことを検証し、codeの大文字小文字を正規化した形式を返す。 It performs the following steps when called:

  1. typeが"language"ならば、
    1. codeがunicode_language_id Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
    2. IsWellFormedLanguageTag(code)がfalseならば、RangeError例外を投げる。
    3. CanonicalizeUnicodeLocaleId(code)を返す。
  2. typeが"region"ならば、
    1. codeがunicode_region_subtag Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
    2. codeのASCII大文字化を返す。
  3. typeが"script"ならば、
    1. codeがunicode_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. firstとrestの文字列連結を返す。
  4. typeが"calendar"ならば、
    1. codeがtype Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
    2. codeがUnicode 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. fieldがTable 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. optionsをoptionsResolution.[[Options]]に設定する。
  5. resolvedLocaleをoptionsResolution.[[ResolvedLocale]]とする。
  6. durationFormat.[[Locale]]をresolvedLocale.[[Locale]]に設定する。
  7. resolvedLocaleDataをresolvedLocale.[[LocaleData]]とする。
  8. digitalFormatをresolvedLocaleData.[[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. prevStyleをunitOptions.[[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. dfをthis値とする。
  2. ? RequireInternalSlot(df, [[InitializedDurationFormat]])を実行する。
  3. optionsをOrdinaryObjectCreate(%Object.prototype%)とする。
  4. Table 21の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. propertyKeyを現在の行のProperty値とする。
    2. valueを、その名前が現在の行のInternal Slot値であるdfの内部スロットの値とする。
    3. valueがundefinedでないならば、
      1. 現在の行にConversion値があるならば、conversionをその値とする。そうでなければ、conversionをemptyとする。
      2. conversionがnumberならば、
        1. valueを𝔽(value)に設定する。
      3. そうでなく、conversionがemptyでないならば、
        1. Assert: conversionはstyle+displayであり、valueはDuration Unit Options Recordである。
        2. NOTE: value.[[Style]]はpropertyKey(複数形のTemporal単位)という名前のプロパティで表され、その後value.[[Display]]はpropertyKeyに"Display"を接尾する名前のプロパティで表される。
        3. styleをvalue.[[Style]]とする。
        4. styleが"fractional"ならば、
          1. Assert: IsFractionalSecondUnitName(propertyKey)はtrueである。
          2. styleを"numeric"に設定する。
        5. ! CreateDataPropertyOrThrow(options, propertyKey, style)を実行する。
        6. propertyKeyをpropertyKeyと"Display"の文字列連結に設定する。
        7. valueをvalue.[[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. df を this 値とする。
  2. ? RequireInternalSlot(df, [[InitializedDurationFormat]]) を実行する。
  3. record を ? ToDurationRecord(duration) とする。
  4. parts を PartitionDurationFormatPattern(df, record) とする。
  5. result を空の String とする。
  6. parts の各 Record { [[Type]], [[Value]], [[Unit]] } part について、次を行う。
    1. result を result と part.[[Value]] の文字列連結に設定する。
  7. result を返す。

13.3.4 Intl.DurationFormat.prototype.formatToParts ( duration )

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

  1. df を this 値とする。
  2. ? RequireInternalSlot(df, [[InitializedDurationFormat]]) を実行する。
  3. record を ? ToDurationRecord(duration) とする。
  4. parts を PartitionDurationFormatPattern(df, record) とする。
  5. result を ! ArrayCreate(0) とする。
  6. n を 0 とする。
  7. parts の各 Record { [[Type]], [[Value]], [[Unit]] } part について、次を行う。
    1. obj を OrdinaryObjectCreate(%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. n を n + 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. daysがundefinedでないならば、result.[[Days]]を? ToIntegerIfIntegral(days)に設定する。
  5. hoursを? Get(input, "hours")とする。
  6. hoursがundefinedでないならば、result.[[Hours]]を? ToIntegerIfIntegral(hours)に設定する。
  7. microsecondsを? Get(input, "microseconds")とする。
  8. microsecondsがundefinedでないならば、result.[[Microseconds]]を? ToIntegerIfIntegral(microseconds)に設定する。
  9. millisecondsを? Get(input, "milliseconds")とする。
  10. millisecondsがundefinedでないならば、result.[[Milliseconds]]を? ToIntegerIfIntegral(milliseconds)に設定する。
  11. minutesを? Get(input, "minutes")とする。
  12. minutesがundefinedでないならば、result.[[Minutes]]を? ToIntegerIfIntegral(minutes)に設定する。
  13. monthsを? Get(input, "months")とする。
  14. monthsがundefinedでないならば、result.[[Months]]を? ToIntegerIfIntegral(months)に設定する。
  15. nanosecondsを? Get(input, "nanoseconds")とする。
  16. nanosecondsがundefinedでないならば、result.[[Nanoseconds]]を? ToIntegerIfIntegral(nanoseconds)に設定する。
  17. secondsを? Get(input, "seconds")とする。
  18. secondsがundefinedでないならば、result.[[Seconds]]を? ToIntegerIfIntegral(seconds)に設定する。
  19. weeksを? Get(input, "weeks")とする。
  20. weeksがundefinedでないならば、result.[[Weeks]]を? ToIntegerIfIntegral(weeks)に設定する。
  21. yearsを? Get(input, "years")とする。
  22. yearsがundefinedでないならば、result.[[Years]]を? ToIntegerIfIntegral(years)に設定する。
  23. years、months、weeks、days、hours、minutes、seconds、milliseconds、microseconds、および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) が有限の Number でない場合、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. normalizedSecondsをdays × 86,400 + hours × 3600 + minutes × 60 + seconds + ℝ(𝔽(milliseconds)) × 10-3 + ℝ(𝔽(microseconds)) × 10-6 + ℝ(𝔽(nanoseconds)) × 10-9とする。
  7. NOTE: 上記の手順は、浮動小数点演算を使用して直接実装することはできない。milliseconds、microseconds、または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. styleがundefinedならば、
    1. baseStyleが"digital"ならば、
      1. styleをdigitalBaseに設定する。
      2. unitが"hours"、"minutes"、または"seconds"のいずれでもないならば、displayDefaultを"auto"に設定する。
    2. そうでなく、prevStyleが"fractional"、"numeric"、または"2-digit"のいずれかならば、
      1. styleを"numeric"に設定する。
      2. unitが"minutes"または"seconds"でないならば、displayDefaultを"auto"に設定する。
    3. そうでなければ、
      1. styleをbaseStyleに設定する。
      2. displayDefaultを"auto"に設定する。
  4. styleが"numeric"であり、かつIsFractionalSecondUnitName(unit)がtrueならば、
    1. styleを"fractional"に設定する。
    2. displayDefaultを"auto"に設定する。
  5. displayFieldをunitと"Display"の文字列連結とする。
  6. displayを? GetOption(options, displayField, string, « "auto", "always" », displayDefault)とする。
  7. ? ValidateDurationUnitStyle(unit, style, display, prevStyle)を実行する。
  8. unitが"hours"であり、かつtwoDigitHoursがtrueならば、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. resultをresult + (value / 10exponent)に設定する。
      5. exponentをexponent + 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 RecordのList. hoursValueは時数を示す整数である。durationFormatの有効なロケールおよび整形オプションに従って、hoursValueの部分を作成する。 It performs the following steps when called:

  1. resultを新しい空のListとする。
  2. hoursStyleをdurationFormat.[[HoursOptions]].[[Style]]とする。
  3. Assert: hoursStyleは"numeric"または"2-digit"である。
  4. nfOptionsをOrdinaryObjectCreate(null)とする。
  5. numberingSystemをdurationFormat.[[NumberingSystem]]とする。
  6. ! CreateDataPropertyOrThrow(nfOptions, "numberingSystem", numberingSystem)を実行する。
  7. hoursStyleが"2-digit"ならば、
    1. ! CreateDataPropertyOrThrow(nfOptions, "minimumIntegerDigits", 2𝔽)を実行する。
  8. signDisplayedがfalseならば、
    1. ! CreateDataPropertyOrThrow(nfOptions, "signDisplay", "never")を実行する。
  9. ! CreateDataPropertyOrThrow(nfOptions, "useGrouping", false)を実行する。
  10. nfを! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOptions »)とする。
  11. hoursPartsをPartitionNumberPattern(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 RecordのList. minutesValueは分数を示す整数である。durationFormatの有効なロケールおよび整形オプションに従って、minutesValueの部分を作成する。 It performs the following steps when called:

  1. resultを新しい空のListとする。
  2. hoursDisplayedがtrueならば、
    1. separatorをdurationFormat.[[HourMinuteSeparator]]とする。
    2. Record { [[Type]]: "literal", [[Value]]: separator, [[Unit]]: empty }をresultに追加する。
  3. minutesStyleをdurationFormat.[[MinutesOptions]].[[Style]]とする。
  4. Assert: minutesStyleは"numeric"または"2-digit"である。
  5. nfOptionsをOrdinaryObjectCreate(null)とする。
  6. numberingSystemをdurationFormat.[[NumberingSystem]]とする。
  7. ! CreateDataPropertyOrThrow(nfOptions, "numberingSystem", numberingSystem)を実行する。
  8. minutesStyleが"2-digit"ならば、
    1. ! CreateDataPropertyOrThrow(nfOptions, "minimumIntegerDigits", 2𝔽)を実行する。
  9. signDisplayedがfalseならば、
    1. ! CreateDataPropertyOrThrow(nfOptions, "signDisplay", "never")を実行する。
  10. ! CreateDataPropertyOrThrow(nfOptions, "useGrouping", false)を実行する。
  11. nfを! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOptions »)とする。
  12. minutesPartsをPartitionNumberPattern(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 RecordのList. secondsValueは秒数を示す数学的値である。durationFormatの有効なロケールおよび整形オプションに従って、secondsValueの部分を作成する。 It performs the following steps when called:

  1. resultを新しい空のListとする。
  2. minutesDisplayedがtrueならば、
    1. separatorをdurationFormat.[[MinuteSecondSeparator]]とする。
    2. Record { [[Type]]: "literal", [[Value]]: separator, [[Unit]]: empty }をresultに追加する。
  3. secondsStyleをdurationFormat.[[SecondsOptions]].[[Style]]とする。
  4. Assert: secondsStyleは"numeric"または"2-digit"である。
  5. nfOptionsをOrdinaryObjectCreate(null)とする。
  6. numberingSystemをdurationFormat.[[NumberingSystem]]とする。
  7. ! CreateDataPropertyOrThrow(nfOptions, "numberingSystem", numberingSystem)を実行する。
  8. secondsStyleが"2-digit"ならば、
    1. ! CreateDataPropertyOrThrow(nfOptions, "minimumIntegerDigits", 2𝔽)を実行する。
  9. signDisplayedがfalseならば、
    1. ! CreateDataPropertyOrThrow(nfOptions, "signDisplay", "never")を実行する。
  10. ! CreateDataPropertyOrThrow(nfOptions, "useGrouping", false)を実行する。
  11. fractionDigitsをdurationFormat.[[FractionalDigits]]とする。
  12. fractionDigitsがundefinedならば、
    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. secondsPartsをPartitionNumberPattern(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 RecordのList. durationFormatの有効なロケールおよび整形オプションに従って、"numeric"または"2-digit"スタイルを使用するdurationの要素を表す部分を作成する。 It performs the following steps when called:

  1. Assert: firstNumericUnitは"hours"、"minutes"、または"seconds"である。
  2. numericPartsListを新しい空のListとする。
  3. hoursValueをduration.[[Hours]]とする。
  4. hoursDisplayをdurationFormat.[[HoursOptions]].[[Display]]とする。
  5. minutesValueをduration.[[Minutes]]とする。
  6. minutesDisplayをdurationFormat.[[MinutesOptions]].[[Display]]とする。
  7. secondsValueをduration.[[Seconds]]とする。
  8. duration.[[Milliseconds]]が0でない、またはduration.[[Microseconds]]が0でない、またはduration.[[Nanoseconds]]が0でないならば、
    1. secondsValueをsecondsValue + ComputeFractionalDigits(durationFormat, duration)に設定する。
  9. secondsDisplayをdurationFormat.[[SecondsOptions]].[[Display]]とする。
  10. hoursFormattedをfalseとする。
  11. firstNumericUnitが"hours"ならば、
    1. hoursValueが0でない、またはhoursDisplayが"always"ならば、
      1. hoursFormattedをtrueに設定する。
  12. secondsValueが0でない、またはsecondsDisplayが"always"ならば、
    1. secondsFormattedをtrueとする。
  13. そうでなければ、
    1. secondsFormattedをfalseとする。
  14. minutesFormattedをfalseとする。
  15. firstNumericUnitが"hours"またはfirstNumericUnitが"minutes"ならば、
    1. hoursFormattedがtrueであり、かつsecondsFormattedがtrueならば、
      1. minutesFormattedをtrueに設定する。
    2. そうでなく、minutesValueが0でない、またはminutesDisplayが"always"ならば、
      1. minutesFormattedをtrueに設定する。
  16. hoursFormattedがtrueならば、
    1. signDisplayedがtrueならば、
      1. hoursValueが0であり、かつDurationSign(duration)が-1ならば、
        1. hoursValueをnegative-zeroに設定する。
    2. hoursPartsをFormatNumericHours(durationFormat, hoursValue, signDisplayed)とする。
    3. numericPartsListをnumericPartsListとhoursPartsのリスト連結に設定する。
    4. signDisplayedをfalseに設定する。
  17. minutesFormattedがtrueならば、
    1. signDisplayedがtrueならば、
      1. minutesValueが0であり、かつDurationSign(duration)が-1ならば、
        1. minutesValueをnegative-zeroに設定する。
    2. minutesPartsをFormatNumericMinutes(durationFormat, minutesValue, hoursFormatted, signDisplayed)とする。
    3. numericPartsListをnumericPartsListとminutesPartsのリスト連結に設定する。
    4. signDisplayedをfalseに設定する。
  18. secondsFormattedがtrueならば、
    1. secondsPartsをFormatNumericSeconds(durationFormat, secondsValue, minutesFormatted, signDisplayed)とする。
    2. numericPartsListをnumericPartsListとsecondsPartsのリスト連結に設定する。
  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 (RecordのListからなるList) and returns List. durationFormatの有効なロケールおよび整形オプションに従って、partitionedPartsList内のList内の部分に対応するListを作成する。 It performs the following steps when called:

  1. lfOptions を OrdinaryObjectCreate(null) とする。
  2. ! CreateDataPropertyOrThrow(lfOptions, "type", "unit") を実行する。
  3. listStyle を durationFormat.[[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. string を string と part.[[Value]] の文字列連結に設定する。
    3. string を strings に追加する。
  9. formattedPartsList を CreatePartsFromList(lf, strings) とする。
  10. partitionedPartsIndex を 0 とする。
  11. partitionedLength を partitionedPartsList 内の要素数とする。
  12. flattenedPartsList を新しい空の List とする。
  13. formattedPartsList の各 Record { [[Type]], [[Value]] } listPart について、次を行う。
    1. listPart.[[Type]] が "element" なら、
      1. Assert: partitionedPartsIndex < partitionedLength である。
      2. parts を partitionedPartsList[partitionedPartsIndex] とする。
      3. parts の各 Record { [[Type]], [[Value]], [[Unit]] } part について、次を行う。
        1. part を flattenedPartsList に追加する。
      4. partitionedPartsIndex を partitionedPartsIndex + 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. signDisplayedをtrueとする。
  3. numericUnitFoundをfalseとする。
  4. numericUnitFoundがfalseである間、Table 24内の各行(ヘッダ行を除く)について、表の順序で繰り返す:
    1. valueを、名前が現在の行のValue Field値であるdurationのフィールドの値とする。
    2. unitOptionsを、名前が現在の行のInternal Slot値であるdurationFormatの内部スロットの値とする。
    3. styleをunitOptions.[[Style]]とする。
    4. displayをunitOptions.[[Display]]とする。
    5. unitを現在の行のUnit値とする。
    6. numberFormatUnitを現在の行のNumberFormat Unit値とする。
    7. styleが"numeric"または"2-digit"ならば、
      1. numericPartsListをFormatNumericUnits(durationFormat, duration, unit, signDisplayed)とする。
      2. numericPartsListが空でないならば、numericPartsListをresultに追加する。
      3. numericUnitFoundをtrueに設定する。
    8. そうでなければ、
      1. nfOptionsをOrdinaryObjectCreate(null)とする。
      2. NextUnitFractional(durationFormat, unit)がtrueならば、
        1. valueをvalue + ComputeFractionalDigits(durationFormat, duration)に設定する。
        2. fractionDigitsをdurationFormat.[[FractionalDigits]]とする。
        3. fractionDigitsがundefinedならば、
          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. numericUnitFoundをtrueに設定する。
      3. displayが"always"である、またはvalueが0でないならば、
        1. ! CreateDataPropertyOrThrow(nfOptions, "numberingSystem", durationFormat.[[NumberingSystem]])を実行する。
        2. signDisplayedがtrueならば、
          1. signDisplayedをfalseに設定する。
          2. valueが0であり、かつDurationSign(duration)が-1ならば、valueをnegative-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. partsをPartitionNumberPattern(nf, value)とする。
        9. listを新しい空のListとする。
        10. partsの各Record { [[Type]], [[Value]] } partについて、次を行う:
          1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: numberFormatUnit }をlistに追加する。
        11. listをresultに追加する。
  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. optionsをoptionsResolution.[[Options]]に設定する。
  5. resolvedLocaleをoptionsResolution.[[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. resolvedLocaleDataをresolvedLocale.[[LocaleData]]とする。
  12. dataLocaleTypesをresolvedLocaleData.[[<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]]という名前のフィールドを持つRecordのListでなければならない。これらの各フィールドは、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. lfをthis値とする。
  2. ? RequireInternalSlot(lf, [[InitializedListFormat]])を実行する。
  3. optionsをOrdinaryObjectCreate(%Object.prototype%)とする。
  4. Table 25の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. propertyKeyを現在の行のProperty値とする。
    2. valueを、その名前が現在の行のInternal Slot値であるlfの内部スロットの値とする。
    3. Assert: valueはundefinedでない。
    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. lfをthis値とする。
  2. ? RequireInternalSlot(lf, [[InitializedListFormat]])を実行する。
  3. stringListを? StringListFromIterable(list)とする。
  4. FormatList(lf, stringList)を返す。

14.3.4 Intl.ListFormat.prototype.formatToParts ( list )

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

  1. lfをthis値とする。
  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 Record(PartitionPatternからのものと同様)である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. patternPartsをPartitionPattern(pattern)とする。
  2. resultを新しい空のListとする。
  3. patternPartsの各Record { [[Type]], [[Value]] } patternPartについて、次を行う:
    1. partTypeをpatternPart.[[Type]]とする。
    2. partTypeが"literal"ならば、
      1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }をresultに追加する。
    3. そうでなければ、
      1. Assert: placeablesはフィールド[[<partType>]]を持つ。
      2. substitutionをplaceables.[[<partType>]]とする。
      3. substitutionがListならば、
        1. substitutionの各要素partについて、次を行う:
          1. partをresultに追加する。
      4. そうでなければ、
        1. substitutionをresultに追加する。
  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)を持つRecordのList. listFormatの有効なロケールおよび整形オプションに従って、対応する部分のListを作成する。 It performs the following steps when called:

  1. size を list の要素数とする。
  2. size が 0 なら、
    1. 新しい空の List を返す。
  3. size が 2 なら、
    1. n を、listFormat.[[Locale]]、list[0]、および list[1] に基づく listFormat.[[Templates]] へのインデックスとする。
    2. pattern を listFormat.[[Templates]][n].[[Pair]] とする。
    3. first を Record { [[Type]]: "element", [[Value]]: list[0] } とする。
    4. second を Record { [[Type]]: "element", [[Value]]: list[1] } とする。
    5. placeables を Record { [[0]]: first, [[1]]: second } とする。
    6. DeconstructPattern(pattern, placeables) を返す。
  4. last を Record { [[Type]]: "element", [[Value]]: list[size - 1] } とする。
  5. parts を « last » とする。
  6. i を size - 2 とする。
  7. i ≥ 0 の間、繰り返す。
    1. head を Record { [[Type]]: "element", [[Value]]: list[i] } とする。
    2. n を、listFormat.[[Locale]]、head、および parts に基づく listFormat.[[Templates]] への実装定義のインデックスとする。
    3. i が 0 なら、
      1. pattern を listFormat.[[Templates]][n].[[Start]] とする。
    4. そうでなく i が size - 2 より小さいなら、
      1. pattern を listFormat.[[Templates]][n].[[Middle]] とする。
    5. そうでなければ、
      1. pattern を listFormat.[[Templates]][n].[[End]] とする。
    6. placeables を Record { [[0]]: head, [[1]]: parts } とする。
    7. parts を DeconstructPattern(pattern, placeables) に設定する。
    8. i を i - 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. partsをCreatePartsFromList(listFormat, list)とする。
  2. resultを空のStringとする。
  3. partsの各Record { [[Type]], [[Value]] } partについて、次を行う:
    1. resultをresultとpart.[[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. partsをCreatePartsFromList(listFormat, list)とする。
  2. resultを! ArrayCreate(0)とする。
  3. nを0とする。
  4. partsの各Record { [[Type]], [[Value]] } partについて、次を行う:
    1. objをOrdinaryObjectCreate(%Object.prototype%)とする。
    2. ! CreateDataPropertyOrThrow(obj, "type", part.[[Type]])を実行する。
    3. ! CreateDataPropertyOrThrow(obj, "value", part.[[Value]])を実行する。
    4. ! CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), obj)を実行する。
    5. n を n + 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. iterableがundefinedならば、
    1. 新しい空のListを返す。
  2. iteratorRecordを? GetIterator(iterable, sync)とする。
  3. listを新しい空のListとする。
  4. 繰り返す:
    1. nextを? IteratorStepValue(iteratorRecord)とする。
    2. nextがdoneならば、
      1. listを返す。
    3. nextがStringでないならば、
      1. errorをThrowCompletion(新しく作成されたTypeErrorオブジェクト)とする。
      2. ? IteratorClose(iteratorRecord, error)を返す。
    4. nextをlistに追加する。
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. baseNameをGetLocaleBaseName(tag)とする。
  2. languageを? GetOption(options, "language", string, empty, GetLocaleLanguage(baseName))とする。
  3. languageがunicode_language_subtag Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
  4. scriptを? GetOption(options, "script", string, empty, GetLocaleScript(baseName))とする。
  5. scriptがundefinedでないならば、
    1. scriptがunicode_script_subtag Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
  6. regionを? GetOption(options, "region", string, empty, GetLocaleRegion(baseName))とする。
  7. regionがundefinedでないならば、
    1. regionがunicode_region_subtag Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
  8. variantsを? GetOption(options, "variants", string, empty, GetLocaleVariants(baseName))とする。
  9. variantsがundefinedでないならば、
    1. variantsが空のStringならば、RangeError例外を投げる。
    2. lowerVariantsをvariantsのASCII小文字化とする。
    3. variantSubtagsをStringSplitToList(lowerVariants, "-")とする。
    4. variantSubtagsの各要素variantについて、次を行う:
      1. variantがunicode_variant_subtag Unicodeロケール非終端記号により一致させることができないならば、RangeError例外を投げる。
    5. variantSubtagsが重複要素を含むならば、RangeError例外を投げる。
  10. allExtensionsをbaseNameの後に続くtagの接尾部とする。
  11. newTagをlanguageとする。
  12. scriptがundefinedでないならば、newTagをnewTag、"-"、およびscriptの文字列連結に設定する。
  13. regionがundefinedでないならば、newTagをnewTag、"-"、およびregionの文字列連結に設定する。
  14. variantsがundefinedでないならば、newTagをnewTag、"-"、およびvariantsの文字列連結に設定する。
  15. newTagをnewTagとallExtensionsの文字列連結に設定する。
  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. tagがUnicodeロケール拡張シーケンスであるsubstringを含むならば、
    1. extensionを、tag内のUnicodeロケール拡張シーケンスのsubstringからなるString値とする。
    2. componentsをUnicodeExtensionComponents(extension)とする。
    3. attributesをcomponents.[[Attributes]]とする。
    4. keywordsをcomponents.[[Keywords]]とする。
  2. そうでなければ、
    1. attributesを新しい空のListとする。
    2. keywordsを新しい空のListとする。
  3. resultを新しいRecordとする。
  4. localeExtensionKeysの各要素keyについて、次を行う:
    1. keywordsが[[Key]]がkeyである要素を含むならば、
      1. entryを、[[Key]]がkeyであるkeywordsの要素とする。
      2. valueをentry.[[Value]]とする。
    2. そうでなければ、
      1. entryをemptyとする。
      2. valueをundefinedとする。
    3. Assert: optionsはフィールド[[<key>]]を持つ。
    4. overrideValueをoptions.[[<key>]]とする。
    5. overrideValueがundefinedでないならば、
      1. valueをCanonicalizeUValue(key, overrideValue)に設定する。
      2. entryがemptyでないならば、
        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. locをthis値とする。
  2. ? RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. GetLocaleBaseName(loc.[[Locale]])を返す。

15.3.3 get Intl.Locale.prototype.calendar

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

  1. locをthis値とする。
  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. locをthis値とする。
  2. ? RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. loc.[[CaseFirst]]を返す。

15.3.5 get Intl.Locale.prototype.collation

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

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

15.3.6 get Intl.Locale.prototype.firstDayOfWeek

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

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

15.3.7 get Intl.Locale.prototype.hourCycle

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

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

15.3.8 get Intl.Locale.prototype.language

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

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

15.3.9 Intl.Locale.prototype.maximize ( )

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

15.3.10 Intl.Locale.prototype.minimize ( )

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

15.3.11 get Intl.Locale.prototype.numberingSystem

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

  1. locをthis値とする。
  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. locをthis値とする。
  2. ? RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. loc.[[Numeric]]を返す。

15.3.13 get Intl.Locale.prototype.region

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

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

15.3.14 get Intl.Locale.prototype.script

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

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

15.3.15 Intl.Locale.prototype.toString ( )

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

15.3.16 Intl.Locale.prototype.getCalendars ( )

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

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

15.3.17 Intl.Locale.prototype.getCollations ( )

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

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

15.3.18 Intl.Locale.prototype.getHourCycles ( )

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

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

15.3.19 Intl.Locale.prototype.getNumberingSystems ( )

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

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

15.3.20 Intl.Locale.prototype.getTimeZones ( )

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

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

15.3.21 Intl.Locale.prototype.getTextInfo ( )

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

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

15.3.22 Intl.Locale.prototype.getWeekInfo ( )

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

  1. locをthis値とする。
  2. ? RequireInternalSlot(loc, [[InitializedLocale]])を実行する。
  3. infoをOrdinaryObjectCreate(%Object.prototype%)とする。
  4. weekInfoをWeekInfoOfLocale(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. locをthis値とする。
  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: localeはunicode_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. baseName を GetLocaleBaseName(locale) とする。
  2. subtags を StringSplitToList(baseName, "-") とする。
  3. Assert: subtags[0] は unicode_language_subtag Unicode ロケール非終端記号にマッチする。
  4. subtags[0] を返す。

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. baseName を GetLocaleBaseName(locale) とする。
  2. 注記: unicode_script_subtag サブタグは、先頭の unicode_language_subtag サブタグの直後でのみ有効である。その位置では、他のすべての有効なサブタグの生成規則が互いに素であるため、それらのいずれとも混同されることはない。
  3. subtags を StringSplitToList(baseName, "-") とする。
  4. 表明: subtags[0] は unicode_language_subtag Unicode ロケール非終端記号にマッチする。
  5. subtags が少なくとも 2 個の要素を持ち、かつ subtags[1] が unicode_script_subtag Unicode ロケール非終端記号にマッチする場合、subtags[1] を返す。
  6. 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. baseName を GetLocaleBaseName(locale) とする。
  2. 注記: unicode_region_subtag サブタグは、先頭の unicode_language_subtag サブタグの直後、またはその間に単一の unicode_script_subtag サブタグを任意に挟んだ位置でのみ有効である。その位置では、他のすべての有効なサブタグの生成規則が互いに素であるため、それらのいずれとも混同されることはない。
  3. subtags を StringSplitToList(baseName, "-") とする。
  4. 表明: subtags[0] は unicode_language_subtag Unicode ロケール非終端記号にマッチする。
  5. subtags が少なくとも 2 個の要素を持ち、かつ subtags[1] が unicode_region_subtag Unicode ロケール非終端記号にマッチする場合、subtags[1] を返す。
  6. subtags が少なくとも 3 個の要素を持ち、かつ subtags[2] が unicode_region_subtag Unicode ロケール非終端記号にマッチする場合、subtags[2] を返す。
  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. baseName を GetLocaleBaseName(locale) とする。
  2. 注記: baseName の先頭以外の各サブタグは、unicode_script_subtag、unicode_region_subtag、または unicode_variant_subtag のいずれかであり、それらの生成規則はすべて互いに素である。
  3. subtags を StringSplitToList(baseName, "-") とする。
  4. 表明: subtags[0] は unicode_language_subtag Unicode ロケール非終端記号にマッチする。
  5. dashIndex を subtags[0] の長さとする。
  6. subtags から最初の要素を削除する。
  7. subtags の各 String subtag について、次を行う
    1. subtag が unicode_variant_subtag Unicode ロケール非終端記号にマッチする場合、
      1. baseName の dashIndex + 1 から始まる部分文字列を返す。
    2. subtagLength を subtag の長さとする。
    3. dashIndex を dashIndex + subtagLength + 1 に設定する。
  8. 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. localeがUnicodeロケール拡張シーケンスを含むならば、
    1. extensionをlocaleのUnicodeロケール拡張シーケンスとする。
    2. componentsをUnicodeExtensionComponents(extension)とする。
    3. keywordsをcomponents.[[Keywords]]とする。
    4. keywordsの要素entryでentry.[[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. subdivisionをUnicodeExtensionValue(locale, key)とする。
  2. subdivisionがemptyならば、undefinedを返す。
  3. subdivisionがunicode_subdivision_id Unicodeロケール非終端記号により一致させることができないならば、undefinedを返す。
  4. regionを、unicode_region_subtag Unicodeロケール非終端記号により一致するsubdivisionの最長の接頭部とする。
  5. regionLocaleを"und-"とregionの文字列連結とする。
  6. regionLocaleをCanonicalizeUnicodeLocaleId(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. regionをGetLocaleRegion(locale)とする。
  2. regionがundefinedならば、
    1. regionをCanonicalUnicodeSubdivision(locale, "sd")に設定する。
    2. regionがundefinedならば、
      1. maximalを、localeに適用されたAdd Likely Subtagsアルゴリズムの結果とする。エラーが通知されたならば、maximalをlocaleに設定する。
      2. maximalをCanonicalizeUnicodeLocaleId(maximal)に設定する。
      3. regionをGetLocaleRegion(maximal)に設定する。
      4. regionがundefinedならば、
        1. regionを"001"に設定する。
  3. regionOverrideをCanonicalUnicodeSubdivision(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. CreateArrayFromList(« loc.[[Calendar]] ») を返す。
  2. preference を RegionPreference(loc.[[Locale]]) とする。
  3. preference.[[RegionOverride]] が undefined でない場合、preferredRegions を « preference.[[RegionOverride]], preference.[[Region]] » とし、それ以外の場合は preferredRegions を « preference.[[Region]] » とする。
  4. calendarsInUse を新しい空の List とする。
  5. language を GetLocaleLanguage(loc.[[Locale]]) とする。
  6. preferredRegions の各 String region について、次の手順を実行する。
    1. locale を language、"-"、および region の文字列連結とする。
    2. calendarsInUse が空であり、ロケール locale のカレンダー設定データが利用可能な場合、
      1. calendarsInUse を、ロケール locale で日付および時刻の書式設定に一般的に使用される一意なカレンダー型を、locale での使用優先度の降順に並べた List に設定する。
    3. calendarsInUse が空であり、地域 region のカレンダー設定データが利用可能な場合、
      1. calendarsInUse を、地域 region で日付および時刻の書式設定に一般的に使用される一意なカレンダー型を、region での使用優先度の降順に並べた List に設定する。
  7. list を新しい空の List とする。
  8. availableCalendars を AvailableCalendars() とする。
  9. calendarsInUse の各要素 identifier について、次の手順を実行する。
    1. canonical を CanonicalizeUValue("ca", identifier) とする。
    2. availableCalendars が canonical を含み、かつ list が canonical を含まない場合、
      1. canonical を list に追加する。
  10. list が空の場合、list を « "gregory" » に設定する。
  11. 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. CreateArrayFromList(« loc.[[Collation]] ») を返す。
  2. match を LookupMatchingLocaleByPrefix(%Intl.Collator%.[[AvailableLocales]], « loc.[[Locale]] ») とする。
  3. match が undefined でない場合、
    1. foundLocale を match.[[locale]] とする。
    2. foundLocaleData を %Intl.Collator%.[[SortLocaleData]].[[<foundLocale>]] とする。
    3. list を foundLocaleData.[[co]] のコピーとする。
    4. 表明: list[0] は null である。
    5. 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. CreateArrayFromList(« loc.[[HourCycle]] ») を返す。
  2. preference を RegionPreference(loc.[[Locale]]) とする。
  3. preference.[[RegionOverride]] が undefined でない場合、preferredRegions を « preference.[[RegionOverride]], preference.[[Region]] » とし、それ以外の場合は preferredRegions を « preference.[[Region]] » とする。
  4. hourCycles を新しい空の List とする。
  5. language を GetLocaleLanguage(loc.[[Locale]]) とする。
  6. preferredRegions の各 String region について、次の手順を実行する。
    1. locale を language、"-"、および region の文字列連結とする。
    2. hourCycles が空であり、ロケール locale の時刻データが利用可能な場合、
      1. hourCycles を、12 時間形式("h11"、"h12")または 24 時間形式("h23"、"h24")のいずれかを示す小文字の String でなければならない一意な時刻周期識別子を、ロケール locale で日付および時刻の書式設定に一般的に使用されるものの優先度の降順に並べた List に設定する。
    3. hourCycles が空であり、地域 region の時刻データが利用可能な場合、
      1. hourCycles を、12 時間形式("h11"、"h12")または 24 時間形式("h23"、"h24")のいずれかを示す小文字の String でなければならない一意な時刻周期識別子を、地域 region で日付および時刻の書式設定に一般的に使用されるものの優先度の降順に並べた List に設定する。
  7. hourCycles が空の場合、hourCycles を « "h23" » に設定する。
  8. CreateArrayFromList(hourCycles) を返す。

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. CreateArrayFromList(« loc.[[NumberingSystem]] »)を返す。
  2. matchをLookupMatchingLocaleByPrefix(%Intl.NumberFormat%.[[AvailableLocales]], « loc.[[Locale]] »)とする。
  3. matchがundefinedでないならば、
    1. foundLocaleをmatch.[[locale]]とする。
    2. foundLocaleDataを%Intl.NumberFormat%.[[LocaleData]].[[<foundLocale>]]とする。
    3. numberingSystemsをfoundLocaleData.[[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. regionをGetLocaleRegion(loc.[[Locale]])とする。
  2. regionがundefinedならば、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. localeをloc.[[Locale]]とする。
  2. scriptをGetLocaleScript(locale)とする。
  3. scriptがundefinedならば、
    1. maximalを、localeに適用されたAdd Likely Subtagsアルゴリズムの結果とする。エラーが通知されたならば、undefinedを返す。
    2. scriptをGetLocaleScript(maximal)に設定する。
    3. scriptがundefinedならば、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. fwがweekdayと等しいならば、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. fwがstringと等しいならば、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. preference を RegionPreference(loc.[[Locale]]) とする。
  2. region を preference.[[Region]] とする。
  3. regionOverride を preference.[[RegionOverride]] とする。
  4. regionOverride が undefined でなく、かつ地域 regionOverride の週データが利用可能な場合、
    1. lookupRegion を regionOverride とする。
  5. それ以外の場合、地域 region の週データが利用可能であれば、
    1. lookupRegion を region とする。
  6. それ以外の場合、
    1. lookupRegion を "001" とする。
  7. weekInfo を、そのフィールドが Table 27 によって定義され、値が地域 lookupRegion に基づく Record とする。
  8. firstDayString を loc.[[FirstDayOfWeek]] とする。
  9. firstDayString が undefined でない場合、
    1. firstDay を WeekdayUValueToNumber(firstDayString) とする。
    2. firstDay が undefined でない場合、weekInfo.[[FirstDay]] を firstDay に設定する。
  10. 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. optionsをoptionsResolution.[[Options]]に設定する。
  5. resolvedLocaleをoptionsResolution.[[ResolvedLocale]]とする。
  6. numberFormat.[[Locale]]をresolvedLocale.[[Locale]]に設定する。
  7. numberFormat.[[LocaleData]]をresolvedLocale.[[LocaleData]]に設定する。
  8. numberFormat.[[NumberingSystem]]をresolvedLocale.[[nu]]に設定する。
  9. ? SetNumberFormatUnitOptions(numberFormat, options)を実行する。
  10. styleをnumberFormat.[[Style]]とする。
  11. notationを? GetOption(options, "notation", string, « "standard", "scientific", "engineering", "compact" », "standard")とする。
  12. numberFormat.[[Notation]]をnotationに設定する。
  13. styleが"currency"であり、かつnotationが"standard"ならば、
    1. currencyをnumberFormat.[[Currency]]とする。
    2. cDigitsをCurrencyDigits(currency)とする。
    3. mnfdDefaultをcDigitsとする。
    4. mxfdDefaultをcDigitsとする。
  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"ならば、useGroupingをdefaultUseGroupingに設定する。
  22. useGroupingがtrueならば、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. thisをthis値とする。
    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. newTargetがundefinedであり、かつ? 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.2参照)。 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でないならば、mxfdDefaultをmnfdDefaultに設定する。
  14. intlObj.[[RoundingIncrement]]をroundingIncrementに設定する。
  15. intlObj.[[RoundingMode]]をroundingModeに設定する。
  16. intlObj.[[TrailingZeroDisplay]]をtrailingZeroDisplayに設定する。
  17. mnsdがundefinedであり、かつmxsdがundefinedならばhasSdをfalseとする。そうでなければ、hasSdをtrueとする。
  18. mnfdがundefinedであり、かつmxfdがundefinedならばhasFdをfalseとする。そうでなければ、hasFdをtrueとする。
  19. needSdをtrueとする。
  20. needFdをtrueとする。
  21. roundingPriorityが"auto"ならば、
    1. needSdをhasSdに設定する。
    2. needSdがtrueである、またはhasFdがfalseかつnotationが"compact"であるならば、
      1. needFdをfalseに設定する。
  22. needSdがtrueならば、
    1. hasSdがtrueならば、
      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. needFdがtrueならば、
    1. hasFdがtrueならば、
      1. mnfdを? DefaultNumberOption(mnfd, 0, 100, undefined)に設定する。
      2. mxfdを? DefaultNumberOption(mxfd, 0, 100, undefined)に設定する。
      3. mnfdがundefinedならば、mnfdをmin(mnfdDefault, mxfd)に設定する。
      4. そうでなく、mxfdがundefinedならば、mxfdをmax(mxfdDefault, mnfd)に設定する。
      5. そうでなく、mnfdがmxfdより大きいならば、RangeError例外を投げる。
      6. intlObj.[[MinimumFractionDigits]]をmnfdに設定する。
      7. intlObj.[[MaximumFractionDigits]]をmxfdに設定する。
    2. そうでなければ、
      1. intlObj.[[MinimumFractionDigits]]をmnfdDefaultに設定する。
      2. intlObj.[[MaximumFractionDigits]]をmxfdDefaultに設定する。
  24. needSdがfalseであり、かつneedFdがfalseならば、
    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. そうでなく、hasSdがtrueならば、
    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. currencyがundefinedならば、
    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. unitがundefinedならば、
    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]]をcurrencyのASCII-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-262の6.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. nfをthis値とする。
  2. 実装が4.3 Note 1の規範的任意コンストラクタモードをサポートするならば、
    1. nfを? UnwrapNumberFormat(nf)に設定する。
  3. ? RequireInternalSlot(nf, [[InitializedNumberFormat]])を実行する。
  4. optionsをOrdinaryObjectCreate(%Object.prototype%)とする。
  5. Table 28の各行(ヘッダ行を除く)について、表の順序で、次を行う:
    1. propertyKeyを現在の行のProperty値とする。
    2. valueを、その名前が現在の行のInternal Slot値であるnfの内部スロットの値とする。
    3. valueがundefinedでないならば、
      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. nf を this 値とする。
  2. 実装が 4.3 Note 1 の規範的な任意のコンストラクターモードをサポートする場合、次を実行する。
    1. nf を ? UnwrapNumberFormat(nf) に設定する。
  3. ? RequireInternalSlot(nf, [[InitializedNumberFormat]]) を実行する。
  4. nf.[[BoundFormat]] が undefined である場合、次を実行する。
    1. closure を、nf をキャプチャし、呼び出されたときに次の手順を実行する、パラメーター (value) を持つ新しい抽象クロージャーとする:
      1. x を ? ToIntlMathematicalValue(value) とする。
      2. FormatNumeric(nf, x) を返す。
    2. nf.[[BoundFormat]] を CreateBuiltinFunction(closure, 1, "", « ») に設定する。
  5. nf.[[BoundFormat]] を返す。
Note
返される関数は、Array.prototype.map やその他の関数に直接渡せるように nf に束縛されている。 これは、新しい機能ではもはや従われていない慣例の一部として歴史的な名残と見なされているが、既存のプログラムとの互換性を維持するために保持されている。

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

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

  1. nfをthis値とする。
  2. ? RequireInternalSlot(nf, [[InitializedNumberFormat]])を実行する。
  3. startがundefinedまたはendがundefinedならば、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. nfをthis値とする。
  2. ? RequireInternalSlot(nf, [[InitializedNumberFormat]])を実行する。
  3. startがundefinedまたはendがundefinedならば、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. nfをthis値とする。
  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-digits、more-precision、またはless-precisionである場合にのみ使用される。
  • [[MinimumSignificantDigits]]および[[MaximumSignificantDigits]]は、表示される最小および最大の有効桁数を示す正整数である。存在する場合、フォーマッタは指定された有効桁数を表示するために必要な数の小数部桁数を使用する。これらのプロパティは、[[RoundingType]]がsignificant-digits、more-precision、またはless-precisionである場合にのみ使用される。
  • [[UseGrouping]]は、桁区切り記号が使用される条件を示すBooleanまたはString値である。桁区切り記号の位置、および整形された数値に桁区切り記号を表示するかどうかは実装定義である。値"always"は、可能であれば桁区切り記号を表示するよう実装に示唆する。"min2"は、グループ内に少なくとも2桁がある場合、"auto"は、ロケールが整形された数値に桁区切り記号を使用することを好む場合である。値falseは桁区切り記号を無効にする。
  • [[RoundingType]]は、使用する丸め戦略を示す値fraction-digits、significant-digits、more-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 FormatNumericToString ( intlObj, x )

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

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

16.5.3 PartitionNumberPattern ( numberFormat, x )

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

  1. exponentを0とする。
  2. xがnot-a-numberならば、
    1. formattedStringをNaN値を示すILD String値とする。
  3. そうでなく、xがpositive-infinityならば、
    1. formattedStringを正の無限大を示すILD String値とする。
  4. そうでなく、xがnegative-infinityならば、
    1. formattedStringを負の無限大を示すILD String値とする。
  5. そうでなければ、
    1. xがnegative-zeroでないならば、
      1. Assert: xは数学的値である。
      2. numberFormat.[[Style]]が"percent"ならば、xを100 × xに設定する。
      3. exponentをComputeExponent(numberFormat, x)に設定する。
      4. xをx × 10-exponentに設定する。
    2. formatNumberResultをFormatNumericToString(numberFormat, x)とする。
    3. formattedStringをformatNumberResult.[[FormattedString]]とする。
    4. xをformatNumberResult.[[RoundedNumber]]に設定する。
  6. patternをGetNumberFormatPattern(numberFormat, x)とする。
  7. resultを新しい空のListとする。
  8. patternPartsをPartitionPattern(pattern)とする。
  9. patternPartsの各Record { [[Type]], [[Value]] } patternPartについて、次を行う:
    1. partTypeをpatternPart.[[Type]]とする。
    2. partTypeが"literal"ならば、
      1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }をresultに追加する。
    3. そうでなく、partTypeが"number"ならば、
      1. notationSubPartsをPartitionNotationSubPattern(numberFormat, x, formattedString, exponent)とする。
      2. resultをresultとnotationSubPartsのリスト連結に設定する。
    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. unitをnumberFormat.[[Unit]]とする。
      2. unitDisplayをnumberFormat.[[UnitDisplay]]とする。
      3. unitStringを、unitDisplay形式でxの前にあるunitを表すILD String値とする。これは、異なる複数形を持つ言語ではxに依存することがある。
      4. Record { [[Type]]: "unit", [[Value]]: unitString }をresultに追加する。
    8. そうでなく、partTypeが"unitSuffix"であり、かつnumberFormat.[[Style]]が"unit"ならば、
      1. unitをnumberFormat.[[Unit]]とする。
      2. unitDisplayをnumberFormat.[[UnitDisplay]]とする。
      3. unitStringを、unitDisplay形式でxの後にあるunitを表すILD String値とする。これは、異なる複数形を持つ言語ではxに依存することがある。
      4. Record { [[Type]]: "unit", [[Value]]: unitString }をresultに追加する。
    9. そうでなく、partTypeが"currencyCode"であり、かつnumberFormat.[[Style]]が"currency"ならば、
      1. currencyをnumberFormat.[[Currency]]とする。
      2. Record { [[Type]]: "currency", [[Value]]: currency }をresultに追加する。
    10. そうでなく、partTypeが"currencyPrefix"であり、かつnumberFormat.[[Style]]が"currency"ならば、
      1. currencyをnumberFormat.[[Currency]]とする。
      2. currencyDisplayをnumberFormat.[[CurrencyDisplay]]とする。
      3. currencyStringを、currencyDisplay形式でxの前にあるcurrencyを表すILD String値とする。これは、異なる複数形を持つ言語ではxに依存することがある。
      4. Record { [[Type]]: "currency", [[Value]]: currencyString }をresultに追加する。
    11. そうでなく、partTypeが"currencySuffix"であり、かつnumberFormat.[[Style]]が"currency"ならば、
      1. currencyをnumberFormat.[[Currency]]とする。
      2. currencyDisplayをnumberFormat.[[CurrencyDisplay]]とする。
      3. currencyStringを、currencyDisplay形式でxの後にあるcurrencyを表すILD String値とする。これは、異なる複数形を持つ言語ではxに依存することがある。実装がcurrencyのそのような表現を持たない場合は、currency自体を使用する。
      4. Record { [[Type]]: "currency", [[Value]]: currencyString }をresultに追加する。
    12. そうでなければ、
      1. unknownをxおよびpartTypeに基づくILND Stringとする。
      2. Record { [[Type]]: "unknown", [[Value]]: unknown }をresultに追加する。
  10. resultを返す。

16.5.4 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)を持つRecordのList. xは丸めが適用された後のIntl数学的値であり、formattedStringは中間の整形済み文字列である。 numberFormatの有効なロケールおよび整形オプションに従って、数値および表記に対応する部分を作成する。 It performs the following steps when called:

  1. result を新しい空の List とする。
  2. x が not-a-number である場合、
    1. Record { [[Type]]: "nan", [[Value]]: formattedString } を result に追加する。
  3. そうではなく、x が positive-infinity または negative-infinity である場合、
    1. Record { [[Type]]: "infinity", [[Value]]: formattedString } を result に追加する。
  4. それ以外の場合、
    1. notationSubPattern を GetNotationSubPattern(numberFormat, exponent) とする。
    2. patternParts を PartitionPattern(notationSubPattern) とする。
    3. patternParts の各 Record { [[Type]], [[Value]] } patternPart について、次を行う。
      1. partType を patternPart.[[Type]] とする。
      2. partType が "literal" である場合、
        1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] } を result に追加する。
      3. そうではなく、partType が "number" である場合、
        1. numberFormat.[[NumberingSystem]] が、以下の Table 30 の Numbering System 列にある値のいずれかと一致する場合、
          1. digits を、一致する Table 30 の行の Digits 列で指定されたコードポイントを要素とする List とする。
          2. Assert: digits の長さは 10 である。
          3. transliterated を空の String とする。
          4. length を formattedString の長さとする。
          5. position を 0 とする。
          6. position < length である間、次を繰り返す。
            1. c を formattedString 内のインデックス position にあるコード単位とする。
            2. 0x0030 ≤ c ≤ 0x0039 である場合、
              1. NOTE: c は ASCII 数字である。
              2. i を c - 0x0030 とする。
              3. c を CodePointsToString(« digits[i] ») に設定する。
            3. transliterated を transliterated と c の文字列連結に設定する。
            4. position を position + 1 に設定する。
          7. formattedString を transliterated に設定する。
        2. それ以外の場合、
          1. 実装依存のアルゴリズムを使用して、formattedString を指定された記数法における formattedString の適切な表現に対応付ける。
        3. decimalSepIndex を StringIndexOf(formattedString, ".", 0) とする。
        4. decimalSepIndex が not-found ではなく、かつ decimalSepIndex > 0 である場合、
          1. intDigits を formattedString の 0 から decimalSepIndex までの部分文字列とする。
          2. fractionDigits を formattedString の decimalSepIndex + 1 から始まる部分文字列とする。
        5. それ以外の場合、
          1. intDigits を formattedString とする。
          2. fractionDigits を undefined とする。
        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. fractionDigits が undefined でない場合、
          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 に依存する場合がある。実装はこの string を提供できなければならない。そうでなければ、パターンに "{compactSymbol}" プレースホルダーが存在することはない。
        2. Record { [[Type]]: "compact", [[Value]]: compactSymbol } を result に追加する。
      5. そうではなく、partType が "compactName" である場合、
        1. compactName を、長い形式で exponent を表す ILD string とする。これは、複数形が異なる言語では x に依存する場合がある。実装はこの string を提供できなければならない。そうでなければ、パターンに "{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. exponent = 0 である場合、exponentResult を "0" とする。それ以外の場合、exponentResult を exponent の十進表現の数字を順番どおりに並べた String とする。ただし、先頭にゼロを含めない。
        3. Record { [[Type]]: "exponentInteger", [[Value]]: exponentResult } を result に追加する。
      8. それ以外の場合、
        1. unknown を、x および 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.5 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. partsをPartitionNumberPattern(numberFormat, x)とする。
  2. resultを空のStringとする。
  3. partsの各Record { [[Type]], [[Value]] } partについて、次を行う:
    1. resultをresultとpart.[[Value]]の文字列連結に設定する。
  4. resultを返す。

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

16.5.7 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列からの仕様型) and returns フィールド[[FormattedString]](String)、[[RoundedNumber]](数学的値)、[[IntegerDigitsCount]](整数)、および[[RoundingMagnitude]](整数)を持つRecord.

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

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

It performs the following steps when called:

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

16.5.8 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列からの仕様型) and returns フィールド[[FormattedString]](String)、[[RoundedNumber]](数学的値)、[[IntegerDigitsCount]](整数)、および[[RoundingMagnitude]](整数)を持つRecord.

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

ToRawFixedFn(n, f) = n × 10–f

It performs the following steps when called:

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

16.5.9 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.10 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. resolvedLocaleDataをnumberFormat.[[LocaleData]]とする。
  2. patternsをresolvedLocaleData.[[patterns]]とする。
  3. Assert: patternsはRecordである(16.2.3参照)。
  4. styleをnumberFormat.[[Style]]とする。
  5. styleが"percent"ならば、
    1. patternsをpatterns.[[percent]]に設定する。
  6. そうでなく、styleが"unit"ならば、
    1. unitをnumberFormat.[[Unit]]とする。
    2. unitDisplayをnumberFormat.[[UnitDisplay]]とする。
    3. patternsをpatterns.[[unit]]に設定する。
    4. patternsがフィールド[[<unit>]]を持たないならば、
      1. unitを"fallback"に設定する。
    5. patternsをpatterns.[[<unit>]]に設定する。
    6. patternsをpatterns.[[<unitDisplay>]]に設定する。
  7. そうでなく、styleが"currency"ならば、
    1. currencyをnumberFormat.[[Currency]]とする。
    2. currencyDisplayをnumberFormat.[[CurrencyDisplay]]とする。
    3. currencySignをnumberFormat.[[CurrencySign]]とする。
    4. patternsをpatterns.[[currency]]に設定する。
    5. patternsがフィールド[[<currency>]]を持たないならば、
      1. currencyを"fallback"に設定する。
    6. patternsをpatterns.[[<currency>]]に設定する。
    7. patternsをpatterns.[[<currencyDisplay>]]に設定する。
    8. patternsをpatterns.[[<currencySign>]]に設定する。
  8. そうでなければ、
    1. Assert: styleは"decimal"である。
    2. patternsをpatterns.[[decimal]]に設定する。
  9. xがnegative-infinityならば、
    1. categoryをnegative-non-zeroとする。
  10. そうでなく、xがnegative-zeroならば、
    1. categoryをnegative-zeroとする。
  11. そうでなく、xがnot-a-numberならば、
    1. categoryをpositive-zeroとする。
  12. そうでなく、xがpositive-infinityならば、
    1. categoryをpositive-non-zeroとする。
  13. そうでなければ、
    1. Assert: xは数学的値である。
    2. x < 0ならば、
      1. categoryをnegative-non-zeroとする。
    3. そうでなく、x > 0ならば、
      1. categoryをpositive-non-zeroとする。
    4. そうでなければ、
      1. categoryをpositive-zeroとする。
  14. signDisplayをnumberFormat.[[SignDisplay]]とする。
  15. signDisplayが"never"ならば、
    1. patternをpatterns.[[zeroPattern]]とする。
  16. そうでなく、signDisplayが"auto"ならば、
    1. categoryがpositive-non-zeroまたはpositive-zeroならば、
      1. patternをpatterns.[[zeroPattern]]とする。
    2. そうでなければ、
      1. patternをpatterns.[[negativePattern]]とする。
  17. そうでなく、signDisplayが"always"ならば、
    1. categoryがpositive-non-zeroまたはpositive-zeroならば、
      1. patternをpatterns.[[positivePattern]]とする。
    2. そうでなければ、
      1. patternをpatterns.[[negativePattern]]とする。
  18. そうでなく、signDisplayが"exceptZero"ならば、
    1. categoryがpositive-zeroまたはnegative-zeroならば、
      1. patternをpatterns.[[zeroPattern]]とする。
    2. そうでなく、categoryがpositive-non-zeroならば、
      1. patternをpatterns.[[positivePattern]]とする。
    3. そうでなければ、
      1. patternをpatterns.[[negativePattern]]とする。
  19. そうでなければ、
    1. Assert: signDisplayは"negative"である。
    2. categoryがnegative-non-zeroならば、
      1. patternをpatterns.[[negativePattern]]とする。
    3. そうでなければ、
      1. patternをpatterns.[[zeroPattern]]とする。
  20. patternを返す。

16.5.11 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. resolvedLocaleDataをnumberFormat.[[LocaleData]]とする。
  2. notationSubPatternsをresolvedLocaleData.[[notationSubPatterns]]とする。
  3. Assert: notationSubPatternsはRecordである(16.2.3参照)。
  4. notationをnumberFormat.[[Notation]]とする。
  5. notationが"scientific"またはnotationが"engineering"ならば、
    1. notationSubPatterns.[[scientific]]を返す。
  6. そうでなく、exponentが0でないならば、
    1. Assert: notationは"compact"である。
    2. compactDisplayをnumberFormat.[[CompactDisplay]]とする。
    3. compactPatternsをnotationSubPatterns.[[compact]].[[<compactDisplay>]]とする。
    4. compactPatterns.[[<exponent>]]を返す。
  7. そうでなければ、
    1. "{number}"を返す。

16.5.12 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. magnitude を floor(log10(x)) とする。
  4. exponent を ComputeExponentForMagnitude(numberFormat, magnitude) とする。
  5. x を x × 10-exponent に設定する。
  6. formatNumberResult を FormatNumericToString(numberFormat, x) とする。
  7. formatNumberResult.[[RoundedNumber]] = 0 なら、
    1. exponent を返す。
  8. newMagnitude を floor(log10(formatNumberResult.[[RoundedNumber]])) とする。
  9. newMagnitude が magnitude - exponent なら、
    1. exponent を返す。
  10. ComputeExponentForMagnitude(numberFormat, magnitude + 1) を返す。

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

16.5.14 Runtime Semantics: StringIntlMV

The syntax-directed operation StringIntlMV takes no arguments.

Note

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

It is defined piecewise over the following productions:

StringNumericLiteral ::: StrWhiteSpaceopt
  1. 0を返す。
StringNumericLiteral ::: StrWhiteSpaceopt StrNumericLiteral StrWhiteSpaceopt
  1. StrNumericLiteralのStringIntlMVを返す。
StrNumericLiteral ::: NonDecimalIntegerLiteral
  1. NonDecimalIntegerLiteralのMVを返す。
StrDecimalLiteral ::: - StrUnsignedDecimalLiteral
  1. aをStrUnsignedDecimalLiteralのStringIntlMVとする。
  2. aが0ならば、negative-zeroを返す。
  3. aがpositive-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が存在するならばeをExponentPartのMVとする。そうでなければeを0とする。
  5. (a + (b × 10-n)) × 10eを返す。
StrUnsignedDecimalLiteral ::: . DecimalDigits ExponentPartopt
  1. bをDecimalDigitsのMVとする。
  2. ExponentPartが存在するならばeをExponentPartのMVとする。そうでなければeを0とする。
  3. nをDecimalDigits内のコードポイント数とする。
  4. b × 10e - nを返す。
StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPartopt
  1. aをDecimalDigitsのMVとする。
  2. ExponentPartが存在するならばeをExponentPartのMVとする。そうでなければeを0とする。
  3. a × 10eを返す。

16.5.15 ToIntlMathematicalValue ( value )

The abstract operation ToIntlMathematicalValue takes argument value (ECMAScript言語値) and returns Intl数学的値を含む通常完了またはthrow完了. valueをIntl数学的値へ変換して返す。これは数学的値にpositive-infinity、negative-infinity、not-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. strをprimValueとする。
  4. そうでなければ、
    1. xを? ToNumber(primValue)とする。
    2. xが-0𝔽ならば、negative-zeroを返す。
    3. strをNumber::toString(x, 10)とする。
  5. textをStringToCodePoints(str)とする。
  6. literalをParseText(text, StringNumericLiteral)とする。
  7. literalがエラーのListならば、not-a-numberを返す。
  8. intlMVをliteralのStringIntlMVとする。
  9. intlMVが数学的値ならば、
    1. roundedをRoundMVResult(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.16 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を返す(signがnegativeならば負、それ以外ならば正)。 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.17 ApplyUnsignedRoundingMode ( x, r1, r2, unsignedRoundingMode )

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

  1. xがr1ならば、r1を返す。
  2. Assert: r1 < x < r2である。
  3. unsignedRoundingModeがzeroならば、r1を返す。
  4. unsignedRoundingModeがinfinityならば、r2を返す。
  5. d1をx – r1とする。
  6. d2をr2 – xとする。
  7. d1 < d2ならば、r1を返す。
  8. d2 < d1ならば、r2を返す。
  9. Assert: d1はd2である。
  10. unsignedRoundingModeがhalf-zeroならば、r1を返す。
  11. unsignedRoundingModeがhalf-infinityならば、r2を返す。
  12. Assert: unsignedRoundingModeはhalf-evenである。
  13. cardinalityを(r1 / (r2 – r1)) modulo 2とする。
  14. cardinalityが0ならば、r1を返す。
  15. r2を返す。

16.5.18 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)を持つRecordのListを含む通常完了、またはthrow完了. x、y、およびnumberFormatの整形オプションに従って、ローカライズされた数値範囲の部分を作成する。 It performs the following steps when called:

  1. xがnot-a-numberまたはyがnot-a-numberならば、RangeError例外を投げる。
  2. xResultをPartitionNumberPattern(numberFormat, x)とする。
  3. yResultをPartitionNumberPattern(numberFormat, y)とする。
  4. FormatNumeric(numberFormat, x)がFormatNumeric(numberFormat, y)ならば、
    1. approximateResultをFormatApproximately(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.19 FormatApproximately ( numberFormat, result )

The abstract operation FormatApproximately takes arguments numberFormat (Intl.NumberFormat) and result (フィールド[[Type]](String)および[[Value]](String)を持つRecordのList) and returns フィールド[[Type]](String)および[[Value]](String)を持つRecordのList. 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"を持つ場合、新しいRecordはresultの最初の要素の前に挿入されることがある。
  3. resultを返す。

16.5.20 CollapseNumberRange ( numberFormat, result )

The implementation-defined abstract operation CollapseNumberRange takes arguments numberFormat (Intl.NumberFormat) and result (フィールド[[Type]](String)、[[Value]](String)、および[[Source]](String)を持つRecordのList) and returns フィールド[[Type]](String)、[[Value]](String)、および[[Source]](String)を持つRecordのList. 有効なロケールおよびnumberFormatの整形オプションに従って、冗長な情報を削除し、内部不整合を解決し、必要に応じて文字を置換し、必要に応じて空白を挿入することにより、result(PartitionNumberRangePattern内で構築されるRecordのListでなければならない)を変更する。その後、結果の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.21 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. resultをresultとpart.[[Value]]の文字列連結に設定する。
  4. resultを返す。

16.5.22 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. partObjをOrdinaryObjectCreate(%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. n を n + 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. optionsをoptionsResolution.[[Options]]に設定する。
  5. resolvedLocaleをoptionsResolution.[[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. prをthis値とする。
  2. ? RequireInternalSlot(pr, [[InitializedPluralRules]])を実行する。
  3. optionsをOrdinaryObjectCreate(%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. valueをCreateArrayFromList(pluralCategories)とする。
    3. そうでなければ、
      1. valueを、その名前が現在の行のInternal Slot値であるprの内部スロットの値とする。
    4. valueがundefinedでないならば、
      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. prをthis値とする。
  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. prをthis値とする。
  2. ? RequireInternalSlot(pr, [[InitializedPluralRules]])を実行する。
  3. startがundefinedまたはendがundefinedならば、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-digits、significant-digits、more-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についてtype、notation、および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. nがnot-a-numberならば、
    1. formattedStringをNaN値を示すILD String値とする。
    2. Record { [[PluralCategory]]: "other", [[FormattedString]]: formattedString }を返す。
  2. nがpositive-infinityならば、
    1. formattedStringを正の無限大を示すILD String値とする。
    2. Record { [[PluralCategory]]: "other", [[FormattedString]]: formattedString }を返す。
  3. nがnegative-infinityならば、
    1. formattedStringを負の無限大を示すILD String値とする。
    2. Record { [[PluralCategory]]: "other", [[FormattedString]]: formattedString }を返す。
  4. resをFormatNumericToString(pluralRules, n)とする。
  5. formattedStringをres.[[FormattedString]]とする。
  6. localeをpluralRules.[[Locale]]とする。
  7. typeをpluralRules.[[Type]]とする。
  8. notationをpluralRules.[[Notation]]とする。
  9. compactDisplayをpluralRules.[[CompactDisplay]]とする。
  10. pluralCategoryをPluralRuleSelect(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についてtype、notation、および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. xがnot-a-numberまたはyがnot-a-numberならば、RangeError例外を投げる。
  2. xResultをResolvePlural(pluralRules, x)とする。
  3. yResultをResolvePlural(pluralRules, y)とする。
  4. xResult.[[FormattedString]]がyResult.[[FormattedString]]ならば、
    1. xResult.[[PluralCategory]]を返す。
  5. localeをpluralRules.[[Locale]]とする。
  6. typeをpluralRules.[[Type]]とする。
  7. notationをpluralRules.[[Notation]]とする。
  8. compactDisplayをpluralRules.[[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. options を optionsResolution.[[Options]] に設定する。
  5. resolvedLocale を optionsResolution.[[ResolvedLocale]] とする。
  6. locale を resolvedLocale.[[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. nfOptions を OrdinaryObjectCreate(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. relativeTimeFormat を this 値とする。
  2. ? RequireInternalSlot(relativeTimeFormat, [[InitializedRelativeTimeFormat]]) を実行する。
  3. options を OrdinaryObjectCreate(%Object.prototype%) とする。
  4. Table 33 の各行について、ヘッダー行を除き、表の順序で、次を行う。
    1. propertyKey を現在の行の Property 値とする。
    2. value を、現在の行の Internal Slot 値を名前とする relativeTimeFormat の内部スロットの値とする。
    3. Assert: value は undefined でない。
    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. relativeTimeFormat を this 値とする。
  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. relativeTimeFormat を this 値とする。
  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) を持つ Records の List を含む正常完了、または throw 完了. 返される List は、relativeTimeFormat の実効ロケールおよび整形オプションに従って value を表す。 It performs the following steps when called:

  1. value が NaN、+∞𝔽、または -∞𝔽 なら、RangeError 例外を投げる。
  2. unit を ? SingularRelativeTimeUnit(unit) に設定する。
  3. fields を relativeTimeFormat.[[LocaleData]] とする。
  4. patterns を fields.[[<unit>]] とする。
  5. style を relativeTimeFormat.[[Style]] とする。
  6. style が "short" または "narrow" なら、
    1. key を unit、"-"、および style の文字列連結とする。
    2. fields がフィールド [[<key>]] を持つなら、patterns を fields.[[<key>]] に設定する。
  7. relativeTimeFormat.[[Numeric]] が "auto" なら、
    1. valueString を ! ToString(value) とする。
    2. patterns がフィールド [[<valueString>]] を持つなら、
      1. result を patterns.[[<valueString>]] とする。
      2. Record { [[Type]]: "literal", [[Value]]: result, [[Unit]]: empty } を含む List を返す。
  8. value が -0𝔽 または value < -0𝔽 なら、
    1. tense を "past" とする。
  9. そうでなければ、
    1. tense を "future" とする。
  10. tensePatterns を patterns.[[<tense>]] とする。
  11. formattedValue を PartitionNumberPattern(relativeTimeFormat.[[NumberFormat]], ℝ(value)) とする。
  12. pluralCategory を ResolvePlural(relativeTimeFormat.[[PluralRules]], value).[[PluralCategory]] とする。
  13. pattern を tensePatterns.[[<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 を表す Records の List) and returns フィールド [[Type]] (String)、[[Value]] (String)、および [[Unit]] (String または empty) を持つ Records の List. It performs the following steps when called:

  1. patternParts を PartitionPattern(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" } ») を返す。
これは、次のような Records の List を返す « { [[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. result を result と part.[[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. partObj を OrdinaryObjectCreate(%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. n を n + 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. options を optionsResolution.[[Options]] に設定する。
  6. resolvedLocale を optionsResolution.[[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. segmenter を this 値とする。
  2. ? RequireInternalSlot(segmenter, [[InitializedSegmenter]]) を実行する。
  3. options を OrdinaryObjectCreate(%Object.prototype%) とする。
  4. Table 34 の各行について、ヘッダー行を除き、表の順序で、次を行う。
    1. propertyKey を現在の行の Property 値とする。
    2. value を、現在の行の Internal Slot 値を名前とする segmenter の内部スロットの値とする。
    3. Assert: value は undefined でない。
    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. segmenter を this 値とする。
  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. segments を OrdinaryObjectCreate(%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. segments を this 値とする。
  2. ? RequireInternalSlot(segments, [[SegmentsSegmenter]]) を実行する。
  3. segmenter を segments.[[SegmentsSegmenter]] とする。
  4. string を segments.[[SegmentsString]] とする。
  5. length を string の長さとする。
  6. n を ? ToIntegerOrInfinity(index) とする。
  7. n < 0 または n ≥ length なら、undefined を返す。
  8. startIndex を FindBoundary(segmenter, string, n, before) とする。
  9. endIndex を FindBoundary(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. segments を this 値とする。
  2. ? RequireInternalSlot(segments, [[SegmentsSegmenter]]) を実行する。
  3. segmenter を segments.[[SegmentsSegmenter]] とする。
  4. string を segments.[[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. iterator を OrdinaryObjectCreate(%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. iterator を this 値とする。
  2. ? RequireInternalSlot(iterator, [[IteratingSegmenter]]) を実行する。
  3. segmenter を iterator.[[IteratingSegmenter]] とする。
  4. string を iterator.[[IteratedString]] とする。
  5. startIndex を iterator.[[IteratedStringNextSegmentCodeUnitIndex]] とする。
  6. length を string の長さとする。
  7. startIndex ≥ length なら、
    1. CreateIteratorResultObject(undefined, true) を返す。
  8. endIndex を FindBoundary(segmenter, string, startIndex, after) とする。
  9. iterator.[[IteratedStringNextSegmentCodeUnitIndex]] を endIndex に設定する。
  10. segmentData を CreateSegmentDataObject(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. length を string の長さとする。
  2. Assert: endIndex ≤ length である。
  3. Assert: startIndex < endIndex である。
  4. result を OrdinaryObjectCreate(%Object.prototype%) とする。
  5. segment を string の startIndex から endIndex までの部分文字列とする。
  6. ! CreateDataPropertyOrThrow(result, "segment", segment) を実行する。
  7. ! CreateDataPropertyOrThrow(result, "index", 𝔽(startIndex)) を実行する。
  8. ! CreateDataPropertyOrThrow(result, "input", string) を実行する。
  9. granularity を segmenter.[[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. length を string の長さとする。
  2. Assert: startIndex < length である。
  3. locale を segmenter.[[Locale]] とする。
  4. granularity を segmenter.[[SegmenterGranularity]] とする。
  5. direction が before なら、
    1. ロケール locale およびテキスト要素粒度 granularity を使用して、先頭から最大で startIndex 個のコード単位が前にある最後のセグメンテーション境界を string 内で検索する。
    2. 境界が見つかったなら、その前にある string 内のコード単位数を返す。
    3. 0 を返す。
  6. Assert: direction は after である。
  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-262の22.1.3.12で提供される定義を置き換える。

localeCompareメソッドが引数thatおよび省略可能な引数locales、optionsとともに呼び出されるとき、次の手順が実行される:

  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-262の22.1.3.26で提供される定義を置き換える。

この関数は、ECMA-262の6.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-262の6.1.4で述べられるとおり、stringをUTF-16符号化コードポイントの列として解釈し、targetCaseへのILD変換の結果を新しいString値として返す。 It performs the following steps when called:

  1. requestedLocalesを? CanonicalizeLocaleList(locales)とする。
  2. requestedLocalesが空のListでないならば、
    1. requestedLocaleをrequestedLocales[0]とする。
  3. そうでなければ、
    1. requestedLocaleをDefaultLocale()とする。
  4. availableLocalesを、Unicode Character Databaseが言語依存のケースマッピングを含む言語タグを含むAvailable Locales Listとする。実装が追加のロケール依存ケースマッピングをサポートする場合、availableLocalesはそれらに対応する言語タグも含むべきである。
  5. matchをLookupMatchingLocaleByPrefix(availableLocales, « requestedLocale »)とする。
  6. matchがundefinedでないならばlocaleをmatch.[[locale]]とし、そうでなければlocaleを"und"とする。
  7. codePointsをStringToCodePoints(string)とする。
  8. targetCaseがlowerならば、
    1. newCodePointsを、localeを使用する実装由来のアルゴリズムまたはUnicode Default Case Conversionアルゴリズムに従ったcodePointsの小文字変換の結果を要素とするListとする。
  9. そうでなければ、
    1. Assert: targetCaseはupperである。
    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
一部のコードポイントのケースマッピングは複数のコードポイントを生成することがあり、そのため結果は入力と同じ長さにならない場合がある。toLocaleUpperCaseとtoLocaleLowerCaseはいずれも文脈依存の挙動を持つため、これらの関数は対称ではない。言い換えると、s.toLocaleUpperCase().toLocaleLowerCase()は必ずしもs.toLocaleLowerCase()と等しくなく、s.toLocaleLowerCase().toLocaleUpperCase()は必ずしもs.toLocaleUpperCase()と等しくない。

20.1.3 String.prototype.toLocaleUpperCase ( [ locales ] )

この定義は、ECMA-262の22.1.3.27で提供される定義を置き換える。

この関数は、ECMA-262の6.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-262の21.1.3で定義される抽象操作thisNumberValueを参照する。

20.2.1 Number.prototype.toLocaleString ( [ locales [ , options ] ] )

この定義は、ECMA-262の21.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-262の21.2.3で定義される抽象操作thisBigIntValueを参照する。

20.3.1 BigInt.prototype.toLocaleString ( [ locales [ , options ] ] )

この定義は、ECMA-262の21.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-262の21.4.4で定義される抽象操作thisTimeValueを参照する。

20.4.1 Date.prototype.toLocaleString ( [ locales [ , options ] ] )

この定義は、ECMA-262の21.4.4.39で提供される定義を置き換える。

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

  1. dateObjをthis値とする。
  2. ? RequireInternalSlot(dateObj, [[DateValue]])を実行する。
  3. xをdateObj.[[DateValue]]とする。
  4. xがNaNならば、"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. dateObjをthis値とする。
  2. ? RequireInternalSlot(dateObj, [[DateValue]])を実行する。
  3. xをdateObj.[[DateValue]]とする。
  4. xがNaNならば、"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. dateObjをthis値とする。
  2. ? RequireInternalSlot(dateObj, [[DateValue]])を実行する。
  3. xをdateObj.[[DateValue]]とする。
  4. xがNaNならば、"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. resultをresultとseparatorの文字列連結に設定する。
    2. elementを? Get(array, ! ToString(𝔽(k)))とする。
    3. elementがundefinedでもnullでもないならば、
      1. elementStringを? ToString(? Invoke(element, "toLocaleString", « locales, options »))とする。
      2. resultをresultとelementStringの文字列連結に設定する。
    4. kをk + 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.