Draft ECMA-402 / July 10, 2026 ECMAScript® 2027 Internationalization API Specification
イントロダクション
この仕様のソースは 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 をスローする代わりに実装依存の動作をすることが許可されている:
すべてのコンストラクターおよびsupportedLocalesOfメソッドのoptions プロパティ"localeMatcher" 。
Collatorコンストラクターのoptions プロパティ"usage" および"sensitivity" 。
NumberFormatコンストラクターのoptions プロパティ"style" 、"currencyDisplay" 、"notation" 、"compactDisplay" 、"signDisplay" 、"currencySign" 、および"unitDisplay" 。
NumberFormatコンストラクターのoptions プロパティ"minimumIntegerDigits" 、"minimumFractionDigits" 、"maximumFractionDigits" 、"minimumSignificantDigits" 、および"maximumSignificantDigits" について、追加の値が指定された制限よりも高い整数値として解釈される場合。
DateTimeFormatコンストラクターのoptions プロパティはTable 16 に記載されている。
DateTimeFormatコンストラクターのoptions プロパティ"formatMatcher" 。
PluralRulesコンストラクターのoptions プロパティ"minimumIntegerDigits" 、"minimumFractionDigits" 、"maximumFractionDigits" 、および"minimumSignificantDigits" について、追加の値が指定された制限よりも高い整数値として解釈される場合。
PluralRulesコンストラクターのoptions プロパティ"type" 。
RelativeTimeFormatコンストラクターのoptions プロパティ"style" および"numeric" 。
DisplayNamesコンストラクターのoptions プロパティ"style" および"type" 。
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つの方法で利用できます:
サービスコンストラクタ を直接使用してオブジェクトを構築し、優先言語リストと動作を構成するオプションを指定します。オブジェクトは主要な関数(compare、select、formatなど)を提供し、繰り返し呼び出すことができます。また、resolvedOptions関数も提供され、アプリケーションはオブジェクトの正確な構成を知ることができます。
上記の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: よく知られた組み込みオブジェクト(拡張)
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 Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance で定義されるUnicode BCP 47ロケール識別子 を使用してロケールを識別し、そのアルゴリズムはSection 3 Unicode Language and Locale Identifiers の文法で定義されるUnicodeロケール非終端記号 を参照する。
そのような各識別子は言語タグ とも呼ぶことができ、実際にはBCP 47 でその用語が使用される意味で有効な言語タグである。
Unicode Technical Standard #35 Part 1 Core, Section 3.2.1 Canonical Unicode Locale Identifiers で規定される正準形式のロケール識別子は、「Unicode正規化済みロケール識別子 」と呼ばれる。
ロケール識別子は、大文字小文字を区別しないUnicode Basic Latin英数字のサブタグ を"-" (U+002D HYPHEN-MINUS)文字で区切ったものからなり、単一文字のサブタグ は「singletonサブタグ 」と呼ばれる。
Unicode Technical Standard #35 Part 1 Core, Section 3.6 Unicode BCP 47 U Extension サブタグ 列は広く使用され、「 Unicodeロケール拡張シーケンス 」という用語は、言語タグのうちunicode_locale_extensions Unicodeロケール非終端記号により一致させることができ、かつ"-x-…" 私用サブタグ列 の一部ではない最長のsubstring を表す。これは"-u-" で始まり、直後に続くsingletonサブタグでないすべてのサブタグ を、それらの前の"-" 区切り文字とともに含む。例えば、"en-US-u-fw-mon-x-u-ex-foobar" のUnicodeロケール拡張シーケンス は"-u-fw-mon" である。
すべての整形式言語タグ は、この仕様で定義されるAPIでの使用に適しているが、実装は、それらを検証するためにUnicode Common Locale Data Repository(CLDR )データを使用することを要求されない。実装が十分なローカライズを伴ってサポートするロケール、したがって言語タグの集合は実装定義である。Intlコンストラクタ は、要求された言語タグをそれぞれの実装がサポートするロケールへ対応付ける。
6.2.1 IsWellFormedLanguageTag ( locale )
The abstract operation IsWellFormedLanguageTag takes argument locale (String) and returns Boolean. locale がunicode_bcp47_locale_id の整形式性制約に適合する整形式言語タグ であるかどうかを判定する。locale が意味のある意味論を伝えるかどうかは考慮せず、エイリアス化されたサブタグ とその推奨置換サブタグ を区別せず、正準の大文字小文字やサブタグ 順序も要求しない。 It performs the following steps when called:
lowerLocale をlocale のASCII-lowercase とする。lowerLocale がunicode_locale_id Unicodeロケール非終端記号 により一致させることができないならば、false を返す。lowerLocale がUnicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance で述べられる後方互換性構文のいずれかを使用するならば、false を返す。baseName をGetLocaleBaseName (lowerLocale )とする。variants をGetLocaleVariants (baseName )とする。variants がundefined でないならば、variants が重複サブタグ を含むならば、false を返す。extensions をbaseName の後に続くlowerLocale の接尾部とする。NOTE: pu_extensions Unicodeロケール非終端記号 により一致する"-x-…" 私用サブタグ 列は無視されなければならないが、後続内容を伴わない孤立した末尾の"x" サブタグ は、以下の検査には影響しない。 puIndex をStringIndexOf (extensions , "-x-" , 0)とする。puIndex がnot-found でないならば、extensions をextensions の0からpuIndex までの部分文字列に設定する。extensions が空のStringでないならば、extensions が重複するsingletonサブタグ を含むならば、false を返す。transformExtension を、transformed_extensions Unicodeロケール非終端記号 により一致するextensions の最長のsubstring とする。そのようなsubstring がない場合は、true を返す。Assert : transformExtension の0から3までの部分文字列は"-t-" である。tPrefix をtransformExtension の3からの部分文字列とする。tlang を、tlang Unicodeロケール非終端記号 により一致するtPrefix の最長の接頭部とする。そのような接頭部がない場合は、true を返す。tlangVariants をGetLocaleVariants (tlang )とする。tlangVariants がundefined でないならば、tlangVariants が重複サブタグ を含むならば、false を返す。true を返す。
6.2.2 CanonicalizeUnicodeLocaleId ( locale )
The abstract operation CanonicalizeUnicodeLocaleId takes argument locale (言語タグ ) and returns Unicode正規化済みロケール識別子 . locale の正準かつ大文字小文字を正規化した形式を返す。 It performs the following steps when called:
localeId を、Unicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalization に従ってlocale を正準形式へ変換するためにProcessing LocaleIds アルゴリズムを実行した結果のString値とする。localeId がUnicodeロケール拡張シーケンス であるsubstring を含むならば、extension を、localeId 内のUnicodeロケール拡張シーケンス のsubstring からなるString値とする。newExtension を"-u" とする。components をUnicodeExtensionComponents (extension )とする。components .[[Attributes]] の各要素attr について、次を行う:newExtension をnewExtension 、"-" 、およびattr の文字列連結に設定する。components .[[Keywords]] の各Record { [[Key]] , [[Value]] } keyword について、次を行う:newExtension をnewExtension 、"-" 、およびkeyword .[[Key]] の文字列連結に設定する。keyword .[[Value]] が空のStringでないならば、newExtension をnewExtension 、"-" 、およびkeyword .[[Value]] の文字列連結に設定する。Assert : newExtension は"-u" でない。localeId を、substring extension の最初の出現をnewExtension で置き換えたlocaleId のコピーに設定する。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:
currency の長さが3でないならば、false を返す。normalized をcurrency のASCII-uppercase とする。normalized が0x0041から0x005A(Unicode文字LATIN CAPITAL LETTER AからLATIN CAPITAL LETTER Zに対応)の範囲外のコード単位を含むならば、false を返す。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 でなければならない:
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 で提供される定義を置き換える。
identifiers を、IANA Time Zone Database内の各Zone名またはLink名のString値を含むList とする。Assert : identifiers のいかなる要素も、他のいかなる要素に対してもASCII-case-insensitive match ではない。identifiers を辞書式コード単位順序に従ってソートする。result を新しい空のList とする。identifiers の各要素identifier について、次を行う:primary をidentifier とする。identifier がIANA Time Zone Database内のLink名であり、かつidentifier がIANA Time Zone Databaseのzone.tabの“TZ”列に存在しないならば、zone を、IANA Time Zone DatabaseでLink名を解決する規則に従ってidentifier が解決されるZone名とする。zone が"Etc/" で始まるならば、primary をzone に設定する。そうでなければ、identifierCountryCode を、identifier に対応する地理的領域を領土に含むISO 3166-1 Alpha-2 国コードとする。zoneCountryCode を、zone に対応する地理的領域を領土に含むISO 3166-1 Alpha-2国コードとする。identifierCountryCode がzoneCountryCode であるならば、primary をzone に設定する。そうでなければ、countryCodeLineCount を、IANA Time Zone Databaseのファイルzone.tab内で“country-code”列がidentifierCountryCode である行の数とする。countryCodeLineCount が1ならば、countryCodeLine を、IANA Time Zone Databaseのファイルzone.tab内で“country-code”列がidentifierCountryCode である行とする。primary をcountryCodeLine の“TZ”列の内容に設定する。そうでなければ、backzone をundefined とする。backzoneLinkLines を、IANA Time Zone Databaseのファイルbackzone内で"Link " または"#PACKRATLIST zone.tab Link " のいずれかで始まる行のList とする。backzoneLinkLines の各要素line について、次を行う:i をStringIndexOf (line , "Link " , 0)とする。line をline のi + 5からの部分文字列に設定する。backzoneAndLink をStringSplitToList (line , " " )とする。Assert : backzoneAndLink は少なくとも2つの要素を持ち、backzoneAndLink [0]とbackzoneAndLink [1]はいずれも利用可能な名前付きタイムゾーン識別子である。backzoneAndLink [1]がidentifier であるならば、Assert : backzone はundefined である。backzone をbackzoneAndLink [0]に設定する。Assert : backzone はundefined でない。primary をbackzone に設定する。 primary が"Etc/UTC" 、"Etc/GMT" 、または"GMT" のいずれかならば、primary を"UTC" に設定する。primary がreplacement time zone identifier であり、そのrename waiting period が終了していないならば、renamedIdentifier を、primary が置き換えたrenamed time zone identifier とする。primary をrenamedIdentifier に設定する。record をTime Zone Identifier Record { [[Identifier]] : identifier , [[PrimaryIdentifier]] : primary }とする。record をresult に追加する。Assert : result は、utcRecord .[[Identifier]] が"UTC" であり、かつutcRecord .[[PrimaryIdentifier]] が"UTC" であるTime Zone Identifier Record utcRecord を含む。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:
AvailableNamedTimeZoneIdentifiers ()の各要素record について、次を行う:record .[[Identifier]] がtimeZoneIdentifier に対するASCII-case-insensitive match であるならば、record を返す。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:
records をAvailableNamedTimeZoneIdentifiers ()とする。result を新しい空のList とする。records の各要素timeZoneIdentifierRecord について、次を行う:timeZoneIdentifierRecord .[[Identifier]] がtimeZoneIdentifierRecord .[[PrimaryIdentifier]] であるならば、timeZoneIdentifierRecord .[[Identifier]] をresult に追加する。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:
Assert : string は空のStringでない。Assert : separator は空のStringでない。separatorLength をseparator の長さとする。substrings を新しい空のList とする。i を0とする。j をStringIndexOf (string , separator , 0)とする。j がnot-found でない間、繰り返す:substring をstring のi からj までの部分文字列とする。substring をsubstrings に追加する。i をj + separatorLength に設定する。j をStringIndexOf (string , separator , i )に設定する。substring をstring のi からの部分文字列とする。substring をsubstrings に追加する。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:
IsSanctionedSingleUnitIdentifier (unitIdentifier )がtrue ならば、true を返す。numeratorAndDenominator をStringSplitToList (unitIdentifier , "-per-" )とする。numeratorAndDenominator が正確に2つの要素を持たないならば、false を返す。IsSanctionedSingleUnitIdentifier (numeratorAndDenominator [0])がfalse ならば、false を返す。IsSanctionedSingleUnitIdentifier (numeratorAndDenominator [1])がfalse ならば、false を返す。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:
unitIdentifier が下のTable 2 に列挙されているならば、true を返す。そうでなければ、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オブジェクト は、次のとおりである:
%Intl% である。
グローバルオブジェクトの"Intl" プロパティの初期値である。
通常のオブジェクトである。
値が%Object.prototype% である[[Prototype]] 内部スロットを持つ。
関数オブジェクトではない。
[[Construct]] 内部メソッドを持たない。new演算子を伴うコンストラクタとして使用できない。
[[Call]] 内部メソッドを持たない。関数として呼び出すことはできない。
[[FallbackSymbol]] 内部スロットを持つ。これは、[[Description]] が"IntlLegacyConstructedSymbol" である、現在のrealm 内の新しい%Symbol% である。
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 とともに呼び出されるとき、次の手順が実行される:
localeList を? CanonicalizeLocaleList (locales )とする。CreateArrayFromList (localeList )を返す。
8.3.2 Intl.supportedValuesOf ( key )
supportedValuesOfメソッドが引数key とともに呼び出されるとき、次の手順が実行される:
key を ? ToString (key ) に設定する。key が "calendar" なら、list を新しい空の List とする。AvailableCalendars () の各要素 identifier について、次を行う。canonical を CanonicalizeUValue ("ca" , identifier ) とする。identifier が canonical なら、identifier を list に追加する。そうでなく key が "collation" なら、list を AvailableCanonicalCollations ( ) とする。 そうでなく key が "currency" なら、list を AvailableCanonicalCurrencies ( ) とする。 そうでなく key が "numberingSystem" なら、list を AvailableCanonicalNumberingSystems ( ) とする。 そうでなく key が "timeZone" なら、list を AvailablePrimaryTimeZoneIdentifiers ( ) とする。 そうでなく key が "unit" なら、list を AvailableCanonicalUnits ( ) とする。 そうでなければ、RangeError 例外を投げる。 CreateArrayFromList ( list ) を返す。
9 ロケールおよびパラメータのネゴシエーション
サービスコンストラクタ は、locales 引数およびoptions 引数によって表される要求を、実装の実際の能力と照合してネゴシエートするために共通のパターンを使用する。その共通の挙動は、能力を記述する内部スロット、これらの内部スロットを使用する抽象操作、および以下で定義される特殊なデータ型によってここで説明される。
Available Locales List は、任意の順序で並ぶ重複のない言語タグ のList であり、それぞれが整形式 であり、正規化済み であり、Unicodeロケール拡張シーケンス を欠く。これは、実装が特定の文脈内で機能を提供するすべてのロケールを表す。
Language Priority List は、優先度の降順でロケールの選好列を表す、整形式 かつ正規化済み の言語タグ のList である。これは、RFC 4647 section 2.3 においてBCP 47 で定義される同名の用語に対応するが、"*" 要素を禁止し、正規化済みの内容のみを含む。
Resolution Option Descriptor は、フィールド[[Key]] (文字列、通常は[[RelevantExtensionKeys]] List の要素)および[[Property]] (文字列)を持ち、必要に応じて[[Type]] (boolean またはstring )と[[Values]] (empty またはECMAScript言語値のList )のいずれかまたは両方も持つRecord である。これは、オブジェクト構築中にロケール解決に関連するオプションを読み取る方法を記述する。
9.1 サービスコンストラクタの内部スロット
各サービスコンストラクタ は、次の内部スロットを持つ:
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:
locales がundefined ならば、新しい空のList を返す。 seen を新しい空のList とする。locales がStringである、またはlocales がObjectであり、かつlocales が[[InitializedLocale]] 内部スロットを持つならば、localesObj をCreateArrayFromList (« locales »)とする。そうでなければ、localesObj を? ToObject (locales )とする。 length を? LengthOfArrayLike (localesObj )とする。k を0とする。k < length である間、繰り返す:propertyKey を! ToString (𝔽 (k ))とする。exists を? HasProperty (localesObj , propertyKey )とする。exists がtrue ならば、element を? Get (localesObj , propertyKey )とする。element がStringでもObjectでもないならば、TypeError 例外を投げる。element がObjectであり、かつelement が[[InitializedLocale]] 内部スロットを持つならば、tag をelement .[[Locale]] とする。そうでなければ、tag を? ToString (element )とする。 IsWellFormedLanguageTag (tag )がfalse ならば、RangeError 例外を投げる。canonicalizedTag をCanonicalizeUnicodeLocaleId (tag )とする。seen がcanonicalizedTag を含まないならば、canonicalizedTag をseen に追加する。k をk + 1に設定する。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:
lowerValue をuvalue のASCII-lowercase とする。canonicalized を、Unicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalization Section 5 Canonicalizing Syntax, Processing LocaleIds に従って、キーukey の値としてlowerValue を正規化した結果のString値とする。NOTE: 実装は、Common Locale Data Repository(https://cldr.unicode.org/ で入手可能)によって提供されるcommon/bcp47内の'u'拡張データを使用することが推奨される。 canonicalized を返す。
9.2.3 LookupMatchingLocaleByPrefix ( availableLocales , requestedLocales )
The abstract operation LookupMatchingLocaleByPrefix takes arguments availableLocales (Available Locales List ) and requestedLocales (Language Priority List ) and returns フィールド[[locale]] (Unicode正規化済みロケール識別子 )および[[extension]] (Unicodeロケール拡張シーケンス またはempty )を持つRecord またはundefined . Unicodeロケール拡張シーケンス を無視して、RFC 4647 section 3.4 においてBCP 47 で定義されるlookupアルゴリズムを使用し、requestedLocales を満たすためのavailableLocales の最良の要素を決定する。非デフォルトの一致が見つかった場合、availableLocales からの一致する言語タグ を含む[[locale]] フィールドと、requestedLocales の対応する要素のUnicodeロケール拡張シーケンス (要求された言語タグ にそのようなシーケンスがない場合はempty )を含む[[extension]] フィールドを持つRecord を返す。 It performs the following steps when called:
requestedLocales の各要素locale について、次を行う:extension をempty とする。locale がUnicodeロケール拡張シーケンス を含むならば、extension をlocale のUnicodeロケール拡張シーケンス に設定する。locale を、任意のUnicodeロケール拡張シーケンス が削除されたlocale であるString値に設定する。prefix をlocale とする。prefix が空のStringでない間、繰り返す:availableLocales がprefix を含むならば、Record { [[locale]] : prefix , [[extension]] : extension }を返す。prefix が"-" (コード単位0x002D HYPHEN-MINUS)を含むならばpos をprefix 内の"-" の最後の出現のインデックスとし、そうでなければpos を0とする。pos ≥ 2であり、かつprefix のpos - 2からpos - 1までの部分文字列が"-" である間、繰り返す:pos をpos - 2に設定する。prefix をprefix の0からpos までの部分文字列に設定する。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:
Assert : extension の ASCII-lowercase は extension である。Assert : extension の 0 から 3 までの部分文字列は "-u-" である。attributes を新しい空の List とする。keywords を新しい空の List とする。keyword を undefined とする。size を extension の長さとする。k を 3 とする。k < size の間、繰り返す。e を StringIndexOf (extension , "-" , k ) とする。e が not-found なら length を size - k とする。そうでなければ length を e - k とする。subtag を extension の k から k + length までの部分文字列とする。NOTE: keyword は、一連のサブタグ であり、その最初のものは長さ 2 の key で、後続するものがあれば長さが 3 から 8 までの閉区間内にあり、それらは間にある "-" 区切りとともに collectively value を構成する。attribute は、すべての keywords に先行する、長さが 3 から 8 までの閉区間内にある単一のサブタグ である。 Assert : length ≥ 2 である。keyword が undefined で、かつ length ≠ 2 なら、subtag が attributes の要素でないなら、subtag を attributes に追加する。そうでなく length = 2 なら、keyword を Record { [[Key]] : subtag , [[Value]] : 空の String } に設定する。keywords が [[Key]] が keyword .[[Key]] である要素を含まないなら、keyword を keywords に追加する。 そうでなく keyword .[[Value]] が空の String なら、keyword .[[Value]] を subtag に設定する。 そうでなければ、keyword .[[Value]] を keyword .[[Value]] 、"-" 、および subtag の文字列連結に設定する。 k を k + length + 1 に設定する。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:
Assert : locale はUnicodeロケール拡張シーケンス を含まない。extension を"-u" とする。attributes の各要素attr について、次を行う:extension をextension 、"-" 、およびattr の文字列連結に設定する。keywords の各Record { [[Key]] , [[Value]] } keyword について、次を行う:extension をextension 、"-" 、およびkeyword .[[Key]] の文字列連結に設定する。keyword .[[Value]] が空のStringでないならば、extension をextension 、"-" 、およびkeyword .[[Value]] の文字列連結に設定する。extension が"-u" ならば、CanonicalizeUnicodeLocaleId (locale )を返す。privateIndex をStringIndexOf (locale , "-x-" , 0)とする。privateIndex がnot-found ならば、newLocale をlocale とextension の文字列連結とする。そうでなければ、preExtension をlocale の0からprivateIndex までの部分文字列とする。postExtension をlocale のprivateIndex からの部分文字列とする。newLocale をpreExtension 、extension 、およびpostExtension の文字列連結とする。 Assert : IsWellFormedLanguageTag (newLocale )はtrue である。CanonicalizeUnicodeLocaleId (newLocale )を返す。
9.2.7 ResolveLocale ( availableLocales , requestedLocales , options , relevantExtensionKeys , localeData )
The abstract operation ResolveLocale takes arguments availableLocales (Available Locales List ), requestedLocales (Language Priority List ), options (Record ), relevantExtensionKeys (StringのList ), and localeData (Record ) and returns Record . RFC 4647 section 3 においてBCP 47 で定義される"lookup"を実行し、Unicodeロケール拡張シーケンス を無視して、options .[[localeMatcher]] によって指定されるLookupMatchingLocaleByBestFit アルゴリズムまたはLookupMatchingLocaleByPrefix アルゴリズムのいずれかを使用し、requestedLocales を満たすためのavailableLocales の最良の要素を決定し、localeData からの対応するデータおよびrelevantExtensionKeys の各要素に対する解決済み値(一致したロケールのデータをデフォルトとし、存在する場合は要求されたUnicodeロケール拡張シーケンス からのデータにより、さらに存在する場合はoptions からのデータにより置き換えられる)も含む一致の表現を返す。requestedLocales から一致した要素がUnicodeロケール拡張シーケンス を含む場合、それは返されるRecord の[[Locale]] フィールド内の言語タグ へコピーされるが、relevantExtensionKeys 内に含まれないkey値、またはoptions からの異なる値によって置き換えられたtype値を持つkeyword Unicodeロケール非終端記号 は省略される。 It performs the following steps when called:
matcher を options .[[localeMatcher]] とする。matcher が "lookup" なら、match を LookupMatchingLocaleByPrefix (availableLocales , requestedLocales ) とする。そうでなければ、match を LookupMatchingLocaleByBestFit (availableLocales , requestedLocales ) とする。 match が undefined なら、match を Record { [[locale]] : DefaultLocale (), [[extension]] : empty } に設定する。foundLocale を match .[[locale]] とする。foundLocaleData を localeData .[[<foundLocale >]] とする。Assert : foundLocaleData は Record である。result を新しい Record とする。result .[[LocaleData]] を foundLocaleData に設定する。match .[[extension]] が empty でないなら、components を UnicodeExtensionComponents (match .[[extension]] ) とする。keywords を components .[[Keywords]] とする。そうでなければ、keywords を新しい空の List とする。 supportedKeywords を新しい空の List とする。relevantExtensionKeys の各要素 key について、次を行う。keyLocaleData を foundLocaleData .[[<key >]] とする。Assert : keyLocaleData は List である。value を keyLocaleData [0] とする。Assert : value は String または null である。supportedKeyword を empty とする。keywords が [[Key]] が key である要素を含むなら、entry を [[Key]] が key である keywords の要素とする。requestedValue を entry .[[Value]] とする。requestedValue が空の String でないなら、keyLocaleData が requestedValue を含むなら、value を requestedValue に設定する。supportedKeyword を Record { [[Key]] : key , [[Value]] : value } に設定する。そうでなく keyLocaleData が "true" を含むなら、value を "true" に設定する。supportedKeyword を Record { [[Key]] : key , [[Value]] : 空の String } に設定する。 Assert : options はフィールド [[<key >]] を持つ。optionsValue を options .[[<key >]] とする。Assert : optionsValue は String、または undefined もしくは null のいずれかである。optionsValue が String なら、ukey を key の ASCII-lowercase とする。optionsValue を CanonicalizeUValue (ukey , optionsValue ) に設定する。optionsValue が空の String なら、optionsValue を "true" に設定する。SameValue (optionsValue , value ) が false で、かつ keyLocaleData が optionsValue を含むなら、value を optionsValue に設定する。supportedKeyword を empty に設定する。supportedKeyword が empty でないなら、supportedKeyword を supportedKeywords に追加する。result .[[<key >]] を value に設定する。supportedKeywords が空でないなら、supportedAttributes を新しい空の List とする。foundLocale を InsertUnicodeExtensionAndCanonicalize (foundLocale , supportedAttributes , supportedKeywords ) に設定する。result .[[Locale]] を foundLocale に設定する。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:
requestedLocales を? CanonicalizeLocaleList (locales )とする。specialBehaviours が存在し、require-options を含み、かつoptions がundefined ならば、TypeError 例外を投げる。specialBehaviours が存在し、coerce-options を含むならば、options を? CoerceOptionsToObject (options )に設定する。そうでなければ、options を? GetOptionsObject (options )に設定する。matcher を? GetOption (options , "localeMatcher" , string , « "lookup" , "best fit" », "best fit" )とする。opt をRecord { [[localeMatcher]] : matcher }とする。ctor .[[ResolutionOptionDescriptors]] の各Resolution Option Descriptor desc について、次を行う:desc が[[Type]] フィールドを持つならばtype をdesc .[[Type]] とする。そうでなければtype をstring とする。desc が[[Values]] フィールドを持つならばvalues をdesc .[[Values]] とする。そうでなければvalues をempty とする。value を? GetOption (options , desc .[[Property]] , type , values , undefined )とする。value がundefined でないならば、value を! ToString (value )に設定する。value がtype Unicodeロケール非終端記号 により一致させることができないならば、RangeError 例外を投げる。key をdesc .[[Key]] とする。opt .[[<key >]]をvalue に設定する。modifyResolutionOptions が存在するならば、! modifyResolutionOptions (opt )を実行する。resolution をResolveLocale (ctor .[[AvailableLocales]] , requestedLocales , opt , ctor .[[RelevantExtensionKeys]] , localeData )とする。Record { [[Options]] : options , [[ResolvedLocale]] : resolution , [[ResolutionOptions]] : opt }を返す。
9.2.9 FilterLocales ( availableLocales , requestedLocales , options )
The abstract operation FilterLocales takes arguments availableLocales (Available Locales List ), requestedLocales (Language Priority List ), and options (ECMAScript言語値) and returns Unicode正規化済みロケール識別子 のList を含む通常完了またはthrow完了. RFC 4647 section 3 においてBCP 47 で定義される"filtering"を実行し、options で指定されるLookupMatchingLocaleByBestFit アルゴリズムまたはLookupMatchingLocaleByPrefix アルゴリズムのいずれかを使用するときにavailableLocales が一致するロケールを含むrequestedLocales の要素を返し、それらの相対順序を保持する。 It performs the following steps when called:
options を? CoerceOptionsToObject (options )に設定する。matcher を? GetOption (options , "localeMatcher" , string , « "lookup" , "best fit" », "best fit" )とする。subset を新しい空のList とする。requestedLocales の各要素locale について、次を行う:matcher が"lookup" ならば、match をLookupMatchingLocaleByPrefix (availableLocales , « locale »)とする。そうでなければ、match をLookupMatchingLocaleByBestFit (availableLocales , « locale »)とする。 match がundefined でないならば、locale をsubset に追加する。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:
options がundefined ならば、OrdinaryObjectCreate (null )を返す。? 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:
value を? Get (options , propertyKey )とする。value がundefined ならば、default がrequired ならば、TypeError 例外を投げる。default を返す。type がboolean ならば、value をToBoolean (value )に設定する。そうでなければ、Assert : type はstring である。value を? ToString (value )に設定する。 values がempty でなく、かつvalues がvalue を含まないならば、RangeError 例外を投げる。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:
value を? Get (options , propertyKey )とする。value がundefined ならば、fallback を返す。value がtrue ならば、true を返す。ToBoolean (value )がfalse ならば、false を返す。value を? ToString (value )に設定する。stringValues がvalue を含まないならば、RangeError 例外を投げる。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:
value がundefined ならば、fallback を返す。value を? ToNumber (value )に設定する。value が有限でない、またはℝ (value ) < minimum 、またはℝ (value ) > maximum ならば、RangeError 例外を投げる。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:
value を? Get (options , propertyKey )とする。? 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:
result を新しい空のList とする。placeholderEnd を-1とする。placeholderStart をStringIndexOf (pattern , "{" , 0)とする。placeholderStart がnot-found でない間、繰り返す:literal をpattern のplaceholderEnd + 1からplaceholderStart までの部分文字列とする。literal が空のStringでないならば、Record { [[Type]] : "literal" , [[Value]] : literal }をresult に追加する。placeholderEnd をStringIndexOf (pattern , "}" , placeholderStart )に設定する。Assert : placeholderEnd はnot-found でなく、かつplaceholderStart < placeholderEnd である。placeholderName をpattern のplaceholderStart + 1からplaceholderEnd までの部分文字列とする。Record { [[Type]] : placeholderName , [[Value]] : undefined }をresult に追加する。placeholderStart をStringIndexOf (pattern , "{" , placeholderEnd )に設定する。tail をpattern のplaceholderEnd + 1からの部分文字列とする。tail が空のStringでないならば、Record { [[Type]] : "literal" , [[Value]] : tail }をresult に追加する。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 で呼び出された場合、次の手順を実行する:
NewTarget が undefined なら、newTarget をアクティブな関数オブジェクトとし、そうでなければ newTarget を NewTarget とする。 internalSlotsList を « [[InitializedCollator]] , [[Locale]] , [[Usage]] , [[Collation]] , [[Numeric]] ,
[[CaseFirst]] , [[Sensitivity]] , [[IgnorePunctuation]] , [[BoundCompare]] » とする。collator を ? OrdinaryCreateFromConstructor (newTarget , "%Intl.Collator.prototype%" , internalSlotsList )
とする。注: locale データのソースは ResolveOptions の "usage" プロパティに依存するが、次の2つのステップはその参照よりも観測可能に先行しなければならず、ResolveOptions
内で観測可能に繰り返してはならない。 requestedLocales を ? CanonicalizeLocaleList (locales ) とする。options を ? CoerceOptionsToObject (options ) とする。usage を ? GetOption (options , "usage" , string , « "sort" , "search" », "sort" ) とする。collator .[[Usage]] に usage を設定する。usage が "sort" ならlocaleData を %Intl.Collator% .[[SortLocaleData]] とする。それ以外の場合、 localeData を %Intl.Collator% .[[SearchLocaleData]] とする。optionsResolution を ? ResolveOptions (%Intl.Collator% , localeData ,
CreateArrayFromList (requestedLocales ), options ) とする。resolvedLocale を optionsResolution .[[ResolvedLocale]] とする。collator .[[Locale]] に resolvedLocale .[[Locale]] を設定する。resolvedLocale .[[co]] が null なら collation を "default" とし、そうでなければ collation を resolvedLocale .[[co]] とする。collator .[[Collation]] に collation を設定する。collator .[[Numeric]] に SameValue (resolvedLocale .[[kn]] , "true" ) を設定する。collator .[[CaseFirst]] に resolvedLocale .[[kf]] を設定する。resolvedLocaleData を resolvedLocale .[[LocaleData]] とする。usage が "sort" なら defaultSensitivity を "variant" とし、そうでなければ defaultSensitivity を
resolvedLocaleData .[[sensitivity]] とする。collator .[[Sensitivity]] に ? GetOption (options , "sensitivity" , string , « "base" , "accent" ,
"case" , "variant" », defaultSensitivity ) を設定する。defaultIgnorePunctuation を resolvedLocaleData .[[ignorePunctuation]] とする。collator .[[IgnorePunctuation]] に ? GetOption (options , "ignorePunctuation" , boolean , empty ,
defaultIgnorePunctuation ) を設定する。collator を返す。
Note
10.2 Intl.Collator コンストラクターのプロパティ
Intl.Collator コンストラクター:
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 を引数に呼び出された場合、次の手順を実行する:
availableLocales を %Intl.Collator% .[[AvailableLocales]] とする。requestedLocales を ? CanonicalizeLocaleList (locales ) とする。? 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 ( )
この関数はオブジェクトの初期化時に計算されたロケールとオプションにアクセスするためのものである。
collator を this 値とする。? RequireInternalSlot (collator , [[InitializedCollator]] ) を実行する。 options を OrdinaryObjectCreate (%Object.prototype% ) とする。Table 3 の各行(ヘッダー行を除く)について、テーブル順に次を行うpropertyKey を現在の行の Property 値とする。value を collator の内部スロットのうち、現在の行の Internal Slot 値の名前を持つものの値とする。現在の行に Extension Key 値がある場合、 extensionKey を現在の行の Extension Key 値とする。%Intl.Collator% .[[RelevantExtensionKeys]] が extensionKey を含まない場合、value を undefined に設定する。value が undefined でない場合、! CreateDataPropertyOrThrow (options , propertyKey , value ) を実行する。 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 アクセサ関数は次の手順を実行する:
collator を this 値とする。? RequireInternalSlot (collator , [[InitializedCollator]] ) を実行する。 collator .[[BoundCompare]] が undefined なら、func を 10.3.3.1 で定義された新しい組み込み関数オブジェクトとする。func .[[Collator]] に collator を設定する。collator .[[BoundCompare]] に func を設定する。collator .[[BoundCompare]] を返す。
Note
返される関数は collator にバインドされているため、Array.prototype.sort や他の関数に直接渡すことができる。
10.3.3.1 Collator 比較関数
Collator 比較関数は [[Collator]] 内部スロットを持つ匿名組み込み関数である。
Collator 比較関数 func が引数 x と y で呼び出された場合、次の手順を実行する:
collator を func .[[Collator]] とする。collator はオブジェクトであり、[[InitializedCollator]] 内部スロットを持つことをアサートする。x が指定されていない場合、x を undefined とする。y が指定されていない場合、y を undefined とする。xString を ? ToString (x ) とする。yString を ? ToString (y ) とする。CompareStrings (collator , xString , yString ) を返す。
Collator 比較関数の "length" プロパティは 2 𝔽 である。
10.3.3.2 CompareStrings ( collator , x , y )
The implementation-defined abstract operation CompareStrings takes arguments collator (an Intl.Collator), x (a String), and y (a String) and returns a Number, but not NaN .
返される数値は 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 とともに呼び出されたとき、次の手順が実行される:
NewTarget が undefined なら、newTarget をアクティブな関数オブジェクトとする。そうでなければ、newTarget を NewTarget とする。 dateTimeFormat を ? CreateDateTimeFormat (newTarget , locales , options , any , date ) とする。実装が 4.3 Note 1 の規範的任意コンストラクターモードをサポートするなら、this を this 値とする。? ChainDateTimeFormat (dateTimeFormat , NewTarget, this ) を返す。 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:
newTarget が undefined で、かつ ? OrdinaryHasInstance (%Intl.DateTimeFormat% , this ) が true なら、? DefinePropertyOrThrow (this , %Intl% .[[FallbackSymbol]] , PropertyDescriptor { [[Value]] : dateTimeFormat , [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false }) を実行する。 this を返す。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:
dateTimeFormat を ? OrdinaryCreateFromConstructor (newTarget , "%Intl.DateTimeFormat.prototype%" , « [[InitializedDateTimeFormat]] , [[Locale]] , [[Calendar]] , [[NumberingSystem]] , [[TimeZone]] , [[HourCycle]] , [[DateStyle]] , [[TimeStyle]] , [[DateTimeFormat]] , [[BoundFormat]] ») とする。specialOptions を Record { [[Hour12]] : undefined } とする。modifyResolutionOptions を、specialOptions を捕捉し、呼び出されたときに次の手順を実行する、パラメーター (options ) を持つ新しい Abstract Closure とする:specialOptions .[[Hour12]] を options .[[hour12]] に設定する。options からフィールド [[hour12]] を取り除く。specialOptions .[[Hour12]] が undefined でないなら、options .[[hc]] を null に設定する。optionsResolution を ? ResolveOptions (%Intl.DateTimeFormat% , %Intl.DateTimeFormat% .[[LocaleData]] , locales , options , « coerce-options », modifyResolutionOptions ) とする。hour12 を specialOptions .[[Hour12]] とする。options を optionsResolution .[[Options]] に設定する。resolvedLocale を optionsResolution .[[ResolvedLocale]] とする。dateTimeFormat .[[Locale]] を resolvedLocale .[[Locale]] に設定する。resolvedCalendar を resolvedLocale .[[ca]] とする。dateTimeFormat .[[Calendar]] を resolvedCalendar に設定する。dateTimeFormat .[[NumberingSystem]] を resolvedLocale .[[nu]] に設定する。resolvedLocaleData を resolvedLocale .[[LocaleData]] とする。hour12 が true なら、hc を resolvedLocaleData .[[hourCycle12]] とする。そうでなく hour12 が false なら、hc を resolvedLocaleData .[[hourCycle24]] とする。 そうでなければ、Assert : hour12 は undefined である。hc を resolvedLocale .[[hc]] とする。hc が null なら、hc を resolvedLocaleData .[[hourCycle]] に設定する。 timeZone を ? Get (options , "timeZone" ) とする。timeZone が undefined なら、timeZone を SystemTimeZoneIdentifier () に設定する。そうでなければ、timeZone を ? ToString (timeZone ) に設定する。 IsTimeZoneOffsetString (timeZone ) が true なら、parseResult を ParseText (StringToCodePoints (timeZone ), UTCOffset ) とする。Assert : parseResult は Parse Node である。parseResult が複数の MinuteSecond Parse Node を含むなら、RangeError 例外を投げる。offsetNanoseconds を ParseTimeZoneOffsetString (timeZone ) とする。offsetMinutes を offsetNanoseconds / (6 × 1010 ) とする。Assert : offsetMinutes は整数である。timeZone を FormatOffsetTimeZoneIdentifier (offsetMinutes ) に設定する。そうでなければ、timeZoneIdentifierRecord を GetAvailableNamedTimeZoneIdentifier (timeZone ) とする。timeZoneIdentifierRecord が empty なら、RangeError 例外を投げる。timeZone を timeZoneIdentifierRecord .[[PrimaryIdentifier]] に設定する。 dateTimeFormat .[[TimeZone]] を timeZone に設定する。formatOptions を新しい Record とする。formatOptions .[[hourCycle]] を hc に設定する。hasExplicitFormatComponents を false とする。Table 16 の各行について、ヘッダー行を除き、表の順序で、次を行う。propertyKey を現在の行の Property 列で与えられた名前とする。propertyKey が "fractionalSecondDigits" なら、value を ? GetNumberOption (options , "fractionalSecondDigits" , 1, 3, undefined ) とする。そうでなければ、values を現在の行の Values 列で与えられた文字列を要素とする List とする。value を ? GetOption (options , propertyKey , string , values , undefined ) とする。 formatOptions .[[<propertyKey >]] を value に設定する。value が undefined でないなら、hasExplicitFormatComponents を true に設定する。formatMatcher を ? GetOption (options , "formatMatcher" , string , « "basic" , "best fit" », "best fit" ) とする。dateStyle を ? GetOption (options , "dateStyle" , string , « "full" , "long" , "medium" , "short" », undefined ) とする。dateTimeFormat .[[DateStyle]] を dateStyle に設定する。timeStyle を ? GetOption (options , "timeStyle" , string , « "full" , "long" , "medium" , "short" », undefined ) とする。dateTimeFormat .[[TimeStyle]] を timeStyle に設定する。dateStyle が undefined でない、または timeStyle が undefined でないなら、hasExplicitFormatComponents が true なら、TypeError 例外を投げる。required が date で、かつ timeStyle が undefined でないなら、TypeError 例外を投げる。required が time で、かつ dateStyle が undefined でないなら、TypeError 例外を投げる。styles を resolvedLocaleData .[[styles]] .[[<resolvedCalendar >]] とする。bestFormat を DateTimeStyleFormat (dateStyle , timeStyle , styles ) とする。そうでなければ、needDefaults を true とする。required が date または any なら、« "weekday" , "year" , "month" , "day" » の各プロパティ名 propertyKey について、次を行う。value を formatOptions .[[<propertyKey >]] とする。value が undefined でないなら、needDefaults を false に設定する。 required が time または any なら、« "dayPeriod" , "hour" , "minute" , "second" , "fractionalSecondDigits" » の各プロパティ名 propertyKey について、次を行う。value を formatOptions .[[<propertyKey >]] とする。value が undefined でないなら、needDefaults を false に設定する。 needDefaults が true で、かつ defaults が date または all のいずれかなら、« "year" , "month" , "day" » の各プロパティ名 propertyKey について、次を行う。formatOptions .[[<propertyKey >]] を "numeric" に設定する。 needDefaults が true で、かつ defaults が time または all のいずれかなら、« "hour" , "minute" , "second" » の各プロパティ名 propertyKey について、次を行う。formatOptions .[[<propertyKey >]] を "numeric" に設定する。 formats を resolvedLocaleData .[[formats]] .[[<resolvedCalendar >]] とする。formatMatcher が "basic" なら、bestFormat を BasicFormatMatcher (formatOptions , formats ) とする。そうでなければ、bestFormat を BestFitFormatMatcher (formatOptions , formats ) とする。 dateTimeFormat .[[DateTimeFormat]] を bestFormat に設定する。bestFormat がフィールド [[hour]] を持つなら、dateTimeFormat .[[HourCycle]] を hc に設定する。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:
offsetMinutes ≥ 0 なら、sign をコード単位 0x002B (PLUS SIGN) とする。そうでなければ、sign をコード単位 0x002D (HYPHEN-MINUS) とする。absoluteMinutes を abs (offsetMinutes ) とする。hours を floor (absoluteMinutes / 60) とする。minutes を absoluteMinutes modulo 60 とする。sign 、ToZeroPaddedDecimalString (hours , 2)、コード単位 0x003A (COLON)、および ToZeroPaddedDecimalString (minutes , 2) の文字列連結を返す。
11.2 Intl.DateTimeFormat コンストラクターのプロパティ
Intl.DateTimeFormat コンストラクターは次の通りである:
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 とともに呼び出されたとき、次の手順が実行される:
availableLocales を %Intl.DateTimeFormat% .[[AvailableLocales]] とする。requestedLocales を ? CanonicalizeLocaleList (locales ) とする。? 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
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
11.2.3.6 DateTime Style Records
各 DateTime Style Record は、Table 10 で定義されるフィールドを持つ。
Table 10: DateTime Style Record
11.2.3.7 DateTime Connector Records
各 DateTime Connector Record は、Table 11 で定義されるフィールドを持つ。すべてのコネクターパターン文字列は、文字列 "{0}" および "{1}" を含まなければならない。
Table 11: DateTime Connector Record
11.2.3.8 DateTime Date Range Records
各 DateTime Date Range Record は、Table 12 で定義されるフィールドを持つ。
Table 12: DateTime Date Range Record
11.2.3.9 DateTime Time Range Records
各 DateTime Time Range Record は、Table 13 で定義されるフィールドを持つ。
Table 13: DateTime Time Range Record
11.2.3.10 DateTime Style Range Records
各 DateTime Style Range Record は、Table 14 で定義されるフィールドを持つ。
Table 14: DateTime Style Range Record
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 ( )
この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。
dtf を this 値とする。実装が 4.3 Note 1 の規範的任意コンストラクターモードをサポートするなら、dtf を ? UnwrapDateTimeFormat (dtf ) に設定する。 ? RequireInternalSlot (dtf , [[InitializedDateTimeFormat]] ) を実行する。 options を OrdinaryObjectCreate (%Object.prototype% ) とする。Table 15 の各行について、ヘッダー行を除き、表の順序で、次を行う。propertyKey を現在の行の Property 値とする。現在の行に Internal Slot 値があるなら、value を、現在の行の Internal Slot 値を名前とする dtf の内部スロットの値とする。 そうでなければ、format を dtf .[[DateTimeFormat]] とする。format がフィールド [[<propertyKey >]] を持ち、かつ dtf .[[DateStyle]] が undefined で、かつ dtf .[[TimeStyle]] が undefined なら、value を format .[[<propertyKey >]] とする。そうでなければ、value を undefined とする。 value が undefined でないなら、現在の行に Conversion 値があるなら、conversion を現在の行の Conversion 値とする。conversion が hour12 なら、value が "h11" または "h12" なら、value を true に設定する。そうでなければ、value を false に設定する。そうでなければ、Assert : conversion は number である。value を 𝔽 (value ) に設定する。 ! CreateDataPropertyOrThrow (options , propertyKey , value ) を実行する。 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 アクセサー関数は次の手順を実行する:
dtf を this 値とする。実装が 4.3 Note 1 の規範的任意コンストラクターモードをサポートするなら、dtf を ? UnwrapDateTimeFormat (dtf ) に設定する。 ? RequireInternalSlot (dtf , [[InitializedDateTimeFormat]] ) を実行する。 dtf .[[BoundFormat]] が undefined なら、func を、DateTime Format Functions (11.5.4 ) で定義される新しい組み込み関数オブジェクトとする。func .[[DateTimeFormat]] を dtf に設定する。dtf .[[BoundFormat]] を func に設定する。dtf .[[BoundFormat]] を返す。
Note
返される関数は dtf に束縛されているため、Array.prototype.map または他の関数に直接渡すことができる。
これは、もはや新機能では従われない慣例の一部として歴史的な遺物と見なされるが、既存のプログラムとの互換性を維持するために保存されている。
11.3.4 Intl.DateTimeFormat.prototype.formatRange ( startDate , endDate )
formatRange メソッドが引数 startDate および endDate とともに呼び出されたとき、次の手順が実行される:
dtf を this 値とする。? RequireInternalSlot (dtf , [[InitializedDateTimeFormat]] ) を実行する。 startDate が undefined または endDate が undefined なら、TypeError 例外を投げる。x を ? ToNumber (startDate ) とする。y を ? ToNumber (endDate ) とする。? FormatDateTimeRange (dtf , x , y ) を返す。
11.3.5 Intl.DateTimeFormat.prototype.formatRangeToParts ( startDate , endDate )
formatRangeToParts メソッドが引数 startDate および endDate とともに呼び出されたとき、次の手順が実行される:
dtf を this 値とする。? RequireInternalSlot (dtf , [[InitializedDateTimeFormat]] ) を実行する。 startDate が undefined または endDate が undefined なら、TypeError 例外を投げる。x を ? ToNumber (startDate ) とする。y を ? ToNumber (endDate ) とする。? FormatDateTimeRangeToParts (dtf , x , y ) を返す。
11.3.6 Intl.DateTimeFormat.prototype.formatToParts ( date )
formatToParts メソッドが引数 date とともに呼び出されたとき、次の手順が実行される:
dtf を this 値とする。? RequireInternalSlot (dtf , [[InitializedDateTimeFormat]] ) を実行する。 date が undefined なら、x を ! Call (%Date.now%, undefined ) とする。そうでなければ、x を ? ToNumber (date ) とする。 ? 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:
removalPenalty を 120 とする。additionPenalty を 20 とする。longLessPenalty を 8 とする。longMorePenalty を 6 とする。shortLessPenalty を 6 とする。shortMorePenalty を 3 とする。offsetPenalty を 1 とする。bestScore を -∞ とする。bestFormat を undefined とする。formats の各要素 format について、次を行う。score を 0 とする。Table 16 の各行について、ヘッダー行を除き、表の順序で、次を行う。property を現在の行の Property 列で与えられた名前とする。options がフィールド [[<property >]] を持つなら、optionsProp を options .[[<property >]] とする。そうでなければ optionsProp を undefined とする。format がフィールド [[<property >]] を持つなら、formatProp を format .[[<property >]] とする。そうでなければ formatProp を undefined とする。optionsProp が undefined で、かつ formatProp が undefined でないなら、score を score - additionPenalty に設定する。そうでなく optionsProp が undefined でなく、かつ formatProp が undefined なら、score を score - removalPenalty に設定する。 そうでなく property が "timeZoneName" なら、optionsProp が "short" または "shortGeneric" なら、formatProp が "shortOffset" なら、score を score - offsetPenalty に設定する。そうでなく formatProp が "longOffset" なら、score を score - (offsetPenalty + shortMorePenalty ) に設定する。 そうでなく optionsProp が "short" で、かつ formatProp が "long" なら、score を score - shortMorePenalty に設定する。 そうでなく optionsProp が "shortGeneric" で、かつ formatProp が "longGeneric" なら、score を score - shortMorePenalty に設定する。 そうでなく optionsProp ≠ formatProp なら、score を score - removalPenalty に設定する。 そうでなく optionsProp が "shortOffset" で、かつ formatProp が "longOffset" なら、score を score - shortMorePenalty に設定する。 そうでなく optionsProp が "long" または "longGeneric" なら、formatProp が "longOffset" なら、score を score - offsetPenalty に設定する。そうでなく formatProp が "shortOffset" なら、score を score - (offsetPenalty + longLessPenalty ) に設定する。 そうでなく optionsProp が "long" で、かつ formatProp が "short" なら、score を score - longLessPenalty に設定する。 そうでなく optionsProp が "longGeneric" で、かつ formatProp が "shortGeneric" なら、score を score - longLessPenalty に設定する。 そうでなく optionsProp ≠ formatProp なら、score を score - removalPenalty に設定する。 そうでなく optionsProp が "longOffset" で、かつ formatProp が "shortOffset" なら、score を score - longLessPenalty に設定する。 そうでなく optionsProp ≠ formatProp なら、score を score - removalPenalty に設定する。 そうでなく optionsProp ≠ formatProp なら、property が "fractionalSecondDigits" なら、values を « 1, 2, 3 » とする。そうでなければ、values を « "2-digit" , "numeric" , "narrow" , "short" , "long" » とする。 optionsPropIndex を values 内の optionsProp のインデックスとする。formatPropIndex を values 内の formatProp のインデックスとする。delta を max (min (formatPropIndex - optionsPropIndex , 2), -2) とする。delta = 2 なら、score を score - longMorePenalty に設定する。そうでなく delta = 1 なら、score を score - shortMorePenalty に設定する。 そうでなく delta = -1 なら、score を score - shortLessPenalty に設定する。 そうでなく delta = -2 なら、score を score - longLessPenalty に設定する。 score > bestScore なら、bestScore を score に設定する。bestFormat を format に設定する。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 DateTime Format Functions
DateTime format function は、[[DateTimeFormat]] 内部スロットを持つ匿名の組み込み関数である。
DateTime format function func が任意の引数 date とともに呼び出されたとき、次の手順が実行される:
dtf を func .[[DateTimeFormat]] とする。Assert : dtf は Object であり、dtf は [[InitializedDateTimeFormat]] 内部スロットを持つ。date が提供されていない、または undefined なら、x を ! Call (%Date.now%, undefined ) とする。そうでなければ、x を ? ToNumber (date ) とする。 ? FormatDateTime (dtf , x ) を返す。
DateTime format function の "length" プロパティは 1 𝔽 である。
11.5.5 FormatDateTimePattern ( dateTimeFormat , format , pattern , epochNanoseconds )
The abstract operation FormatDateTimePattern takes arguments dateTimeFormat (Intl.DateTimeFormat), format (DateTime Format Record または DateTime Range Pattern Format Record ), pattern (Pattern String ), and epochNanoseconds (BigInt) and returns フィールド [[Type]] (String) および [[Value]] (String) を持つ Records の List . pattern に従い、また dateTimeFormat および format の実効ロケールと整形オプションに従って、エポック時刻 epochNanoseconds に対応する parts を作成する。 It performs the following steps when called:
locale を dateTimeFormat .[[Locale]] とする。nfOptions を OrdinaryObjectCreate (null ) とする。! CreateDataPropertyOrThrow (nfOptions , "numberingSystem" , dateTimeFormat .[[NumberingSystem]] ) を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "useGrouping" , false ) を実行する。 nf を ! Construct (%Intl.NumberFormat% , « locale , nfOptions ») とする。nf2Options を OrdinaryObjectCreate (null ) とする。! CreateDataPropertyOrThrow (nf2Options , "minimumIntegerDigits" , 2 𝔽 ) を実行する。 ! CreateDataPropertyOrThrow (nf2Options , "numberingSystem" , dateTimeFormat .[[NumberingSystem]] ) を実行する。 ! CreateDataPropertyOrThrow (nf2Options , "useGrouping" , false ) を実行する。 nf2 を ! Construct (%Intl.NumberFormat% , « locale , nf2Options ») とする。format がフィールド [[fractionalSecondDigits]] を持つなら、fractionalSecondDigits を format .[[fractionalSecondDigits]] とする。nf3Options を OrdinaryObjectCreate (null ) とする。! CreateDataPropertyOrThrow (nf3Options , "minimumIntegerDigits" , 𝔽 (fractionalSecondDigits )) を実行する。 ! CreateDataPropertyOrThrow (nf3Options , "numberingSystem" , dateTimeFormat .[[NumberingSystem]] ) を実行する。 ! CreateDataPropertyOrThrow (nf3Options , "useGrouping" , false ) を実行する。 nf3 を ! Construct (%Intl.NumberFormat% , « locale , nf3Options ») とする。localTime を ToLocalTime (epochNanoseconds , dateTimeFormat .[[Calendar]] , dateTimeFormat .[[TimeZone]] ) とする。patternParts を PartitionPattern (pattern ) とする。result を新しい空の List とする。patternParts の各 Record { [[Type]] , [[Value]] } patternPart について、次を行う。partType を patternPart .[[Type]] とする。partType が "literal" なら、Record { [[Type]] : "literal" , [[Value]] : patternPart .[[Value]] } を result に追加する。そうでなく partType が "fractionalSecondDigits" なら、Assert : format はフィールド [[fractionalSecondDigits]] を持つ。value を localTime .[[Millisecond]] とする。value を floor (value × 10( fractionalSecondDigits - 3 ) ) に設定する。formattedValue を FormatNumeric (nf3 , value ) とする。Record { [[Type]] : "fractionalSecond" , [[Value]] : formattedValue } を result に追加する。 そうでなく partType が "dayPeriod" なら、Assert : format はフィールド [[dayPeriod]] を持つ。fieldFormat を format .[[dayPeriod]] とする。formattedValue を、fieldFormat によって与えられる形式の localTime の day period を表す ILD String とする。Record { [[Type]] : partType , [[Value]] : formattedValue } を result に追加する。 そうでなく partType が "timeZoneName" なら、Assert : format はフィールド [[timeZoneName]] を持つ。fieldFormat を format .[[timeZoneName]] とする。value を dateTimeFormat .[[TimeZone]] とする。formattedValue を、fieldFormat によって与えられる形式の value を表す ILD String とする。その値は、fieldFormat が "short" 、"long" 、"shortOffset" 、または "longOffset" である場合、localTime の [[InDST]] フィールドの値に依存してよい。実装がそのような fieldFormat のローカライズ表現を持たない場合は、value 自体を使用する。Record { [[Type]] : partType , [[Value]] : formattedValue } を result に追加する。 そうでなく partType が Table 16 の行の Property 列に一致するなら、Assert : format はフィールド [[<partType >]] を持つ。fieldFormat を format .[[<partType >]] とする。value を、一致する行の Internal Slot 列を名前とする localTime のフィールドの値とする。partType が "year" で、かつ value ≤ 0 なら、value を 1 - value に設定する。partType が "month" なら、value を value + 1 に設定する。partType が "hour" で、かつ dateTimeFormat .[[HourCycle]] が "h11" または "h12" なら、value を value modulo 12 に設定する。value = 0 で、かつ dateTimeFormat .[[HourCycle]] が "h12" なら、value を 12 に設定する。partType が "hour" で、かつ dateTimeFormat .[[HourCycle]] が "h24" なら、value = 0 なら、value を 24 に設定する。fieldFormat が "numeric" なら、formattedValue を FormatNumeric (nf , value ) とする。そうでなく fieldFormat が "2-digit" なら、formattedValue を FormatNumeric (nf2 , value ) とする。codePoints を StringToCodePoints (formattedValue ) とする。count を codePoints 内の要素数とする。count > 2 なら、tens を codePoints [count - 2] とする。ones を codePoints [count - 1] とする。formattedValue を CodePointsToString (« tens , ones ») に設定する。 そうでなく fieldFormat が "narrow" 、"short" 、または "long" なら、formattedValue を、fieldFormat によって与えられる形式の value を表す ILD String とする。partType が "month" なら、その値は format が [[day]] フィールドを持つかどうかに依存してよい。実装がそのような fieldFormat のローカライズ表現を持たない場合は、value 自体を使用する。 Record { [[Type]] : partType , [[Value]] : formattedValue } を result に追加する。 そうでなく partType が "ampm" なら、value を localTime .[[Hour]] とする。value > 11 なら、formattedValue を "post meridiem" を表す ILD String とする。そうでなければ、formattedValue を "ante meridiem" を表す ILD String とする。Record { [[Type]] : "dayPeriod" , [[Value]] : formattedValue } を result に追加する。 そうでなく partType が "relatedYear" なら、value を localTime .[[RelatedYear]] とする。formattedValue を FormatNumeric (nf , value ) とする。Record { [[Type]] : "relatedYear" , [[Value]] : formattedValue } を result に追加する。 そうでなく partType が "yearName" なら、value を localTime .[[YearName]] とする。formattedValue を value を表す ILD String とする。Record { [[Type]] : "yearName" , [[Value]] : formattedValue } を result に追加する。 そうでなければ、unknown を epochNanoseconds および partType に基づく ILND String とする。Record { [[Type]] : "unknown" , [[Value]] : unknown } を result に追加する。 result を返す。
Note
実装は、Common Locale Data Repository が提供するロケールおよびカレンダー依存文字列 (
https://cldr.unicode.org/ で利用可能) を使用し、DateTimeFormat
"short" 文字列には CLDR
"abbreviated" 文字列を、DateTimeFormat
"long" 文字列には CLDR
"wide" 文字列を使用することが推奨される。
11.5.6 PartitionDateTimePattern ( dateTimeFormat , x )
The abstract operation PartitionDateTimePattern takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (Number) and returns フィールド [[Type]] (String) および [[Value]] (String) を持つ Records の List を含む正常完了、または throw 完了. x を ECMA-262 、21.4.1.1 で規定される時刻値として解釈し、dateTimeFormat の実効ロケールおよび整形オプションに従って、対応する parts を作成する。 It performs the following steps when called:
x を TimeClip (x ) に設定する。x が NaN なら、RangeError 例外を投げる。epochNanoseconds を ℤ (ℝ (x ) × 106 ) とする。format を dateTimeFormat .[[DateTimeFormat]] とする。dateTimeFormat .[[HourCycle]] が "h11" または "h12" なら、pattern を format .[[pattern12]] とする。そうでなければ、pattern を format .[[pattern]] とする。 result を FormatDateTimePattern (dateTimeFormat , format , pattern , epochNanoseconds ) とする。result を返す。
11.5.7 FormatDateTime ( dateTimeFormat , x )
The abstract operation FormatDateTime takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (Number) and returns String を含む正常完了、または throw 完了. It performs the following steps when called:
parts を ? PartitionDateTimePattern (dateTimeFormat , x ) とする。result を空の String とする。parts の各 Record { [[Type]] , [[Value]] } part について、次を行う。result を result と part .[[Value]] の文字列連結に設定する。result を返す。
11.5.8 FormatDateTimeToParts ( dateTimeFormat , x )
The abstract operation FormatDateTimeToParts takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (Number) and returns Array を含む正常完了、または throw 完了. It performs the following steps when called:
parts を ? PartitionDateTimePattern (dateTimeFormat , x ) とする。result を ! ArrayCreate (0) とする。n を 0 とする。parts の各 Record { [[Type]] , [[Value]] } part について、次を行う。partObj を OrdinaryObjectCreate (%Object.prototype% ) とする。! CreateDataPropertyOrThrow (partObj , "type" , part .[[Type]] ) を実行する。 ! CreateDataPropertyOrThrow (partObj , "value" , part .[[Value]] ) を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), partObj ) を実行する。 n を n + 1 に設定する。result を返す。
11.5.9 PartitionDateTimeRangePattern ( dateTimeFormat , x , y )
The abstract operation PartitionDateTimeRangePattern takes arguments dateTimeFormat (Intl.DateTimeFormat), x (Number), and y (Number) and returns フィールド [[Type]] (String)、[[Value]] (String)、および [[Source]] (String) を持つ Records の List を含む正常完了、または throw 完了. x および y を ECMA-262 、21.4.1.1 で規定される時刻値として解釈し、dateTimeFormat の実効ロケールおよび整形オプションに従って、対応する parts を作成する。 It performs the following steps when called:
x を TimeClip (x ) に設定する。x が NaN なら、RangeError 例外を投げる。y を TimeClip (y ) に設定する。y が NaN なら、RangeError 例外を投げる。xEpochNanoseconds を ℤ (ℝ (x ) × 106 ) とする。yEpochNanoseconds を ℤ (ℝ (y ) × 106 ) とする。localTime1 を ToLocalTime (xEpochNanoseconds , dateTimeFormat .[[Calendar]] , dateTimeFormat .[[TimeZone]] ) とする。localTime2 を ToLocalTime (yEpochNanoseconds , dateTimeFormat .[[Calendar]] , dateTimeFormat .[[TimeZone]] ) とする。format を dateTimeFormat .[[DateTimeFormat]] とする。dateTimeFormat .[[HourCycle]] が "h11" または "h12" なら、pattern を format .[[pattern12]] とする。rangePatterns を format .[[rangePatterns12]] とする。そうでなければ、pattern を format .[[pattern]] とする。rangePatterns を format .[[rangePatterns]] とする。 selectedRangePattern を undefined とする。relevantFieldsEqual を true とする。checkMoreFields を true とする。Table 6 の各行について、ヘッダー行を除き、表の順序で、次を行う。fieldName をその行の Field Name 列で与えられた名前とする。rangePatterns が名前 fieldName のフィールドを持つなら、rangePattern を rangePatterns の名前 fieldName のフィールドとする。そうでなければ rangePattern を undefined とする。selectedRangePattern が undefined でなく、かつ rangePattern が undefined なら、NOTE: このフィールド以下の差異についての範囲パターンが存在しないため、それ以上のチェックは実行されない。 checkMoreFields を false に設定する。fieldName が [[Default]] と等しくなく、かつ relevantFieldsEqual が true で、かつ checkMoreFields が true なら、selectedRangePattern を rangePattern に設定する。fieldName が [[AmPm]] なら、localTime1 .[[Hour]] が 12 未満なら、v1 を "am" とする。そうでなければ v1 を "pm" とする。localTime2 .[[Hour]] が 12 未満なら、v2 を "am" とする。そうでなければ v2 を "pm" とする。そうでなく fieldName が [[DayPeriod]] なら、v1 を localTime1 の day period を表す ILD String とする。v2 を localTime2 の day period を表す ILD String とする。 そうでなく fieldName が [[FractionalSecondDigits]] なら、format が [[fractionalSecondDigits]] フィールドを持つなら、fractionalSecondDigits を format .[[fractionalSecondDigits]] とする。そうでなければ、fractionalSecondDigits を 3 とする。 exp を fractionalSecondDigits - 3 とする。v1 を floor (localTime1 .[[Millisecond]] × 10exp ) とする。v2 を floor (localTime2 .[[Millisecond]] × 10exp ) とする。 そうでなければ、v1 を fieldName を名前とする localTime1 のフィールドとする。v2 を fieldName を名前とする localTime2 のフィールドとする。 v1 が v2 と等しくないなら、relevantFieldsEqual を false に設定する。relevantFieldsEqual が true なら、collapsedResult を新しい空の List とする。resultParts を FormatDateTimePattern (dateTimeFormat , format , pattern , xEpochNanoseconds ) とする。resultParts の各 Record { [[Type]] , [[Value]] } part について、次を行う。Record { [[Type]] : part .[[Type]] , [[Value]] : part .[[Value]] , [[Source]] : "shared" } を collapsedResult に追加する。collapsedResult を返す。rangeResult を新しい空の List とする。selectedRangePattern が undefined なら、selectedRangePattern を rangePatterns .[[Default]] に設定する。selectedRangePattern .[[PatternParts]] の各 Record { [[Pattern]] , [[Source]] } rangePatternPart について、次を行う。pattern を rangePatternPart .[[Pattern]] とする。source を rangePatternPart .[[Source]] とする。source が "startRange" または "shared" なら、z を xEpochNanoseconds とする。そうでなければ、z を yEpochNanoseconds とする。 resultParts を FormatDateTimePattern (dateTimeFormat , selectedRangePattern , pattern , z ) とする。resultParts の各 Record { [[Type]] , [[Value]] } part について、次を行う。Record { [[Type]] : part .[[Type]] , [[Value]] : part .[[Value]] , [[Source]] : source } を rangeResult に追加する。rangeResult を返す。
11.5.10 FormatDateTimeRange ( dateTimeFormat , x , y )
The abstract operation FormatDateTimeRange takes arguments dateTimeFormat (Intl.DateTimeFormat), x (Number), and y (Number) and returns String を含む正常完了、または throw 完了. It performs the following steps when called:
parts を ? PartitionDateTimeRangePattern (dateTimeFormat , x , y ) とする。result を空の String とする。parts の各 Record { [[Type]] , [[Value]] , [[Source]] } part について、次を行う。result を result と part .[[Value]] の文字列連結に設定する。result を返す。
11.5.11 FormatDateTimeRangeToParts ( dateTimeFormat , x , y )
The abstract operation FormatDateTimeRangeToParts takes arguments dateTimeFormat (Intl.DateTimeFormat), x (Number), and y (Number) and returns Array を含む正常完了、または throw 完了. It performs the following steps when called:
parts を ? PartitionDateTimeRangePattern (dateTimeFormat , x , y ) とする。result を ! ArrayCreate (0) とする。n を 0 とする。parts の各 Record { [[Type]] , [[Value]] , [[Source]] } part について、次を行う。partObj を OrdinaryObjectCreate (%Object.prototype% ) とする。! CreateDataPropertyOrThrow (partObj , "type" , part .[[Type]] ) を実行する。 ! CreateDataPropertyOrThrow (partObj , "value" , part .[[Value]] ) を実行する。 ! CreateDataPropertyOrThrow (partObj , "source" , part .[[Source]] ) を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), partObj ) を実行する。 n を n + 1 に設定する。result を返す。
11.5.12 ToLocalTime ( epochNs , calendar , timeZoneIdentifier )
The implementation-defined abstract operation ToLocalTime takes arguments epochNs (BigInt), calendar (String), and timeZoneIdentifier (String) and returns ToLocalTime Record . It performs the following steps when called:
IsTimeZoneOffsetString (timeZoneIdentifier ) が true なら、offsetNs を ParseTimeZoneOffsetString (timeZoneIdentifier ) とする。そうでなければ、Assert : GetAvailableNamedTimeZoneIdentifier (timeZoneIdentifier ) は empty ではない。offsetNs を GetNamedTimeZoneOffsetNanoseconds (timeZoneIdentifier , epochNs ) とする。 tz を ℝ (epochNs ) + offsetNs とする。calendar が "gregory" なら、Table 17 に従って tz から計算されたフィールドを持つ ToLocalTime Record を返す。そうでなければ、与えられた calendar について tz から計算されたフィールドを持つ ToLocalTime Record を返す。この計算は、指定された calendar に関する利用可能な最良の情報を使用すべきである。
11.5.13 ToLocalTime Records
各 ToLocalTime Record は、Table 17 で定義されるフィールドを持つ。
Table 17: ToLocalTime によって返される Record
11.5.14 UnwrapDateTimeFormat ( dtf )
The abstract operation UnwrapDateTimeFormat takes argument dtf (ECMAScript 言語値) and returns ECMAScript 言語値を含む正常完了、または throw 完了.
入力オブジェクトの DateTimeFormat インスタンスを返す。それは、その値自体、または 4.3 Note 1 の規範的任意コンストラクターモードに従って %Intl.DateTimeFormat% によって関連付けられた値のいずれかである。
It performs the following steps when called:
dtf が Object でないなら、TypeError 例外を投げる。dtf が [[InitializedDateTimeFormat]] 内部スロットを持たず、かつ ? OrdinaryHasInstance (%Intl.DateTimeFormat% , dtf ) が true なら、? Get (dtf , %Intl% .[[FallbackSymbol]] ) を返す。 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 とともに呼び出されるとき、次の手順が実行される:
NewTargetがundefined ならば、TypeError 例外を投げる。 displayNames を? OrdinaryCreateFromConstructor (NewTarget, "%Intl.DisplayNames.prototype%" , « [[InitializedDisplayNames]] , [[Locale]] , [[Style]] , [[Type]] , [[Fallback]] , [[LanguageDisplay]] , [[Fields]] »)とする。optionsResolution を? ResolveOptions (%Intl.DisplayNames% , %Intl.DisplayNames% .[[LocaleData]] , locales , options , « require-options »)とする。options をoptionsResolution .[[Options]] に設定する。resolvedLocale をoptionsResolution .[[ResolvedLocale]] とする。style を? GetOption (options , "style" , string , « "narrow" , "short" , "long" », "long" )とする。displayNames .[[Style]] をstyle に設定する。type を? GetOption (options , "type" , string , « "language" , "region" , "script" , "currency" , "calendar" , "dateTimeField" », required )とする。displayNames .[[Type]] をtype に設定する。fallback を? GetOption (options , "fallback" , string , « "code" , "none" », "code" )とする。displayNames .[[Fallback]] をfallback に設定する。displayNames .[[Locale]] をresolvedLocale .[[Locale]] に設定する。resolvedLocaleData をresolvedLocale .[[LocaleData]] とする。types をresolvedLocaleData .[[types]] とする。Assert : types はRecord である(12.2.3 を参照)。languageDisplay を? GetOption (options , "languageDisplay" , string , « "dialect" , "standard" », "dialect" )とする。typeFields をtypes .[[<type >]]とする。Assert : typeFields はRecord である(12.2.3 を参照)。type が"language" ならば、displayNames .[[LanguageDisplay]] をlanguageDisplay に設定する。typeFields をtypeFields .[[<languageDisplay >]]に設定する。Assert : typeFields はRecord である(12.2.3 を参照)。styleFields をtypeFields .[[<style >]]とする。Assert : styleFields はRecord である(12.2.3 を参照)。displayNames .[[Fields]] をstyleFields に設定する。displayNames を返す。
12.2 Intl.DisplayNamesコンストラクタのプロパティ
Intl.DisplayNamesコンストラクタは、次のとおりである:
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 とともに呼び出されるとき、次の手順が実行される:
availableLocales を%Intl.DisplayNames% .[[AvailableLocales]] とする。requestedLocales を? CanonicalizeLocaleList (locales )とする。? 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 ( )
この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。
displayNames をthis 値とする。? RequireInternalSlot (displayNames , [[InitializedDisplayNames]] )を実行する。 options をOrdinaryObjectCreate (%Object.prototype% )とする。Table 18 の各行(ヘッダ行を除く)について、表の順序で、次を行う:propertyKey を現在の行のProperty値とする。value を、その名前が現在の行のInternal Slot値であるdisplayNames の内部スロットの値とする。value がundefined でないならば、! CreateDataPropertyOrThrow (options , propertyKey , value )を実行する。 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 とともに呼び出されるとき、次の手順が実行される:
displayNames をthis 値とする。? RequireInternalSlot (displayNames , [[InitializedDisplayNames]] )を実行する。 code を? ToString (code )に設定する。code を? CanonicalCodeForDisplayNames (displayNames .[[Type]] , code )に設定する。fields をdisplayNames .[[Fields]] とする。fields にフィールド[[<code >]]があるならば、fields .[[<code >]]を返す。displayNames .[[Fallback]] が"code" ならば、code を返す。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:
type が"language" ならば、code がunicode_language_id Unicodeロケール非終端記号 により一致させることができないならば、RangeError 例外を投げる。IsWellFormedLanguageTag (code )がfalse ならば、RangeError 例外を投げる。CanonicalizeUnicodeLocaleId (code )を返す。type が"region" ならば、code がunicode_region_subtag Unicodeロケール非終端記号 により一致させることができないならば、RangeError 例外を投げる。code のASCII大文字化を返す。type が"script" ならば、code がunicode_script_subtag Unicodeロケール非終端記号 により一致させることができないならば、RangeError 例外を投げる。Assert : code の長さは4であり、code のすべてのコード単位はASCII文字(0x0041から0x005A、および0x0061から0x007Aまで、いずれも含む)を表す。first を、code の0から1までの部分文字列のASCII大文字化とする。rest を、code の1からの部分文字列のASCII小文字化とする。first とrest の文字列連結を返す。type が"calendar" ならば、code がtype Unicodeロケール非終端記号 により一致させることができないならば、RangeError 例外を投げる。code がUnicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance で述べられる後方互換性構文のいずれかを使用するならば、RangeError 例外を投げる。code のASCII小文字化を返す。type が"dateTimeField" ならば、IsValidDateTimeFieldCode (code )の結果がfalse ならば、RangeError 例外を投げる。code を返す。Assert : type は"currency" である。IsWellFormedCurrencyCode (code )がfalse ならば、RangeError 例外を投げる。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:
field がTable 19 のCode列に列挙されているならば、true を返す。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 とともに呼び出されるとき、次の手順が実行される:
NewTargetがundefined ならば、TypeError 例外を投げる。 durationFormat を? OrdinaryCreateFromConstructor (NewTarget, "%Intl.DurationFormatPrototype%" , « [[InitializedDurationFormat]] , [[Locale]] , [[NumberingSystem]] , [[Style]] , [[YearsOptions]] , [[MonthsOptions]] , [[WeeksOptions]] , [[DaysOptions]] , [[HoursOptions]] , [[MinutesOptions]] , [[SecondsOptions]] , [[MillisecondsOptions]] , [[MicrosecondsOptions]] , [[NanosecondsOptions]] , [[HourMinuteSeparator]] , [[MinuteSecondSeparator]] , [[FractionalDigits]] »)とする。optionsResolution を? ResolveOptions (%Intl.DurationFormat% , %Intl.DurationFormat% .[[LocaleData]] , locales , options )とする。options をoptionsResolution .[[Options]] に設定する。resolvedLocale をoptionsResolution .[[ResolvedLocale]] とする。durationFormat .[[Locale]] をresolvedLocale .[[Locale]] に設定する。resolvedLocaleData をresolvedLocale .[[LocaleData]] とする。digitalFormat をresolvedLocaleData .[[DigitalFormat]] とする。durationFormat .[[HourMinuteSeparator]] をdigitalFormat .[[HourMinuteSeparator]] に設定する。durationFormat .[[MinuteSecondSeparator]] をdigitalFormat .[[MinuteSecondSeparator]] に設定する。durationFormat .[[NumberingSystem]] をresolvedLocale .[[nu]] に設定する。style を? GetOption (options , "style" , string , « "long" , "short" , "narrow" , "digital" », "short" )とする。durationFormat .[[Style]] をstyle に設定する。prevStyle を空のStringとする。Table 20 の各行(ヘッダ行を除く)について、表の順序で、次を行う:slot を現在の行のInternal Slot値とする。unit を現在の行のUnit値とする。styles を現在の行のStyles値とする。digitalBase を現在の行のDigital Default値とする。unitOptions を? GetDurationUnitOptions (unit , options , style , styles , digitalBase , prevStyle , digitalFormat .[[TwoDigitHours]] )とする。durationFormat の、名前がslot である内部スロットの値をunitOptions に設定する。unit が"hours" 、"minutes" 、"seconds" 、"milliseconds" 、または"microseconds" のいずれかならば、prevStyle をunitOptions .[[Style]] に設定する。durationFormat .[[FractionalDigits]] を? GetNumberOption (options , "fractionalDigits" , 0, 9, undefined )に設定する。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コンストラクタは、次のとおりである:
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 とともに呼び出されるとき、次の手順が実行される:
availableLocales を%Intl.DurationFormat% .[[AvailableLocales]] とする。requestedLocales を? CanonicalizeLocaleList (locales )とする。? 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 ( )
この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。
df をthis 値とする。? RequireInternalSlot (df , [[InitializedDurationFormat]] )を実行する。 options をOrdinaryObjectCreate (%Object.prototype% )とする。Table 21 の各行(ヘッダ行を除く)について、表の順序で、次を行う:propertyKey を現在の行のProperty値とする。value を、その名前が現在の行のInternal Slot値であるdf の内部スロットの値とする。value がundefined でないならば、現在の行にConversion値があるならば、conversion をその値とする。そうでなければ、conversion をempty とする。 conversion がnumber ならば、value を𝔽 (value )に設定する。そうでなく、conversion がempty でないならば、Assert : conversion はstyle+display であり、value はDuration Unit Options Record である。NOTE: value .[[Style]] はpropertyKey (複数形のTemporal単位)という名前のプロパティで表され、その後value .[[Display]] はpropertyKey に"Display" を接尾する名前のプロパティで表される。 style をvalue .[[Style]] とする。style が"fractional" ならば、Assert : IsFractionalSecondUnitName (propertyKey )はtrue である。style を"numeric" に設定する。! CreateDataPropertyOrThrow (options , propertyKey , style )を実行する。 propertyKey をpropertyKey と"Display" の文字列連結に設定する。value をvalue .[[Display]] に設定する。 ! CreateDataPropertyOrThrow (options , propertyKey , value )を実行する。 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 とともに呼び出されるとき、次の手順が実行される:
df を this 値とする。? RequireInternalSlot (df , [[InitializedDurationFormat]] ) を実行する。 record を ? ToDurationRecord (duration ) とする。parts を PartitionDurationFormatPattern (df , record ) とする。result を空の String とする。parts の各 Record { [[Type]] , [[Value]] , [[Unit]] } part について、次を行う。result を result と part .[[Value]] の文字列連結に設定する。result を返す。
13.3.4 Intl.DurationFormat.prototype.formatToParts ( duration )
formatToPartsメソッドが引数duration とともに呼び出されるとき、次の手順が実行される:
df を this 値とする。? RequireInternalSlot (df , [[InitializedDurationFormat]] ) を実行する。 record を ? ToDurationRecord (duration ) とする。parts を PartitionDurationFormatPattern (df , record ) とする。result を ! ArrayCreate (0) とする。n を 0 とする。parts の各 Record { [[Type]] , [[Value]] , [[Unit]] } part について、次を行う。obj を OrdinaryObjectCreate (%Object.prototype% ) とする。! CreateDataPropertyOrThrow (obj , "type" , part .[[Type]] ) を実行する。 ! CreateDataPropertyOrThrow (obj , "value" , part .[[Value]] ) を実行する。 part .[[Unit]] が empty でないなら、! CreateDataPropertyOrThrow (obj , "unit" , part .[[Unit]] ) を実行する。! CreateDataPropertyOrThrow (result , ! ToString (n ), obj ) を実行する。 n を n + 1 に設定する。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コンストラクタ によって計算されるいくつかの内部スロットも持つ:
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:
number を? ToNumber (arg )とする。number が整数Numberでないならば、RangeError 例外を投げる。ℝ (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:
input がObjectでないならば、input がStringならば、RangeError 例外を投げる。TypeError 例外を投げる。result を、各フィールドが0に設定された新しいDuration Record とする。days を? Get (input , "days" )とする。days がundefined でないならば、result .[[Days]] を? ToIntegerIfIntegral (days )に設定する。hours を? Get (input , "hours" )とする。hours がundefined でないならば、result .[[Hours]] を? ToIntegerIfIntegral (hours )に設定する。microseconds を? Get (input , "microseconds" )とする。microseconds がundefined でないならば、result .[[Microseconds]] を? ToIntegerIfIntegral (microseconds )に設定する。milliseconds を? Get (input , "milliseconds" )とする。milliseconds がundefined でないならば、result .[[Milliseconds]] を? ToIntegerIfIntegral (milliseconds )に設定する。minutes を? Get (input , "minutes" )とする。minutes がundefined でないならば、result .[[Minutes]] を? ToIntegerIfIntegral (minutes )に設定する。months を? Get (input , "months" )とする。months がundefined でないならば、result .[[Months]] を? ToIntegerIfIntegral (months )に設定する。nanoseconds を? Get (input , "nanoseconds" )とする。nanoseconds がundefined でないならば、result .[[Nanoseconds]] を? ToIntegerIfIntegral (nanoseconds )に設定する。seconds を? Get (input , "seconds" )とする。seconds がundefined でないならば、result .[[Seconds]] を? ToIntegerIfIntegral (seconds )に設定する。weeks を? Get (input , "weeks" )とする。weeks がundefined でないならば、result .[[Weeks]] を? ToIntegerIfIntegral (weeks )に設定する。years を? Get (input , "years" )とする。years がundefined でないならば、result .[[Years]] を? ToIntegerIfIntegral (years )に設定する。years 、months 、weeks 、days 、hours 、minutes 、seconds 、milliseconds 、microseconds 、およびnanoseconds がすべてundefined ならば、TypeError 例外を投げる。IsValidDuration ( result .[[Years]] , result .[[Months]] , result .[[Weeks]] , result .[[Days]] , result .[[Hours]] , result .[[Minutes]] , result .[[Seconds]] , result .[[Milliseconds]] , result .[[Microseconds]] , result .[[Nanoseconds]] )がfalse ならば、RangeError 例外を投げる。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:
« duration .[[Years]] , duration .[[Months]] , duration .[[Weeks]] , duration .[[Days]] , duration .[[Hours]] , duration .[[Minutes]] , duration .[[Seconds]] , duration .[[Milliseconds]] , duration .[[Microseconds]] , duration .[[Nanoseconds]] »の各値v について、次を行う:v < 0ならば、-1を返す。v > 0ならば、1を返す。 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:
sign を0とする。« years , months , weeks , days , hours , minutes , seconds , milliseconds , microseconds , nanoseconds »の各値v について、次を行う:𝔽 (v )が有限でないならば、false を返す。v < 0ならば、sign > 0ならば、false を返す。sign を-1に設定する。そうでなく、v > 0ならば、sign < 0ならば、false を返す。sign を1に設定する。 abs (years ) ≥ 232 ならば、false を返す。abs (months ) ≥ 232 ならば、false を返す。abs (weeks ) ≥ 232 ならば、false を返す。normalizedSeconds をdays × 86,400 + hours × 3600 + minutes × 60 + seconds + ℝ (𝔽 (milliseconds )) × 10-3 + ℝ (𝔽 (microseconds )) × 10-6 + ℝ (𝔽 (nanoseconds )) × 10-9 とする。NOTE: 上記の手順は、浮動小数点演算を使用して直接実装することはできない。milliseconds 、microseconds 、またはnanoseconds が安全でない整数である場合、それぞれ10-3 、10-6 、および10-9 を掛けると不正確になる可能性がある。この乗算は、商に十分なビットを持つstd::remquo()の実装を使用してC++で実装できる。乗算は10の冪によるものであるため、文字列操作でも正確な結果が得られる。 abs (normalizedSeconds ) ≥ 253 ならば、false を返す。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:
style を? GetOption (options , unit , string , stylesList , undefined )とする。displayDefault を"always" とする。style がundefined ならば、baseStyle が"digital" ならば、style をdigitalBase に設定する。unit が"hours" 、"minutes" 、または"seconds" のいずれでもないならば、displayDefault を"auto" に設定する。そうでなく、prevStyle が"fractional" 、"numeric" 、または"2-digit" のいずれかならば、style を"numeric" に設定する。unit が"minutes" または"seconds" でないならば、displayDefault を"auto" に設定する。 そうでなければ、style をbaseStyle に設定する。displayDefault を"auto" に設定する。 style が"numeric" であり、かつIsFractionalSecondUnitName (unit )がtrue ならば、style を"fractional" に設定する。displayDefault を"auto" に設定する。displayField をunit と"Display" の文字列連結とする。display を? GetOption (options , displayField , string , « "auto" , "always" », displayDefault )とする。? ValidateDurationUnitStyle (unit , style , display , prevStyle )を実行する。 unit が"hours" であり、かつtwoDigitHours がtrue ならば、style を"2-digit" に設定する。unit が"minutes" または"seconds" であり、かつprevStyle が"numeric" または"2-digit" ならば、style を"2-digit" に設定する。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:
display が"always" であり、かつstyle が"fractional" ならば、RangeError 例外を投げる。prevStyle が"fractional" であり、かつstyle が"fractional" でないならば、RangeError 例外を投げる。prevStyle が"numeric" または"2-digit" であり、かつstyle が"fractional" 、"numeric" 、または"2-digit" のいずれでもないならば、RangeError 例外を投げる。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:
result を0とする。exponent を3とする。Table 24 の各行(ヘッダ行を除く)について、表の順序で、次を行う:unitOptions を、名前が現在の行のInternal Slot値であるdurationFormat の内部スロットの値とする。unitOptions .[[Style]] が"fractional" ならば、unit を現在の行のUnit値とする。Assert : IsFractionalSecondUnitName (unit )はtrue である。value を、名前が現在の行のValue Field値であるduration のフィールドの値とする。result をresult + (value / 10exponent )に設定する。exponent をexponent + 3に設定する。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:
unit が"seconds" であり、かつdurationFormat .[[MillisecondsOptions]] .[[Style]] が"fractional" ならば、true を返す。unit が"milliseconds" であり、かつdurationFormat .[[MicrosecondsOptions]] .[[Style]] が"fractional" ならば、true を返す。unit が"microseconds" であり、かつdurationFormat .[[NanosecondsOptions]] .[[Style]] が"fractional" ならば、true を返す。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:
result を新しい空のList とする。hoursStyle をdurationFormat .[[HoursOptions]] .[[Style]] とする。Assert : hoursStyle は"numeric" または"2-digit" である。nfOptions をOrdinaryObjectCreate (null )とする。numberingSystem をdurationFormat .[[NumberingSystem]] とする。! CreateDataPropertyOrThrow (nfOptions , "numberingSystem" , numberingSystem )を実行する。 hoursStyle が"2-digit" ならば、! CreateDataPropertyOrThrow (nfOptions , "minimumIntegerDigits" , 2 𝔽 )を実行する。 signDisplayed がfalse ならば、! CreateDataPropertyOrThrow (nfOptions , "signDisplay" , "never" )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "useGrouping" , false )を実行する。 nf を! Construct (%Intl.NumberFormat% , « durationFormat .[[Locale]] , nfOptions »)とする。hoursParts をPartitionNumberPattern (nf , hoursValue )とする。hoursParts の各Record { [[Type]] , [[Value]] } part について、次を行う:Record { [[Type]] : part .[[Type]] , [[Value]] : part .[[Value]] , [[Unit]] : "hour" }をresult に追加する。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:
result を新しい空のList とする。hoursDisplayed がtrue ならば、separator をdurationFormat .[[HourMinuteSeparator]] とする。Record { [[Type]] : "literal" , [[Value]] : separator , [[Unit]] : empty }をresult に追加する。minutesStyle をdurationFormat .[[MinutesOptions]] .[[Style]] とする。Assert : minutesStyle は"numeric" または"2-digit" である。nfOptions をOrdinaryObjectCreate (null )とする。numberingSystem をdurationFormat .[[NumberingSystem]] とする。! CreateDataPropertyOrThrow (nfOptions , "numberingSystem" , numberingSystem )を実行する。 minutesStyle が"2-digit" ならば、! CreateDataPropertyOrThrow (nfOptions , "minimumIntegerDigits" , 2 𝔽 )を実行する。 signDisplayed がfalse ならば、! CreateDataPropertyOrThrow (nfOptions , "signDisplay" , "never" )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "useGrouping" , false )を実行する。 nf を! Construct (%Intl.NumberFormat% , « durationFormat .[[Locale]] , nfOptions »)とする。minutesParts をPartitionNumberPattern (nf , minutesValue )とする。minutesParts の各Record { [[Type]] , [[Value]] } part について、次を行う:Record { [[Type]] : part .[[Type]] , [[Value]] : part .[[Value]] , [[Unit]] : "minute" }をresult に追加する。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:
result を新しい空のList とする。minutesDisplayed がtrue ならば、separator をdurationFormat .[[MinuteSecondSeparator]] とする。Record { [[Type]] : "literal" , [[Value]] : separator , [[Unit]] : empty }をresult に追加する。secondsStyle をdurationFormat .[[SecondsOptions]] .[[Style]] とする。Assert : secondsStyle は"numeric" または"2-digit" である。nfOptions をOrdinaryObjectCreate (null )とする。numberingSystem をdurationFormat .[[NumberingSystem]] とする。! CreateDataPropertyOrThrow (nfOptions , "numberingSystem" , numberingSystem )を実行する。 secondsStyle が"2-digit" ならば、! CreateDataPropertyOrThrow (nfOptions , "minimumIntegerDigits" , 2 𝔽 )を実行する。 signDisplayed がfalse ならば、! CreateDataPropertyOrThrow (nfOptions , "signDisplay" , "never" )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "useGrouping" , false )を実行する。 fractionDigits をdurationFormat .[[FractionalDigits]] とする。fractionDigits がundefined ならば、! CreateDataPropertyOrThrow (nfOptions , "maximumFractionDigits" , 9 𝔽 )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "minimumFractionDigits" , +0 𝔽 )を実行する。 そうでなければ、! CreateDataPropertyOrThrow (nfOptions , "maximumFractionDigits" , fractionDigits )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "minimumFractionDigits" , fractionDigits )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "roundingMode" , "trunc" )を実行する。 nf を! Construct (%Intl.NumberFormat% , « durationFormat .[[Locale]] , nfOptions »)とする。secondsParts をPartitionNumberPattern (nf , secondsValue )とする。secondsParts の各Record { [[Type]] , [[Value]] } part について、次を行う:Record { [[Type]] : part .[[Type]] , [[Value]] : part .[[Value]] , [[Unit]] : "second" }をresult に追加する。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:
Assert : firstNumericUnit は"hours" 、"minutes" 、または"seconds" である。numericPartsList を新しい空のList とする。hoursValue をduration .[[Hours]] とする。hoursDisplay をdurationFormat .[[HoursOptions]] .[[Display]] とする。minutesValue をduration .[[Minutes]] とする。minutesDisplay をdurationFormat .[[MinutesOptions]] .[[Display]] とする。secondsValue をduration .[[Seconds]] とする。duration .[[Milliseconds]] が0でない、またはduration .[[Microseconds]] が0でない、またはduration .[[Nanoseconds]] が0でないならば、secondsValue をsecondsValue + ComputeFractionalDigits (durationFormat , duration )に設定する。secondsDisplay をdurationFormat .[[SecondsOptions]] .[[Display]] とする。hoursFormatted をfalse とする。firstNumericUnit が"hours" ならば、hoursValue が0でない、またはhoursDisplay が"always" ならば、hoursFormatted をtrue に設定する。secondsValue が0でない、またはsecondsDisplay が"always" ならば、secondsFormatted をtrue とする。そうでなければ、secondsFormatted をfalse とする。 minutesFormatted をfalse とする。firstNumericUnit が"hours" またはfirstNumericUnit が"minutes" ならば、hoursFormatted がtrue であり、かつsecondsFormatted がtrue ならば、minutesFormatted をtrue に設定する。そうでなく、minutesValue が0でない、またはminutesDisplay が"always" ならば、minutesFormatted をtrue に設定する。 hoursFormatted がtrue ならば、signDisplayed がtrue ならば、hoursValue が0であり、かつDurationSign (duration )が-1ならば、hoursValue をnegative-zero に設定する。hoursParts をFormatNumericHours (durationFormat , hoursValue , signDisplayed )とする。numericPartsList をnumericPartsList とhoursParts のリスト連結に設定する。signDisplayed をfalse に設定する。minutesFormatted がtrue ならば、signDisplayed がtrue ならば、minutesValue が0であり、かつDurationSign (duration )が-1ならば、minutesValue をnegative-zero に設定する。minutesParts をFormatNumericMinutes (durationFormat , minutesValue , hoursFormatted , signDisplayed )とする。numericPartsList をnumericPartsList とminutesParts のリスト連結に設定する。signDisplayed をfalse に設定する。secondsFormatted がtrue ならば、secondsParts をFormatNumericSeconds (durationFormat , secondsValue , minutesFormatted , signDisplayed )とする。numericPartsList をnumericPartsList とsecondsParts のリスト連結に設定する。numericPartsList を返す。
13.5.13 IsFractionalSecondUnitName ( unit )
The abstract operation IsFractionalSecondUnitName takes argument unit (String) and returns Boolean. It performs the following steps when called:
unit が"milliseconds" 、"microseconds" 、または"nanoseconds" のいずれかならば、true を返す。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:
lfOptions を OrdinaryObjectCreate (null ) とする。! CreateDataPropertyOrThrow (lfOptions , "type" , "unit" ) を実行する。 listStyle を durationFormat .[[Style]] とする。listStyle が "digital" なら、listStyle を "short" に設定する。! CreateDataPropertyOrThrow (lfOptions , "style" , listStyle ) を実行する。 lf を ! Construct (%Intl.ListFormat% , « durationFormat .[[Locale]] , lfOptions ») とする。strings を新しい空の List とする。partitionedPartsList の各要素 parts について、次を行う。string を空の String とする。parts の各 Record { [[Type]] , [[Value]] , [[Unit]] } part について、次を行う。string を string と part .[[Value]] の文字列連結に設定する。string を strings に追加する。formattedPartsList を CreatePartsFromList (lf , strings ) とする。partitionedPartsIndex を 0 とする。partitionedLength を partitionedPartsList 内の要素数とする。flattenedPartsList を新しい空の List とする。formattedPartsList の各 Record { [[Type]] , [[Value]] } listPart について、次を行う。listPart .[[Type]] が "element" なら、Assert : partitionedPartsIndex < partitionedLength である。parts を partitionedPartsList [partitionedPartsIndex ] とする。parts の各 Record { [[Type]] , [[Value]] , [[Unit]] } part について、次を行う。part を flattenedPartsList に追加する。partitionedPartsIndex を partitionedPartsIndex + 1 に設定する。そうでなければ、Assert : listPart .[[Type]] は "literal" である。Record { [[Type]] : "literal" , [[Value]] : listPart .[[Value]] , [[Unit]] : empty } を flattenedPartsList に追加する。 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:
result を新しい空のList とする。signDisplayed をtrue とする。numericUnitFound をfalse とする。numericUnitFound がfalse である間、Table 24 内の各行(ヘッダ行を除く)について、表の順序で繰り返す:value を、名前が現在の行のValue Field値であるduration のフィールドの値とする。unitOptions を、名前が現在の行のInternal Slot値であるdurationFormat の内部スロットの値とする。style をunitOptions .[[Style]] とする。display をunitOptions .[[Display]] とする。unit を現在の行のUnit値とする。numberFormatUnit を現在の行のNumberFormat Unit値とする。style が"numeric" または"2-digit" ならば、numericPartsList をFormatNumericUnits (durationFormat , duration , unit , signDisplayed )とする。numericPartsList が空でないならば、numericPartsList をresult に追加する。numericUnitFound をtrue に設定する。そうでなければ、nfOptions をOrdinaryObjectCreate (null )とする。NextUnitFractional (durationFormat , unit )がtrue ならば、value をvalue + ComputeFractionalDigits (durationFormat , duration )に設定する。fractionDigits をdurationFormat .[[FractionalDigits]] とする。fractionDigits がundefined ならば、! CreateDataPropertyOrThrow (nfOptions , "maximumFractionDigits" , 9 𝔽 )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "minimumFractionDigits" , +0 𝔽 )を実行する。 そうでなければ、! CreateDataPropertyOrThrow (nfOptions , "maximumFractionDigits" , fractionDigits )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "minimumFractionDigits" , fractionDigits )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "roundingMode" , "trunc" )を実行する。 numericUnitFound をtrue に設定する。display が"always" である、またはvalue が0でないならば、! CreateDataPropertyOrThrow (nfOptions , "numberingSystem" , durationFormat .[[NumberingSystem]] )を実行する。 signDisplayed がtrue ならば、signDisplayed をfalse に設定する。value が0であり、かつDurationSign (duration )が-1ならば、value をnegative-zero に設定する。そうでなければ、! CreateDataPropertyOrThrow (nfOptions , "signDisplay" , "never" )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "style" , "unit" )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "unit" , numberFormatUnit )を実行する。 ! CreateDataPropertyOrThrow (nfOptions , "unitDisplay" , style )を実行する。 nf を! Construct (%Intl.NumberFormat% , « durationFormat .[[Locale]] , nfOptions »)とする。parts をPartitionNumberPattern (nf , value )とする。list を新しい空のList とする。parts の各Record { [[Type]] , [[Value]] } part について、次を行う:Record { [[Type]] : part .[[Type]] , [[Value]] : part .[[Value]] , [[Unit]] : numberFormatUnit }をlist に追加する。list をresult に追加する。 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.ListFormat% である。
Intlオブジェクト の"ListFormat" プロパティの初期値である。
Intlオブジェクト のすべてのサービスコンストラクタ プロパティに共通する挙動は、9.1 で規定される。
14.1.1 Intl.ListFormat ( [ locales [ , options ] ] )
Intl.ListFormat関数が省略可能な引数locales およびoptions とともに呼び出されるとき、次の手順が実行される:
NewTargetがundefined ならば、TypeError 例外を投げる。 listFormat を? OrdinaryCreateFromConstructor (NewTarget, "%Intl.ListFormat.prototype%" , « [[InitializedListFormat]] , [[Locale]] , [[Type]] , [[Style]] , [[Templates]] »)とする。optionsResolution を? ResolveOptions (%Intl.ListFormat% , %Intl.ListFormat% .[[LocaleData]] , locales , options )とする。options をoptionsResolution .[[Options]] に設定する。resolvedLocale をoptionsResolution .[[ResolvedLocale]] とする。listFormat .[[Locale]] をresolvedLocale .[[Locale]] に設定する。type を? GetOption (options , "type" , string , « "conjunction" , "disjunction" , "unit" », "conjunction" )とする。listFormat .[[Type]] をtype に設定する。style を? GetOption (options , "style" , string , « "long" , "short" , "narrow" », "long" )とする。listFormat .[[Style]] をstyle に設定する。resolvedLocaleData をresolvedLocale .[[LocaleData]] とする。dataLocaleTypes をresolvedLocaleData .[[<type >]]とする。listFormat .[[Templates]] をdataLocaleTypes .[[<style >]]に設定する。listFormat を返す。
14.2 Intl.ListFormatコンストラクタのプロパティ
Intl.ListFormatコンストラクタは、次のとおりである:
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 とともに呼び出されるとき、次の手順が実行される:
availableLocales を%Intl.ListFormat% .[[AvailableLocales]] とする。requestedLocales を? CanonicalizeLocaleList (locales )とする。? 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 ( )
この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。
lf をthis 値とする。? RequireInternalSlot (lf , [[InitializedListFormat]] )を実行する。 options をOrdinaryObjectCreate (%Object.prototype% )とする。Table 25 の各行(ヘッダ行を除く)について、表の順序で、次を行う:propertyKey を現在の行のProperty値とする。value を、その名前が現在の行のInternal Slot値であるlf の内部スロットの値とする。Assert : value はundefined でない。! CreateDataPropertyOrThrow (options , propertyKey , value )を実行する。 options を返す。
Table 25: ListFormatインスタンスのResolved Options
内部スロット
プロパティ
[[Locale]]
"locale"
[[Type]]
"type"
[[Style]]
"style"
14.3.3 Intl.ListFormat.prototype.format ( list )
formatメソッドが引数list とともに呼び出されるとき、次の手順が実行される:
lf をthis 値とする。? RequireInternalSlot (lf , [[InitializedListFormat]] )を実行する。 stringList を? StringListFromIterable (list )とする。FormatList (lf , stringList )を返す。
14.3.4 Intl.ListFormat.prototype.formatToParts ( list )
formatToPartsメソッドが引数list とともに呼び出されるとき、次の手順が実行される:
lf をthis 値とする。? RequireInternalSlot (lf , [[InitializedListFormat]] )を実行する。 stringList を? StringListFromIterable (list )とする。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:
patternParts をPartitionPattern (pattern )とする。result を新しい空のList とする。patternParts の各Record { [[Type]] , [[Value]] } patternPart について、次を行う:partType をpatternPart .[[Type]] とする。partType が"literal" ならば、Record { [[Type]] : "literal" , [[Value]] : patternPart .[[Value]] }をresult に追加する。そうでなければ、Assert : placeables はフィールド[[<partType >]]を持つ。substitution をplaceables .[[<partType >]]とする。substitution がList ならば、substitution の各要素part について、次を行う:part をresult に追加する。そうでなければ、substitution をresult に追加する。 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:
size を list の要素数とする。size が 0 なら、新しい空の List を返す。 size が 2 なら、n を、listFormat .[[Locale]] 、list [0]、および list [1] に基づく listFormat .[[Templates]] へのインデックスとする。pattern を listFormat .[[Templates]] [n ].[[Pair]] とする。first を Record { [[Type]] : "element" , [[Value]] : list [0] } とする。second を Record { [[Type]] : "element" , [[Value]] : list [1] } とする。placeables を Record { [[0]] : first , [[1]] : second } とする。DeconstructPattern (pattern , placeables ) を返す。last を Record { [[Type]] : "element" , [[Value]] : list [size - 1] } とする。parts を « last » とする。i を size - 2 とする。i ≥ 0 の間、繰り返す。head を Record { [[Type]] : "element" , [[Value]] : list [i ] } とする。n を、listFormat .[[Locale]] 、head 、および parts に基づく listFormat .[[Templates]] への実装定義のインデックスとする。i が 0 なら、pattern を listFormat .[[Templates]] [n ].[[Start]] とする。そうでなく i が size - 2 より小さいなら、pattern を listFormat .[[Templates]] [n ].[[Middle]] とする。 そうでなければ、pattern を listFormat .[[Templates]] [n ].[[End]] とする。 placeables を Record { [[0]] : head , [[1]] : parts } とする。parts を DeconstructPattern (pattern , placeables ) に設定する。i を i - 1 に設定する。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:
parts をCreatePartsFromList (listFormat , list )とする。result を空のStringとする。parts の各Record { [[Type]] , [[Value]] } part について、次を行う:result をresult とpart .[[Value]] の文字列連結に設定する。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:
parts をCreatePartsFromList (listFormat , list )とする。result を! ArrayCreate (0)とする。n を0とする。parts の各Record { [[Type]] , [[Value]] } part について、次を行う:obj をOrdinaryObjectCreate (%Object.prototype% )とする。! CreateDataPropertyOrThrow (obj , "type" , part .[[Type]] )を実行する。 ! CreateDataPropertyOrThrow (obj , "value" , part .[[Value]] )を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), obj )を実行する。 n を n + 1 に設定する。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:
iterable がundefined ならば、新しい空のList を返す。 iteratorRecord を? GetIterator (iterable , sync )とする。list を新しい空のList とする。繰り返す:next を? IteratorStepValue (iteratorRecord )とする。next がdone ならば、list を返す。next がStringでないならば、error をThrowCompletion (新しく作成されたTypeError オブジェクト)とする。? IteratorClose (iteratorRecord , error )を返す。 next をlist に追加する。
Note
このアルゴリズムは、Stringでない値に遭遇したときに例外を発生させる。任意の値に対する明らかなロケール認識の強制変換がないためである。
15 Localeオブジェクト
15.1 Intl.Localeコンストラクタ
Intl.Localeコンストラクタは、次のとおりである:
%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:
baseName をGetLocaleBaseName (tag )とする。language を? GetOption (options , "language" , string , empty , GetLocaleLanguage (baseName ))とする。language がunicode_language_subtag Unicodeロケール非終端記号 により一致させることができないならば、RangeError 例外を投げる。script を? GetOption (options , "script" , string , empty , GetLocaleScript (baseName ))とする。script がundefined でないならば、script がunicode_script_subtag Unicodeロケール非終端記号 により一致させることができないならば、RangeError 例外を投げる。region を? GetOption (options , "region" , string , empty , GetLocaleRegion (baseName ))とする。region がundefined でないならば、region がunicode_region_subtag Unicodeロケール非終端記号 により一致させることができないならば、RangeError 例外を投げる。variants を? GetOption (options , "variants" , string , empty , GetLocaleVariants (baseName ))とする。variants がundefined でないならば、variants が空のStringならば、RangeError 例外を投げる。lowerVariants をvariants のASCII小文字化とする。variantSubtags をStringSplitToList (lowerVariants , "-" )とする。variantSubtags の各要素variant について、次を行う:variant がunicode_variant_subtag Unicodeロケール非終端記号 により一致させることができないならば、RangeError 例外を投げる。variantSubtags が重複要素を含むならば、RangeError 例外を投げる。allExtensions をbaseName の後に続くtag の接尾部とする。newTag をlanguage とする。script がundefined でないならば、newTag をnewTag 、"-" 、およびscript の文字列連結に設定する。region がundefined でないならば、newTag をnewTag 、"-" 、およびregion の文字列連結に設定する。variants がundefined でないならば、newTag をnewTag 、"-" 、およびvariants の文字列連結に設定する。newTag をnewTag とallExtensions の文字列連結に設定する。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:
tag がUnicodeロケール拡張シーケンス であるsubstring を含むならば、extension を、tag 内のUnicodeロケール拡張シーケンス のsubstring からなるString値とする。components をUnicodeExtensionComponents (extension )とする。attributes をcomponents .[[Attributes]] とする。keywords をcomponents .[[Keywords]] とする。そうでなければ、attributes を新しい空のList とする。keywords を新しい空のList とする。 result を新しいRecord とする。localeExtensionKeys の各要素key について、次を行う:keywords が[[Key]] がkey である要素を含むならば、entry を、[[Key]] がkey であるkeywords の要素とする。value をentry .[[Value]] とする。そうでなければ、entry をempty とする。value をundefined とする。 Assert : options はフィールド[[<key >]]を持つ。overrideValue をoptions .[[<key >]]とする。overrideValue がundefined でないならば、value をCanonicalizeUValue (key , overrideValue )に設定する。entry がempty でないならば、entry .[[Value]] をvalue に設定する。そうでなければ、Record { [[Key]] : key , [[Value]] : value }をkeywords に追加する。 result .[[<key >]]をvalue に設定する。locale を、任意のUnicodeロケール拡張シーケンス が削除されたtag であるString値とする。attributes が空でない、またはkeywords が空でないならば、result .[[locale]] をInsertUnicodeExtensionAndCanonicalize (locale , attributes , keywords )に設定する。そうでなければ、result .[[locale]] をCanonicalizeUnicodeLocaleId (locale )に設定する。 result を返す。
15.2 Intl.Localeコンストラクタのプロパティ
Intl.Localeコンストラクタは、次のとおりである:
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アクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 GetLocaleBaseName (loc .[[Locale]] )を返す。
15.3.3 get Intl.Locale.prototype.calendar
Intl.Locale.prototype.calendarは、setアクセサ関数がundefined であるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 loc .[[Calendar]] を返す。
15.3.4 get Intl.Locale.prototype.caseFirst
このプロパティは、%Intl.Locale% .[[LocaleExtensionKeys]] が"kf" を含む場合にのみ存在する。
Intl.Locale.prototype.caseFirstは、setアクセサ関数がundefined であるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 loc .[[CaseFirst]] を返す。
15.3.5 get Intl.Locale.prototype.collation
Intl.Locale.prototype.collationは、setアクセサ関数がundefined であるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 loc .[[Collation]] を返す。
15.3.6 get Intl.Locale.prototype.firstDayOfWeek
Intl.Locale.prototype.firstDayOfWeekは、setアクセサ関数がundefined であるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 loc .[[FirstDayOfWeek]] を返す。
15.3.7 get Intl.Locale.prototype.hourCycle
Intl.Locale.prototype.hourCycleは、setアクセサ関数がundefined であるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 loc .[[HourCycle]] を返す。
15.3.8 get Intl.Locale.prototype.language
Intl.Locale.prototype.languageは、setアクセサ関数がundefined であるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 GetLocaleLanguage (loc .[[Locale]] )を返す。
15.3.9 Intl.Locale.prototype.maximize ( )
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 maximal を、loc .[[Locale]] に適用されたAdd Likely Subtags アルゴリズムの結果とする。エラーが通知されたならば、maximal をloc .[[Locale]] に設定する。! Construct (%Intl.Locale% , « maximal »)を返す。
15.3.10 Intl.Locale.prototype.minimize ( )
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 minimal を、loc .[[Locale]] に適用されたRemove Likely Subtags アルゴリズムの結果とする。エラーが通知されたならば、minimal をloc .[[Locale]] に設定する。! Construct (%Intl.Locale% , « minimal »)を返す。
15.3.11 get Intl.Locale.prototype.numberingSystem
Intl.Locale.prototype.numberingSystemは、setアクセサ関数がundefined であるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 loc .[[NumberingSystem]] を返す。
15.3.12 get Intl.Locale.prototype.numeric
このプロパティは、%Intl.Locale% .[[LocaleExtensionKeys]] が"kn" を含む場合にのみ存在する。
Intl.Locale.prototype.numericは、setアクセサ関数がundefined であるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 loc .[[Numeric]] を返す。
15.3.13 get Intl.Locale.prototype.region
Intl.Locale.prototype.regionは、setアクセサ関数がundefined であるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 GetLocaleRegion (loc .[[Locale]] )を返す。
15.3.14 get Intl.Locale.prototype.script
Intl.Locale.prototype.scriptは、setアクセサ関数がundefined であるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 GetLocaleScript (loc .[[Locale]] )を返す。
15.3.15 Intl.Locale.prototype.toString ( )
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 loc .[[Locale]] を返す。
15.3.16 Intl.Locale.prototype.getCalendars ( )
getCalendarsメソッドが呼び出されるとき、次の手順が実行される:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 CalendarsOfLocale (loc )を返す。
15.3.17 Intl.Locale.prototype.getCollations ( )
getCollationsメソッドが呼び出されるとき、次の手順が実行される:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 CollationsOfLocale (loc )を返す。
15.3.18 Intl.Locale.prototype.getHourCycles ( )
getHourCyclesメソッドが呼び出されるとき、次の手順が実行される:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 HourCyclesOfLocale (loc )を返す。
15.3.19 Intl.Locale.prototype.getNumberingSystems ( )
getNumberingSystemsメソッドが呼び出されるとき、次の手順が実行される:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 NumberingSystemsOfLocale (loc )を返す。
15.3.20 Intl.Locale.prototype.getTimeZones ( )
getTimeZonesメソッドが呼び出されるとき、次の手順が実行される:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 TimeZonesOfLocale (loc )を返す。
15.3.21 Intl.Locale.prototype.getTextInfo ( )
getTextInfoメソッドが呼び出されるとき、次の手順が実行される:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 info をOrdinaryObjectCreate (%Object.prototype% )とする。dir をTextDirectionOfLocale (loc )とする。! CreateDataPropertyOrThrow (info , "direction" , dir )を実行する。 info を返す。
15.3.22 Intl.Locale.prototype.getWeekInfo ( )
getWeekInfoメソッドが呼び出されるとき、次の手順が実行される:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 info をOrdinaryObjectCreate (%Object.prototype% )とする。weekInfo をWeekInfoOfLocale (loc )とする。! CreateDataPropertyOrThrow (info , "firstDay" , weekInfo .[[FirstDay]] )を実行する。 ! CreateDataPropertyOrThrow (info , "weekend" , CreateArrayFromList (weekInfo .[[Weekend]] ))を実行する。 info を返す。
15.3.23 get Intl.Locale.prototype.variants
Intl.Locale.prototype.variantsは、setアクセサ関数がundefined であるアクセサプロパティである。そのgetアクセサ関数は次の手順を実行する:
loc をthis 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] )を実行する。 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コンストラクタ によって計算されるいくつかの内部スロットも持つ:
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:
Assert : locale はunicode_locale_id Unicodeロケール非終端記号 により一致させることができる。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:
baseName をGetLocaleBaseName (locale )とする。Assert : baseName の最初のサブタグ はunicode_language_subtag Unicodeロケール非終端記号 により一致させることができる。baseName の最初のサブタグ を返す。
15.5.3 GetLocaleScript ( locale )
The abstract operation GetLocaleScript takes argument locale (String) and returns Stringまたはundefined . It performs the following steps when called:
baseName をGetLocaleBaseName (locale )とする。Assert : baseName は、unicode_script_subtag Unicodeロケール非終端記号 により一致させることができるサブタグ を高々1つ含む。baseName がunicode_script_subtag Unicodeロケール非終端記号 により一致するサブタグ を含むならば、そのサブタグ を返す。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:
baseName をGetLocaleBaseName (locale )とする。NOTE: unicode_region_subtagサブタグ は、最初のunicode_language_subtagサブタグ の直後、必要に応じてその間に単一のunicode_script_subtagサブタグ を伴う位置でのみ有効である。その位置では、unicode_region_subtagは他の有効なサブタグ と混同され得ない。すべての生成規則が互いに素であるためである。 Assert : baseName の最初のサブタグ はunicode_language_subtag Unicodeロケール非終端記号 により一致させることができる。baseNameTail を、最初のサブタグ に続くbaseName の接尾部とする。Assert : baseNameTail は、unicode_region_subtag Unicodeロケール非終端記号 により一致させることができるサブタグ を高々1つ含む。baseNameTail がunicode_region_subtag Unicodeロケール非終端記号 により一致するサブタグ を含むならば、そのサブタグ を返す。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:
baseName を GetLocaleBaseName (locale ) とする。NOTE: baseName 内で "-" が前に付く各サブタグ は、unicode_script_subtag、unicode_region_subtag、または unicode_variant_subtag のいずれかであるが、unicode_variant_subtag に一致する任意の substring は、他の生成規則のいずれかにも一致し得るその任意の接頭辞よりも厳密に長い。 subtags を StringSplitToList (baseName , "-" ) とする。dashIndex を subtags [0] の長さとする。subtags から最初の要素を取り除く。subtags の各 String subtag について、次を行う。subtag が unicode_variant_subtag Unicode ロケール非終端記号に一致するなら、baseName の dashIndex + 1 から始まる部分文字列を返す。subtagLength を subtag の長さとする。dashIndex を dashIndex + subtagLength + 1 に設定する。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:
locale がUnicodeロケール拡張シーケンス を含むならば、extension をlocale のUnicodeロケール拡張シーケンス とする。components をUnicodeExtensionComponents (extension )とする。keywords をcomponents .[[Keywords]] とする。keywords の要素entry でentry .[[Key]] がkey であるものが存在するならば、entry .[[Value]] を返す。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:
subdivision をUnicodeExtensionValue (locale , key )とする。subdivision がempty ならば、undefined を返す。subdivision がunicode_subdivision_id Unicodeロケール非終端記号 により一致させることができないならば、undefined を返す。region を、unicode_region_subtag Unicodeロケール非終端記号 により一致するsubdivision の最長の接頭部とする。regionLocale を"und-" とregion の文字列連結とする。regionLocale をCanonicalizeUnicodeLocaleId (regionLocale )に設定する。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:
region をGetLocaleRegion (locale )とする。region がundefined ならば、region をCanonicalUnicodeSubdivision (locale , "sd" )に設定する。region がundefined ならば、maximal を、locale に適用されたAdd Likely Subtags アルゴリズムの結果とする。エラーが通知されたならば、maximal をlocale に設定する。maximal をCanonicalizeUnicodeLocaleId (maximal )に設定する。region をGetLocaleRegion (maximal )に設定する。region がundefined ならば、region を"001" に設定する。regionOverride をCanonicalUnicodeSubdivision (locale , "rg" )とする。{ [[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:
loc .[[Calendar]] がundefined でないならば、CreateArrayFromList (« loc .[[Calendar]] »)を返す。preference をRegionPreference (loc .[[Locale]] )とする。region をpreference .[[Region]] とする。regionOverride をpreference .[[RegionOverride]] とする。regionOverride がundefined でなく、かつregionOverride のカレンダー選好データが利用可能ならば、lookupRegion をregionOverride とする。そうでなければ、lookupRegion をregion とする。 list を新しい空のList とする。availableCalendars をAvailableCalendars ()とする。calendarsInUse を、lookupRegion における日時整形で一般に使用される一意なカレンダー型 のList であり、lookupRegion での使用選好の降順でソートされたものとする。lookupRegion のカレンダー選好データが利用可能でない場合、このList は空である。calendarsInUse の各要素identifier について、次を行う:canonical をCanonicalizeUValue ("ca" , identifier )とする。identifier がcanonical であり、かつavailableCalendars がidentifier を含むならば、identifier をlist に追加する。list が空ならば、list を« "gregory" »に設定する。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:
loc .[[Collation]] がundefined でないならば、CreateArrayFromList (« loc .[[Collation]] »)を返す。language をGetLocaleLanguage (loc .[[Locale]] )とする。language が"und" でないならば、match をLookupMatchingLocaleByPrefix (%Intl.Collator% .[[AvailableLocales]] , « loc .[[Locale]] »)とする。match がundefined でないならばfoundLocale をmatch .[[locale]] とし、そうでなければfoundLocale をDefaultLocale ()とする。foundLocaleData を%Intl.Collator% .[[SortLocaleData]] .[[<foundLocale >]]とする。list をfoundLocaleData .[[co]] のコピーとする。Assert : list [0]はnull である。list から最初の要素を削除する。そうでなければ、list を« "emoji" , "eor" »とする。 sorted を、辞書式コード単位順序に従ってソートされたlist のコピーとする。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:
loc .[[HourCycle]] がundefined でないならば、CreateArrayFromList (« loc .[[HourCycle]] »)を返す。preference をRegionPreference (loc .[[Locale]] )とする。region をpreference .[[Region]] とする。regionOverride をpreference .[[RegionOverride]] とする。regionOverride がundefined でなく、かつregionOverride の時刻データが利用可能ならば、lookupRegion をregionOverride とする。そうでなければ、lookupRegion をregion とする。 list を、一意な時制識別子のList であり、12時間形式("h11" 、"h12" )または24時間形式("h23" 、"h24" )のいずれかを示す小文字String値でなければならず、lookupRegion における日時整形で一般に使用されるものの降順の選好でソートされたものとする。lookupRegion の時刻データが利用可能でない場合、このList は空である。list が空ならば、list を« "h23" »に設定する。CreateArrayFromList (list )を返す。
15.5.12 NumberingSystemsOfLocale ( loc )
The implementation-defined abstract operation NumberingSystemsOfLocale takes argument loc (Intl.Locale) and returns Array. It performs the following steps when called:
loc .[[NumberingSystem]] がundefined でないならば、CreateArrayFromList (« loc .[[NumberingSystem]] »)を返す。match をLookupMatchingLocaleByPrefix (%Intl.NumberFormat% .[[AvailableLocales]] , « loc .[[Locale]] »)とする。match がundefined でないならば、foundLocale をmatch .[[locale]] とする。foundLocaleData を%Intl.NumberFormat% .[[LocaleData]] .[[<foundLocale >]]とする。numberingSystems をfoundLocaleData .[[nu]] とする。list を« numberingSystems [0] »とする。そうでなければ、list を« "latn" »とする。 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:
region をGetLocaleRegion (loc .[[Locale]] )とする。region がundefined ならば、undefined を返す。list を、一意な正準タイムゾーン識別子のList であり、IANA Time Zone Databaseの正準Zone名を示すString値でなければならず、region で一般に使用されるものとする。region で一般に使用されるタイムゾーンがない場合、このList は空である。このList は辞書式コード単位順序に従ってソートされる。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:
locale をloc .[[Locale]] とする。script をGetLocaleScript (locale )とする。script がundefined ならば、maximal を、locale に適用されたAdd Likely Subtags アルゴリズムの結果とする。エラーが通知されたならば、undefined を返す。script をGetLocaleScript (maximal )に設定する。script がundefined ならば、undefined を返す。script 内の行内における文字の既定の一般順序が右から左ならば、"rtl" を返す。script 内の行内における文字の既定の一般順序が左から右ならば、"ltr" を返す。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:
Table 26 の各行(ヘッダ行を除く)について、表の順序で、次を行う:weekday を現在の行のWeekday値とする。string を現在の行のString値とする。fw がweekday と等しいならば、string を返す。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:
Table 26 の各行(ヘッダ行を除く)について、表の順序で、次を行う:string を現在の行のString値とする。value を現在の行のValue値とする。fw がstring と等しいならば、value を返す。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:
locale をloc .[[Locale]] とする。weekInfo を、フィールドがTable 27 で定義され、値がlocale に基づくRecord とする。firstDayString をloc .[[FirstDayOfWeek]] とする。firstDayString がundefined でないならば、firstDay をWeekdayUValueToNumber (firstDayString )とする。firstDay がundefined でないならば、weekInfo .[[FirstDay]] をfirstDay に設定する。weekInfo を返す。
Note
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 とともに呼び出されるとき、次の手順が実行される:
NewTargetがundefined ならばnewTarget を実行中の関数オブジェクトとし、そうでなければnewTarget をNewTargetとする。 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]] »)とする。optionsResolution を? ResolveOptions (%Intl.NumberFormat% , %Intl.NumberFormat% .[[LocaleData]] , locales , options , « coerce-options »)とする。options をoptionsResolution .[[Options]] に設定する。resolvedLocale をoptionsResolution .[[ResolvedLocale]] とする。numberFormat .[[Locale]] をresolvedLocale .[[Locale]] に設定する。numberFormat .[[LocaleData]] をresolvedLocale .[[LocaleData]] に設定する。numberFormat .[[NumberingSystem]] をresolvedLocale .[[nu]] に設定する。? SetNumberFormatUnitOptions (numberFormat , options )を実行する。 style をnumberFormat .[[Style]] とする。notation を? GetOption (options , "notation" , string , « "standard" , "scientific" , "engineering" , "compact" », "standard" )とする。numberFormat .[[Notation]] をnotation に設定する。style が"currency" であり、かつnotation が"standard" ならば、currency をnumberFormat .[[Currency]] とする。cDigits をCurrencyDigits (currency )とする。mnfdDefault をcDigits とする。mxfdDefault をcDigits とする。そうでなければ、mnfdDefault を0とする。style が"percent" ならば、mxfdDefault を0とする。そうでなければ、mxfdDefault を3とする。 ? SetNumberFormatDigitOptions (numberFormat , options , mnfdDefault , mxfdDefault , notation )を実行する。 compactDisplay を? GetOption (options , "compactDisplay" , string , « "short" , "long" », "short" )とする。defaultUseGrouping を"auto" とする。notation が"compact" ならば、numberFormat .[[CompactDisplay]] をcompactDisplay に設定する。defaultUseGrouping を"min2" に設定する。NOTE: 歴史的理由により、文字列"true" および"false" は受け入れられ、デフォルト値に置き換えられる。 useGrouping を? GetBooleanOrStringNumberFormatOption (options , "useGrouping" , « "min2" , "auto" , "always" , "true" , "false" », defaultUseGrouping )とする。useGrouping が"true" またはuseGrouping が"false" ならば、useGrouping をdefaultUseGrouping に設定する。useGrouping がtrue ならば、useGrouping を"always" に設定する。numberFormat .[[UseGrouping]] をuseGrouping に設定する。signDisplay を? GetOption (options , "signDisplay" , string , « "auto" , "never" , "always" , "exceptZero" , "negative" », "auto" )とする。numberFormat .[[SignDisplay]] をsignDisplay に設定する。実装が4.3 Note 1 の規範的任意コンストラクタモードをサポートするならば、this をthis 値とする。? ChainNumberFormat (numberFormat , NewTarget, this )を返す。 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:
newTarget がundefined であり、かつ? OrdinaryHasInstance (%Intl.NumberFormat% , this )がtrue ならば、? DefinePropertyOrThrow (this , %Intl% .[[FallbackSymbol]] , PropertyDescriptor { [[Value]] : numberFormat , [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : false })を実行する。 this を返す。numberFormat を返す。
16.1.2 SetNumberFormatDigitOptions ( intlObj , options , mnfdDefault , mxfdDefault , notation )
The abstract operation SetNumberFormatDigitOptions takes arguments intlObj (Object), options (Object), mnfdDefault (整数), mxfdDefault (整数), and notation (String) and returns unused を含む通常完了またはthrow完了. ロケール非依存の数値丸めに影響するintlObj の内部スロットを設定する(16.5.3 参照)。 It performs the following steps when called:
mnid を? GetNumberOption (options , "minimumIntegerDigits" , 1, 21, 1)とする。mnfd を? Get (options , "minimumFractionDigits" )とする。mxfd を? Get (options , "maximumFractionDigits" )とする。mnsd を? Get (options , "minimumSignificantDigits" )とする。mxsd を? Get (options , "maximumSignificantDigits" )とする。intlObj .[[MinimumIntegerDigits]] をmnid に設定する。roundingIncrement を? GetNumberOption (options , "roundingIncrement" , 1, 5000, 1)とする。roundingIncrement が« 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000 »内にないならば、RangeError 例外を投げる。roundingMode を? GetOption (options , "roundingMode" , string , « "ceil" , "floor" , "expand" , "trunc" , "halfCeil" , "halfFloor" , "halfExpand" , "halfTrunc" , "halfEven" », "halfExpand" )とする。roundingPriority を? GetOption (options , "roundingPriority" , string , « "auto" , "morePrecision" , "lessPrecision" », "auto" )とする。trailingZeroDisplay を? GetOption (options , "trailingZeroDisplay" , string , « "auto" , "stripIfInteger" », "auto" )とする。NOTE: SetNumberFormatDigitOptions に必要なすべてのフィールドは、すでにoptions から読み取られている。このAOの残りはオプションを解釈し、例外を投げる可能性がある。 roundingIncrement が1でないならば、mxfdDefault をmnfdDefault に設定する。intlObj .[[RoundingIncrement]] をroundingIncrement に設定する。intlObj .[[RoundingMode]] をroundingMode に設定する。intlObj .[[TrailingZeroDisplay]] をtrailingZeroDisplay に設定する。mnsd がundefined であり、かつmxsd がundefined ならばhasSd をfalse とする。そうでなければ、hasSd をtrue とする。mnfd がundefined であり、かつmxfd がundefined ならばhasFd をfalse とする。そうでなければ、hasFd をtrue とする。needSd をtrue とする。needFd をtrue とする。roundingPriority が"auto" ならば、needSd をhasSd に設定する。needSd がtrue である、またはhasFd がfalse かつnotation が"compact" であるならば、needFd をfalse に設定する。needSd がtrue ならば、hasSd がtrue ならば、intlObj .[[MinimumSignificantDigits]] を? DefaultNumberOption (mnsd , 1, 21, 1)に設定する。intlObj .[[MaximumSignificantDigits]] を? DefaultNumberOption (mxsd , intlObj .[[MinimumSignificantDigits]] , 21, 21)に設定する。そうでなければ、intlObj .[[MinimumSignificantDigits]] を1に設定する。intlObj .[[MaximumSignificantDigits]] を21に設定する。 needFd がtrue ならば、hasFd がtrue ならば、mnfd を? DefaultNumberOption (mnfd , 0, 100, undefined )に設定する。mxfd を? DefaultNumberOption (mxfd , 0, 100, undefined )に設定する。mnfd がundefined ならば、mnfd をmin (mnfdDefault , mxfd )に設定する。そうでなく、mxfd がundefined ならば、mxfd をmax (mxfdDefault , mnfd )に設定する。 そうでなく、mnfd がmxfd より大きいならば、RangeError 例外を投げる。 intlObj .[[MinimumFractionDigits]] をmnfd に設定する。intlObj .[[MaximumFractionDigits]] をmxfd に設定する。そうでなければ、intlObj .[[MinimumFractionDigits]] をmnfdDefault に設定する。intlObj .[[MaximumFractionDigits]] をmxfdDefault に設定する。 needSd がfalse であり、かつneedFd がfalse ならば、intlObj .[[MinimumFractionDigits]] を0に設定する。intlObj .[[MaximumFractionDigits]] を0に設定する。intlObj .[[MinimumSignificantDigits]] を1に設定する。intlObj .[[MaximumSignificantDigits]] を2に設定する。intlObj .[[RoundingType]] をmore-precision に設定する。intlObj .[[ComputedRoundingPriority]] を"morePrecision" に設定する。そうでなく、roundingPriority が"morePrecision" ならば、intlObj .[[RoundingType]] をmore-precision に設定する。intlObj .[[ComputedRoundingPriority]] を"morePrecision" に設定する。 そうでなく、roundingPriority が"lessPrecision" ならば、intlObj .[[RoundingType]] をless-precision に設定する。intlObj .[[ComputedRoundingPriority]] を"lessPrecision" に設定する。 そうでなく、hasSd がtrue ならば、intlObj .[[RoundingType]] をsignificant-digits に設定する。intlObj .[[ComputedRoundingPriority]] を"auto" に設定する。 そうでなければ、intlObj .[[RoundingType]] をfraction-digits に設定する。intlObj .[[ComputedRoundingPriority]] を"auto" に設定する。 roundingIncrement が1でないならば、intlObj .[[RoundingType]] がfraction-digits でないならば、TypeError 例外を投げる。intlObj .[[MaximumFractionDigits]] がintlObj .[[MinimumFractionDigits]] でないならば、RangeError 例外を投げる。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:
style を? GetOption (options , "style" , string , « "decimal" , "percent" , "currency" , "unit" », "decimal" )とする。intlObj .[[Style]] をstyle に設定する。currency を? GetOption (options , "currency" , string , empty , undefined )とする。currency がundefined ならば、style が"currency" ならば、TypeError 例外を投げる。そうでなければ、IsWellFormedCurrencyCode (currency )がfalse ならば、RangeError 例外を投げる。 currencyDisplay を? GetOption (options , "currencyDisplay" , string , « "code" , "symbol" , "narrowSymbol" , "name" », "symbol" )とする。currencySign を? GetOption (options , "currencySign" , string , « "standard" , "accounting" », "standard" )とする。unit を? GetOption (options , "unit" , string , empty , undefined )とする。unit がundefined ならば、style が"unit" ならば、TypeError 例外を投げる。そうでなければ、IsWellFormedUnitIdentifier (unit )がfalse ならば、RangeError 例外を投げる。 unitDisplay を? GetOption (options , "unitDisplay" , string , « "short" , "narrow" , "long" », "short" )とする。style が"currency" ならば、intlObj .[[Currency]] をcurrency のASCII-uppercase に設定する。intlObj .[[CurrencyDisplay]] をcurrencyDisplay に設定する。intlObj .[[CurrencySign]] をcurrencySign に設定する。style が"unit" ならば、intlObj .[[Unit]] をunit に設定する。intlObj .[[UnitDisplay]] をunitDisplay に設定する。unused を返す。
16.2 Intl.NumberFormatコンストラクタのプロパティ
Intl.NumberFormatコンストラクタは、次のとおりである:
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 とともに呼び出されるとき、次の手順が実行される:
availableLocales を%Intl.NumberFormat% .[[AvailableLocales]] とする。requestedLocales を? CanonicalizeLocaleList (locales )とする。? 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 ( )
この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。
nf をthis 値とする。実装が4.3 Note 1 の規範的任意コンストラクタモードをサポートするならば、nf を? UnwrapNumberFormat (nf )に設定する。 ? RequireInternalSlot (nf , [[InitializedNumberFormat]] )を実行する。 options をOrdinaryObjectCreate (%Object.prototype% )とする。Table 28 の各行(ヘッダ行を除く)について、表の順序で、次を行う:propertyKey を現在の行のProperty値とする。value を、その名前が現在の行のInternal Slot値であるnf の内部スロットの値とする。value がundefined でないならば、現在の行にConversion値があるならば、Assert : 現在の行のConversion値はnumber である。value を𝔽 (value )に設定する。 ! CreateDataPropertyOrThrow (options , propertyKey , value )を実行する。 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アクセサ関数は次の手順を実行する:
nf をthis 値とする。実装が4.3 Note 1 の規範的任意コンストラクタモードをサポートするならば、nf を? UnwrapNumberFormat (nf )に設定する。 ? RequireInternalSlot (nf , [[InitializedNumberFormat]] )を実行する。 nf .[[BoundFormat]] がundefined ならば、Number Format Functions(16.5.2 )で定義される新しい組込み関数オブジェクトfunc を作成する。 func .[[NumberFormat]] をnf に設定する。nf .[[BoundFormat]] をfunc に設定する。nf .[[BoundFormat]] を返す。
Note
返される関数はnf に束縛されるため、Array.prototype.mapまたはその他の関数へ直接渡すことができる。
これは歴史的な遺物と見なされる。新機能ではもはや従われていない慣例の一部であるが、既存プログラムとの互換性を維持するために保持されている。
16.3.4 Intl.NumberFormat.prototype.formatRange ( start , end )
formatRangeメソッドが引数start およびend とともに呼び出されるとき、次の手順が実行される:
nf をthis 値とする。? RequireInternalSlot (nf , [[InitializedNumberFormat]] )を実行する。 start がundefined またはend がundefined ならば、TypeError 例外を投げる。x を? ToIntlMathematicalValue (start )とする。y を? ToIntlMathematicalValue (end )とする。? FormatNumericRange (nf , x , y )を返す。
16.3.5 Intl.NumberFormat.prototype.formatRangeToParts ( start , end )
formatRangeToPartsメソッドが引数start およびend とともに呼び出されるとき、次の手順が実行される:
nf をthis 値とする。? RequireInternalSlot (nf , [[InitializedNumberFormat]] )を実行する。 start がundefined またはend がundefined ならば、TypeError 例外を投げる。x を? ToIntlMathematicalValue (start )とする。y を? ToIntlMathematicalValue (end )とする。? FormatNumericRangeToParts (nf , x , y )を返す。
16.3.6 Intl.NumberFormat.prototype.formatToParts ( value )
formatToPartsメソッドが省略可能な引数value とともに呼び出されるとき、次の手順が実行される:
nf をthis 値とする。? RequireInternalSlot (nf , [[InitializedNumberFormat]] )を実行する。 x を? ToIntlMathematicalValue (value )とする。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:
Assert : IsWellFormedCurrencyCode (currency )はtrue である。currency に対応する通貨の数量を整形するときに使用される小数部桁数を示す非負整数を返す。使用される桁数に関する利用可能な情報がない場合は、2を返す。
16.5.2 数値整形関数
数値整形関数は、[[NumberFormat]] 内部スロットを持つ無名の組込み関数である。
数値整形関数func が省略可能な引数value とともに呼び出されるとき、次の手順が実行される:
nf をfunc .[[NumberFormat]] とする。Assert : nf はObjectであり、nf は[[InitializedNumberFormat]] 内部スロットを持つ。value が提供されていないならば、value をundefined とする。x を? ToIntlMathematicalValue (value )とする。FormatNumeric (nf , x )を返す。
数値整形関数の"length" プロパティは1 𝔽 である。
16.5.3 FormatNumericToString ( intlObj , x )
The abstract operation FormatNumericToString takes arguments intlObj (Object) and x (数学的値またはnegative-zero ) and returns フィールド[[RoundedNumber]] (数学的値またはnegative-zero )および[[FormattedString]] (String)を持つRecord . intlObj の内部スロットに従ってx をIntl数学的値 へ丸める。[[RoundedNumber]] フィールドは丸め結果値を含み、[[FormattedString]] フィールドはintlObj の内部スロットに従って整形されたその結果のString値表現を含む。 It performs the following steps when called:
Assert : intlObj は[[RoundingMode]] 、[[RoundingType]] 、[[MinimumSignificantDigits]] 、[[MaximumSignificantDigits]] 、[[MinimumIntegerDigits]] 、[[MinimumFractionDigits]] 、[[MaximumFractionDigits]] 、[[RoundingIncrement]] 、および[[TrailingZeroDisplay]] 内部スロットを持つ。x がnegative-zero ならば、sign をnegative とする。x を0に設定する。そうでなければ、Assert : x は数学的値である。x < 0ならばsign をnegative とし、そうでなければsign をpositive とする。sign がnegative ならば、x を-x に設定する。 unsignedRoundingMode をGetUnsignedRoundingMode (intlObj .[[RoundingMode]] , sign )とする。intlObj .[[RoundingType]] がsignificant-digits ならば、result をToRawPrecision (x , intlObj .[[MinimumSignificantDigits]] , intlObj .[[MaximumSignificantDigits]] , unsignedRoundingMode )とする。そうでなく、intlObj .[[RoundingType]] がfraction-digits ならば、result をToRawFixed (x , intlObj .[[MinimumFractionDigits]] , intlObj .[[MaximumFractionDigits]] , intlObj .[[RoundingIncrement]] , unsignedRoundingMode )とする。 そうでなければ、significantResult をToRawPrecision (x , intlObj .[[MinimumSignificantDigits]] , intlObj .[[MaximumSignificantDigits]] , unsignedRoundingMode )とする。fractionResult をToRawFixed (x , intlObj .[[MinimumFractionDigits]] , intlObj .[[MaximumFractionDigits]] , intlObj .[[RoundingIncrement]] , unsignedRoundingMode )とする。fractionResult .[[RoundingMagnitude]] < significantResult .[[RoundingMagnitude]] ならばfixedIsMorePrecise をtrue とし、そうでなければfixedIsMorePrecise をfalse とする。intlObj .[[RoundingType]] がmore-precision であり、かつfixedIsMorePrecise がtrue ならば、result をfractionResult とする。そうでなく、intlObj .[[RoundingType]] がless-precision であり、かつfixedIsMorePrecise がfalse ならば、result をfractionResult とする。 そうでなければ、result をsignificantResult とする。 x をresult .[[RoundedNumber]] に設定する。string をresult .[[FormattedString]] とする。intlObj .[[TrailingZeroDisplay]] が"stripIfInteger" であり、かつx modulo 1 = 0 ならば、i をStringIndexOf (string , "." , 0)とする。i がnot-found でないならば、string をstring の0からi までの部分文字列に設定する。int をresult .[[IntegerDigitsCount]] とする。minIntDigits をintlObj .[[MinimumIntegerDigits]] とする。int < minIntDigits ならば、forwardZeros を、コード単位0x0030(DIGIT ZERO)がminIntDigits - int 回出現するStringとする。string をforwardZeros とstring の文字列連結に設定する。sign がnegative ならば、x が0ならば、x をnegative-zero に設定する。そうでなければ、x を-x に設定する。Record { [[RoundedNumber]] : x , [[FormattedString]] : string }を返す。
16.5.4 PartitionNumberPattern ( numberFormat , x )
The abstract operation PartitionNumberPattern takes arguments numberFormat (NumberFormatとして初期化されたオブジェクト) and x (Intl数学的値 ) and returns フィールド[[Type]] (String)および[[Value]] (String)を持つRecord のList . numberFormat の有効なロケールおよび整形オプションに従って、x の数学的値を表す部分を作成する。 It performs the following steps when called:
exponent を0とする。x がnot-a-number ならば、formattedString をNaN 値を示すILD String値とする。そうでなく、x がpositive-infinity ならば、formattedString を正の無限大を示すILD String値とする。 そうでなく、x がnegative-infinity ならば、formattedString を負の無限大を示すILD String値とする。 そうでなければ、x がnegative-zero でないならば、Assert : x は数学的値である。numberFormat .[[Style]] が"percent" ならば、x を100 × x に設定する。exponent をComputeExponent (numberFormat , x )に設定する。x をx × 10-exponent に設定する。formatNumberResult をFormatNumericToString (numberFormat , x )とする。formattedString をformatNumberResult .[[FormattedString]] とする。x をformatNumberResult .[[RoundedNumber]] に設定する。 pattern をGetNumberFormatPattern (numberFormat , x )とする。result を新しい空のList とする。patternParts をPartitionPattern (pattern )とする。patternParts の各Record { [[Type]] , [[Value]] } patternPart について、次を行う:partType をpatternPart .[[Type]] とする。partType が"literal" ならば、Record { [[Type]] : "literal" , [[Value]] : patternPart .[[Value]] }をresult に追加する。そうでなく、partType が"number" ならば、notationSubParts をPartitionNotationSubPattern (numberFormat , x , formattedString , exponent )とする。result をresult とnotationSubParts のリスト連結に設定する。 そうでなく、partType が"plusSign" ならば、plusSignSymbol をプラス記号を表すILND Stringとする。Record { [[Type]] : "plusSign" , [[Value]] : plusSignSymbol }をresult に追加する。 そうでなく、partType が"minusSign" ならば、minusSignSymbol をマイナス記号を表すILND Stringとする。Record { [[Type]] : "minusSign" , [[Value]] : minusSignSymbol }をresult に追加する。 そうでなく、partType が"percentSign" であり、かつnumberFormat .[[Style]] が"percent" ならば、percentSignSymbol をパーセント記号を表すILND Stringとする。Record { [[Type]] : "percentSign" , [[Value]] : percentSignSymbol }をresult に追加する。 そうでなく、partType が"unitPrefix" であり、かつnumberFormat .[[Style]] が"unit" ならば、unit をnumberFormat .[[Unit]] とする。unitDisplay をnumberFormat .[[UnitDisplay]] とする。unitString を、unitDisplay 形式でx の前にあるunit を表すILD String値とする。これは、異なる複数形を持つ言語ではx に依存することがある。Record { [[Type]] : "unit" , [[Value]] : unitString }をresult に追加する。 そうでなく、partType が"unitSuffix" であり、かつnumberFormat .[[Style]] が"unit" ならば、unit をnumberFormat .[[Unit]] とする。unitDisplay をnumberFormat .[[UnitDisplay]] とする。unitString を、unitDisplay 形式でx の後にあるunit を表すILD String値とする。これは、異なる複数形を持つ言語ではx に依存することがある。Record { [[Type]] : "unit" , [[Value]] : unitString }をresult に追加する。 そうでなく、partType が"currencyCode" であり、かつnumberFormat .[[Style]] が"currency" ならば、currency をnumberFormat .[[Currency]] とする。Record { [[Type]] : "currency" , [[Value]] : currency }をresult に追加する。 そうでなく、partType が"currencyPrefix" であり、かつnumberFormat .[[Style]] が"currency" ならば、currency をnumberFormat .[[Currency]] とする。currencyDisplay をnumberFormat .[[CurrencyDisplay]] とする。currencyString を、currencyDisplay 形式でx の前にあるcurrency を表すILD String値とする。これは、異なる複数形を持つ言語ではx に依存することがある。Record { [[Type]] : "currency" , [[Value]] : currencyString }をresult に追加する。 そうでなく、partType が"currencySuffix" であり、かつnumberFormat .[[Style]] が"currency" ならば、currency をnumberFormat .[[Currency]] とする。currencyDisplay をnumberFormat .[[CurrencyDisplay]] とする。currencyString を、currencyDisplay 形式でx の後にあるcurrency を表すILD String値とする。これは、異なる複数形を持つ言語ではx に依存することがある。実装がcurrency のそのような表現を持たない場合は、currency 自体を使用する。Record { [[Type]] : "currency" , [[Value]] : currencyString }をresult に追加する。 そうでなければ、unknown をx およびpartType に基づくILND Stringとする。Record { [[Type]] : "unknown" , [[Value]] : unknown }をresult に追加する。 result を返す。
16.5.5 PartitionNotationSubPattern ( numberFormat , x , formattedString , exponent )
The abstract operation PartitionNotationSubPattern takes arguments numberFormat (Intl.NumberFormat), x (Intl数学的値 ), formattedString (String), and exponent (整数) and returns フィールド[[Type]] (String)および[[Value]] (String)を持つRecord のList .
x は丸めが適用された後のIntl数学的値 であり、formattedString は中間の整形済み文字列である。
numberFormat の有効なロケールおよび整形オプションに従って、数値および表記に対応する部分を作成する。
It performs the following steps when called:
result を新しい空のList とする。x がnot-a-number ならば、Record { [[Type]] : "nan" , [[Value]] : formattedString }をresult に追加する。そうでなく、x がpositive-infinity またはnegative-infinity ならば、Record { [[Type]] : "infinity" , [[Value]] : formattedString }をresult に追加する。 そうでなければ、notationSubPattern をGetNotationSubPattern (numberFormat , exponent )とする。patternParts をPartitionPattern (notationSubPattern )とする。patternParts の各Record { [[Type]] , [[Value]] } patternPart について、次を行う:partType をpatternPart .[[Type]] とする。partType が"literal" ならば、Record { [[Type]] : "literal" , [[Value]] : patternPart .[[Value]] }をresult に追加する。そうでなく、partType が"number" ならば、numberFormat .[[NumberingSystem]] が下のTable 30 のNumbering System列内の値の1つに一致するならば、digits を、Table 30 の一致する行のDigits列で指定されたコードポイントを要素とするList とする。Assert : digits の長さは10である。transliterated を空のStringとする。length をformattedString の長さとする。position を0とする。position < length である間、繰り返す:c をformattedString 内のインデックスposition にあるコード単位とする。0x0030 ≤ c ≤ 0x0039ならば、NOTE: c はASCII数字である。 i をc - 0x0030とする。c をCodePointsToString (« digits [i ] »)に設定する。 transliterated をtransliterated とc の文字列連結に設定する。position をposition + 1に設定する。formattedString をtransliterated に設定する。そうでなければ、実装依存アルゴリズムを使用して、formattedString を所与の番号体系におけるformattedString の適切な表現へ対応付ける。 decimalSepIndex をStringIndexOf (formattedString , "." , 0)とする。decimalSepIndex がnot-found でなく、かつdecimalSepIndex > 0ならば、intDigits をformattedString の0からdecimalSepIndex までの部分文字列とする。fractionDigits をformattedString のdecimalSepIndex + 1からの部分文字列とする。そうでなければ、intDigits をformattedString とする。fractionDigits をundefined とする。 numberFormat .[[UseGrouping]] がfalse ならば、Record { [[Type]] : "integer" , [[Value]] : intDigits }をresult に追加する。そうでなければ、groupSepSymbol を桁区切り記号を表すILND Stringとする。groups を、intDigits 内のILND の位置集合によって定義される部分文字列を左から右の順序で要素とするList とする。これはnumberFormat .[[UseGrouping]] の値に依存することがある。Assert : groups List 内の要素数は0より大きい。groups List が空でない間、繰り返す:groups から最初の要素を削除し、intGroup をその要素の値とする。Record { [[Type]] : "integer" , [[Value]] : intGroup }をresult に追加する。groups List が空でないならば、Record { [[Type]] : "group" , [[Value]] : groupSepSymbol }をresult に追加する。 fractionDigits がundefined でないならば、decimalSepSymbol を小数点記号を表すILND Stringとする。Record { [[Type]] : "decimal" , [[Value]] : decimalSepSymbol }をresult に追加する。Record { [[Type]] : "fraction" , [[Value]] : fractionDigits }をresult に追加する。 そうでなく、partType が"compactSymbol" ならば、compactSymbol を、exponent を短い形式で表すILD stringとする。これは、異なる複数形を持つ言語ではx に依存することがある。実装はこの文字列を提供できなければならず、そうでなければパターンに"{compactSymbol}" プレースホルダーが存在しないはずである。Record { [[Type]] : "compact" , [[Value]] : compactSymbol }をresult に追加する。 そうでなく、partType が"compactName" ならば、compactName を、exponent を長い形式で表すILD stringとする。これは、異なる複数形を持つ言語ではx に依存することがある。実装はこの文字列を提供できなければならず、そうでなければパターンに"{compactName}" プレースホルダーが存在しないはずである。Record { [[Type]] : "compact" , [[Value]] : compactName }をresult に追加する。 そうでなく、partType が"scientificSeparator" ならば、scientificSeparator を指数区切りを表すILND Stringとする。Record { [[Type]] : "exponentSeparator" , [[Value]] : scientificSeparator }をresult に追加する。 そうでなく、partType が"scientificExponent" ならば、exponent < 0ならば、minusSignSymbol をマイナス記号を表すILND Stringとする。Record { [[Type]] : "exponentMinusSign" , [[Value]] : minusSignSymbol }をresult に追加する。exponent を-exponent とする。exponentResult をToRawFixed (exponent , 0, 0, 1, undefined )とする。Record { [[Type]] : "exponentInteger" , [[Value]] : exponentResult .[[FormattedString]] }をresult に追加する。 そうでなければ、unknown をx およびpartType に基づくILND Stringとする。Record { [[Type]] : "unknown" , [[Value]] : unknown }をresult に追加する。 result を返す。
Table 30: 単純な数字マッピングを持つ番号体系
番号体系
数字
adlm
U+1E950 to U+1E959
ahom
U+11730 to U+11739
arab
U+0660 to U+0669
arabext
U+06F0 to U+06F9
bali
U+1B50 to U+1B59
beng
U+09E6 to U+09EF
bhks
U+11C50 to U+11C59
brah
U+11066 to U+1106F
cakm
U+11136 to U+1113F
cham
U+AA50 to U+AA59
deva
U+0966 to U+096F
diak
U+11950 to U+11959
fullwide
U+FF10 to U+FF19
gara
U+10D40 to U+10D49
gong
U+11DA0 to U+11DA9
gonm
U+11D50 to U+11D59
gujr
U+0AE6 to U+0AEF
gukh
U+16130 to U+16139
guru
U+0A66 to U+0A6F
hanidec
U+3007, U+4E00, U+4E8C, U+4E09, U+56DB, U+4E94, U+516D, U+4E03, U+516B, U+4E5D
hmng
U+16B50 to U+16B59
hmnp
U+1E140 to U+1E149
java
U+A9D0 to U+A9D9
kali
U+A900 to U+A909
kawi
U+11F50 to U+11F59
khmr
U+17E0 to U+17E9
knda
U+0CE6 to U+0CEF
krai
U+16D70 to U+16D79
lana
U+1A80 to U+1A89
lanatham
U+1A90 to U+1A99
laoo
U+0ED0 to U+0ED9
latn
U+0030 to U+0039
lepc
U+1C40 to U+1C49
limb
U+1946 to U+194F
mathbold
U+1D7CE to U+1D7D7
mathdbl
U+1D7D8 to U+1D7E1
mathmono
U+1D7F6 to U+1D7FF
mathsanb
U+1D7EC to U+1D7F5
mathsans
U+1D7E2 to U+1D7EB
mlym
U+0D66 to U+0D6F
modi
U+11650 to U+11659
mong
U+1810 to U+1819
mroo
U+16A60 to U+16A69
mtei
U+ABF0 to U+ABF9
mymr
U+1040 to U+1049
mymrepka
U+116DA to U+116E3
mymrpao
U+116D0 to U+116D9
mymrshan
U+1090 to U+1099
mymrtlng
U+A9F0 to U+A9F9
nagm
U+1E4F0 to U+1E4F9
newa
U+11450 to U+11459
nkoo
U+07C0 to U+07C9
olck
U+1C50 to U+1C59
onao
U+1E5F1 to U+1E5FA
orya
U+0B66 to U+0B6F
osma
U+104A0 to U+104A9
outlined
U+1CCF0 to U+1CCF9
rohg
U+10D30 to U+10D39
saur
U+A8D0 to U+A8D9
segment
U+1FBF0 to U+1FBF9
shrd
U+111D0 to U+111D9
sind
U+112F0 to U+112F9
sinh
U+0DE6 to U+0DEF
sora
U+110F0 to U+110F9
sund
U+1BB0 to U+1BB9
sunu
U+11BF0 to U+11BF9
takr
U+116C0 to U+116C9
talu
U+19D0 to U+19D9
tamldec
U+0BE6 to U+0BEF
telu
U+0C66 to U+0C6F
thai
U+0E50 to U+0E59
tibt
U+0F20 to U+0F29
tirh
U+114D0 to U+114D9
tnsa
U+16AC0 to U+16AC9
tols
U+11DE0 to U+11DE9
vaii
U+A620 to U+A629
wara
U+118E0 to U+118E9
wcho
U+1E2F0 to U+1E2F9
Note 1
計算は、
numberFormat の有効なロケール、または
numberFormat の有効なロケールおよび番号体系に依存する、数値文字列内の
ILD および
ILND String値ならびに位置に依存する。言及された
ILD および
ILND String値は、通貨名のものを除き、Unicode Standardで規定されるGeneral Category "Number, decimal digit"内のコードポイントを含んではならない。
Note 2
実装は、Common Locale Data Repository(
https://cldr.unicode.org/ で入手可能)が提供するロケールを使用することが推奨される。
16.5.6 FormatNumeric ( numberFormat , x )
The abstract operation FormatNumeric takes arguments numberFormat (Intl.NumberFormat) and x (Intl数学的値 ) and returns String. It performs the following steps when called:
parts をPartitionNumberPattern (numberFormat , x )とする。result を空のStringとする。parts の各Record { [[Type]] , [[Value]] } part について、次を行う:result をresult とpart .[[Value]] の文字列連結に設定する。result を返す。
16.5.7 FormatNumericToParts ( numberFormat , x )
The abstract operation FormatNumericToParts takes arguments numberFormat (Intl.NumberFormat) and x (Intl数学的値 ) and returns Array. It performs the following steps when called:
parts をPartitionNumberPattern (numberFormat , x )とする。result を! ArrayCreate (0)とする。n を0とする。parts の各Record { [[Type]] , [[Value]] } part について、次を行う:partObj をOrdinaryObjectCreate (%Object.prototype% )とする。! CreateDataPropertyOrThrow (partObj , "type" , part .[[Type]] )を実行する。 ! CreateDataPropertyOrThrow (partObj , "value" , part .[[Value]] )を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), partObj )を実行する。 n を n + 1 に設定する。result を返す。
16.5.8 ToRawPrecision ( x , minPrecision , maxPrecision , unsignedRoundingMode )
The abstract operation ToRawPrecision takes arguments x (非負の数学的値), minPrecision (1から21までの包含区間内の整数), maxPrecision (1から21までの包含区間内の整数), and unsignedRoundingMode (Table 31 のUnsigned Rounding Mode列からの仕様型、またはundefined ) and returns フィールド[[FormattedString]] (String)、[[RoundedNumber]] (数学的値)、[[IntegerDigitsCount]] (整数)、および[[RoundingMagnitude]] (整数)を持つRecord .
これは次の方程式を解くことを伴う。この方程式は整数入力が与えられたとき、有効な数学的値を返す:
ToRawPrecisionFn(n , e , p ) = n × 10e –p +1
where 10p –1 ≤ n < 10p
It performs the following steps when called:
p をmaxPrecision とする。x = 0ならば、m を、コード単位0x0030(DIGIT ZERO)がp 回出現するStringとする。e を0とする。xFinal を0とする。そうでなければ、n1 およびe1 をそれぞれ整数とし、r1 を数学的値とする。ただし、r1 = ToRawPrecisionFn (n1 , e1 , p ) であり、r1 ≤ x であり、r1 は最大化される。n2 およびe2 をそれぞれ整数とし、r2 を数学的値とする。ただし、r2 = ToRawPrecisionFn (n2 , e2 , p ) であり、r2 ≥ x であり、r2 は最小化される。xFinal をApplyUnsignedRoundingMode (x , r1 , r2 , unsignedRoundingMode )とする。xFinal がr1 ならば、n をn1 とする。e をe1 とする。そうでなければ、n をn2 とする。e をe2 とする。 m を、n の10進表現の数字からなるString(順序どおり、先頭ゼロなし)とする。 e ≥ (p - 1)ならば、m をm と、コード単位0x0030(DIGIT ZERO)のe - p + 1回の出現との文字列連結に設定する。int をe + 1とする。そうでなく、e ≥ 0ならば、m を、m の最初のe + 1個のコード単位、コード単位0x002E(FULL STOP)、およびm の残りのp - (e + 1)個のコード単位の文字列連結に設定する。int をe + 1とする。 そうでなければ、Assert : e < 0である。m を、"0." 、コード単位0x0030(DIGIT ZERO)の-(e + 1)回の出現、およびm の文字列連結に設定する。int を1とする。 m がコード単位0x002E(FULL STOP)を含み、かつmaxPrecision > minPrecision ならば、cut をmaxPrecision - minPrecision とする。cut > 0であり、かつm の最後のコード単位が0x0030(DIGIT ZERO)である間、繰り返す:m から最後のコード単位を削除する。cut をcut - 1に設定する。m の最後のコード単位が0x002E(FULL STOP)ならば、m から最後のコード単位を削除する。Record { [[FormattedString]] : m , [[RoundedNumber]] : xFinal , [[IntegerDigitsCount]] : int , [[RoundingMagnitude]] : e –p +1 }を返す。
16.5.9 ToRawFixed ( x , minFraction , maxFraction , roundingIncrement , unsignedRoundingMode )
The abstract operation ToRawFixed takes arguments x (非負の数学的値), minFraction (0から100までの包含区間内の整数), maxFraction (0から100までの包含区間内の整数), roundingIncrement (整数), and unsignedRoundingMode (Table 31 のUnsigned Rounding Mode列からの仕様型、またはundefined ) and returns フィールド[[FormattedString]] (String)、[[RoundedNumber]] (数学的値)、[[IntegerDigitsCount]] (整数)、および[[RoundingMagnitude]] (整数)を持つRecord .
これは次の方程式を解くことを伴う。この方程式は整数入力が与えられたとき、有効な数学的値を返す:
ToRawFixedFn(n , f ) = n × 10–f
It performs the following steps when called:
f をmaxFraction とする。n1 を整数とし、r1 を数学的値とする。ただし、r1 = ToRawFixedFn (n1 , f ) であり、n1 modulo roundingIncrement = 0 であり、r1 ≤ x であり、r1 は最大化される。n2 を整数とし、r2 を数学的値とする。ただし、r2 = ToRawFixedFn (n2 , f ) であり、n2 modulo roundingIncrement = 0 であり、r2 ≥ x であり、r2 は最小化される。xFinal をApplyUnsignedRoundingMode (x , r1 , r2 , unsignedRoundingMode )とする。xFinal がr1 ならばn をn1 とする。そうでなければn をn2 とする。n = 0ならばm を"0" とする。そうでなければ、m をn の10進表現の数字からなるString(順序どおり、先頭ゼロなし)とする。f ≠ 0ならば、k をm の長さとする。k ≤ f ならば、z を、コード単位0x0030(DIGIT ZERO)がf + 1 - k 回出現するString値とする。m をz とm の文字列連結に設定する。k をf + 1に設定する。a をm の最初のk - f 個のコード単位とし、b をm の残りのf 個のコード単位とする。m をa 、"." 、およびb の文字列連結に設定する。int をa の長さとする。そうでなければ、int をm の長さとする。 cut をmaxFraction - minFraction とする。cut > 0であり、かつm の最後のコード単位が0x0030(DIGIT ZERO)である間、繰り返す:m から最後のコード単位を削除する。cut をcut - 1に設定する。m の最後のコード単位が0x002E(FULL STOP)ならば、m から最後のコード単位を削除する。Record { [[FormattedString]] : m , [[RoundedNumber]] : xFinal , [[IntegerDigitsCount]] : int , [[RoundingMagnitude]] : –f }を返す。
16.5.10 UnwrapNumberFormat ( nf )
The abstract operation UnwrapNumberFormat takes argument nf (ECMAScript言語値) and returns ECMAScript言語値を含む通常完了またはthrow完了.
入力オブジェクトのNumberFormatインスタンスを返す。これは、その値自体、または4.3 Note 1 の規範的任意コンストラクタモードに従って%Intl.NumberFormat% によって関連付けられた値のいずれかである。
It performs the following steps when called:
nf がObjectでないならば、TypeError 例外を投げる。nf が[[InitializedNumberFormat]] 内部スロットを持たず、かつ? OrdinaryHasInstance (%Intl.NumberFormat% , nf )がtrue ならば、? Get (nf , %Intl% .[[FallbackSymbol]] )を返す。 nf を返す。
16.5.11 GetNumberFormatPattern ( numberFormat , x )
The abstract operation GetNumberFormatPattern takes arguments numberFormat (Intl.NumberFormat) and x (Intl数学的値 ) and returns String.
数値形式オブジェクト内の解決済み単位関連オプションを、整形される最終的にスケーリングおよび丸められた数値(Intl数学的値 )とともに考慮し、16.2.3 で述べられるString値であるパターンを返す。
It performs the following steps when called:
resolvedLocaleData をnumberFormat .[[LocaleData]] とする。patterns をresolvedLocaleData .[[patterns]] とする。Assert : patterns はRecord である(16.2.3 参照)。style をnumberFormat .[[Style]] とする。style が"percent" ならば、patterns をpatterns .[[percent]] に設定する。そうでなく、style が"unit" ならば、unit をnumberFormat .[[Unit]] とする。unitDisplay をnumberFormat .[[UnitDisplay]] とする。patterns をpatterns .[[unit]] に設定する。patterns がフィールド[[<unit >]]を持たないならば、unit を"fallback" に設定する。patterns をpatterns .[[<unit >]]に設定する。patterns をpatterns .[[<unitDisplay >]]に設定する。 そうでなく、style が"currency" ならば、currency をnumberFormat .[[Currency]] とする。currencyDisplay をnumberFormat .[[CurrencyDisplay]] とする。currencySign をnumberFormat .[[CurrencySign]] とする。patterns をpatterns .[[currency]] に設定する。patterns がフィールド[[<currency >]]を持たないならば、currency を"fallback" に設定する。patterns をpatterns .[[<currency >]]に設定する。patterns をpatterns .[[<currencyDisplay >]]に設定する。patterns をpatterns .[[<currencySign >]]に設定する。 そうでなければ、Assert : style は"decimal" である。patterns をpatterns .[[decimal]] に設定する。 x がnegative-infinity ならば、category をnegative-non-zero とする。そうでなく、x がnegative-zero ならば、category をnegative-zero とする。 そうでなく、x がnot-a-number ならば、category をpositive-zero とする。 そうでなく、x がpositive-infinity ならば、category をpositive-non-zero とする。 そうでなければ、Assert : x は数学的値である。x < 0ならば、category をnegative-non-zero とする。そうでなく、x > 0ならば、category をpositive-non-zero とする。 そうでなければ、category をpositive-zero とする。 signDisplay をnumberFormat .[[SignDisplay]] とする。signDisplay が"never" ならば、pattern をpatterns .[[zeroPattern]] とする。そうでなく、signDisplay が"auto" ならば、category がpositive-non-zero またはpositive-zero ならば、pattern をpatterns .[[zeroPattern]] とする。そうでなければ、pattern をpatterns .[[negativePattern]] とする。 そうでなく、signDisplay が"always" ならば、category がpositive-non-zero またはpositive-zero ならば、pattern をpatterns .[[positivePattern]] とする。そうでなければ、pattern をpatterns .[[negativePattern]] とする。 そうでなく、signDisplay が"exceptZero" ならば、category がpositive-zero またはnegative-zero ならば、pattern をpatterns .[[zeroPattern]] とする。そうでなく、category がpositive-non-zero ならば、pattern をpatterns .[[positivePattern]] とする。 そうでなければ、pattern をpatterns .[[negativePattern]] とする。 そうでなければ、Assert : signDisplay は"negative" である。category がnegative-non-zero ならば、pattern をpatterns .[[negativePattern]] とする。そうでなければ、pattern をpatterns .[[zeroPattern]] とする。 pattern を返す。
16.5.12 GetNotationSubPattern ( numberFormat , exponent )
The abstract operation GetNotationSubPattern takes arguments numberFormat (Intl.NumberFormat) and exponent (整数) and returns String.
解決済み表記およびexponent を考慮し、16.2.3 で述べられる表記サブパターンのString値を返す。
It performs the following steps when called:
resolvedLocaleData をnumberFormat .[[LocaleData]] とする。notationSubPatterns をresolvedLocaleData .[[notationSubPatterns]] とする。Assert : notationSubPatterns はRecord である(16.2.3 参照)。notation をnumberFormat .[[Notation]] とする。notation が"scientific" またはnotation が"engineering" ならば、notationSubPatterns .[[scientific]] を返す。そうでなく、exponent が0でないならば、Assert : notation は"compact" である。compactDisplay をnumberFormat .[[CompactDisplay]] とする。compactPatterns をnotationSubPatterns .[[compact]] .[[<compactDisplay >]]とする。compactPatterns .[[<exponent >]]を返す。 そうでなければ、"{number}" を返す。
16.5.13 ComputeExponent ( numberFormat , x )
The abstract operation ComputeExponent takes arguments numberFormat (Intl.NumberFormat) and x (数学的値) and returns 整数.
数値整形設定に従ってx をスケーリングする指数(10の累乗)を計算する。
999が1000に丸め上げられ、異なる指数が必要になるような場合を処理する。
It performs the following steps when called:
x = 0 なら、0 を返す。 x < 0 なら、x = -x とする。magnitude を floor (log10 (x )) とする。exponent を ComputeExponentForMagnitude (numberFormat , magnitude ) とする。x を x × 10-exponent に設定する。formatNumberResult を FormatNumericToString (numberFormat , x ) とする。formatNumberResult .[[RoundedNumber]] = 0 なら、exponent を返す。newMagnitude を floor (log10 (formatNumberResult .[[RoundedNumber]] )) とする。newMagnitude が magnitude - exponent なら、exponent を返す。ComputeExponentForMagnitude (numberFormat , magnitude + 1) を返す。
16.5.14 ComputeExponentForMagnitude ( numberFormat , magnitude )
The abstract operation ComputeExponentForMagnitude takes arguments numberFormat (Intl.NumberFormat) and magnitude (整数) and returns 整数.
ロケールおよび望ましい表記(scientific、engineering、またはcompact)に従って、所与の桁規模(最上位桁の10の累乗)の数値をスケーリングする指数を計算する。
It performs the following steps when called:
notation をnumberFormat .[[Notation]] とする。notation が"standard" ならば、0を返す。 そうでなく、notation が"scientific" ならば、magnitude を返す。 そうでなく、notation が"engineering" ならば、thousands をmagnitude / 3以下である最大の整数とする。thousands × 3を返す。 そうでなければ、Assert : notation は"compact" である。exponent を、現在のロケールに対するcompact notationにおいて所与の桁規模の数値をスケーリングするILD 整数とする。exponent を返す。
16.5.15 Runtime Semantics: StringIntlMV
The syntax-directed operation StringIntlMV takes no arguments.
Note
It is defined piecewise over the following productions:
StringNumericLiteral ::: StrWhiteSpace opt
0を返す。
StringNumericLiteral :::
StrWhiteSpace opt
StrNumericLiteral
StrWhiteSpace opt
StrNumericLiteral のStringIntlMV を返す。
StrNumericLiteral ::: NonDecimalIntegerLiteral
NonDecimalIntegerLiteral のMVを返す。
StrDecimalLiteral :::
-
StrUnsignedDecimalLiteral
a をStrUnsignedDecimalLiteral のStringIntlMV とする。a が0ならば、negative-zero を返す。a がpositive-infinity ならば、negative-infinity を返す。-a を返す。
StrUnsignedDecimalLiteral ::: Infinity
positive-infinity を返す。
StrUnsignedDecimalLiteral :::
DecimalDigits
.
DecimalDigits opt
ExponentPart opt
a を最初のDecimalDigits のMVとする。2番目のDecimalDigits が存在するならば、b を2番目のDecimalDigits のMVとする。n を2番目のDecimalDigits 内のコードポイント数とする。 そうでなければ、b を0とする。n を0とする。 ExponentPart が存在するならばe をExponentPart のMVとする。そうでなければe を0とする。(a + (b × 10-n )) × 10e を返す。
StrUnsignedDecimalLiteral :::
.
DecimalDigits
ExponentPart opt
b をDecimalDigits のMVとする。ExponentPart が存在するならばe をExponentPart のMVとする。そうでなければe を0とする。n をDecimalDigits 内のコードポイント数とする。b × 10e - n を返す。
StrUnsignedDecimalLiteral :::
DecimalDigits
ExponentPart opt
a をDecimalDigits のMVとする。ExponentPart が存在するならばe をExponentPart のMVとする。そうでなければe を0とする。a × 10e を返す。
16.5.16 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:
primValue を? ToPrimitive (value , number )とする。primValue がBigIntならば、ℝ (primValue )を返す。primValue がStringならば、str をprimValue とする。そうでなければ、x を? ToNumber (primValue )とする。x が-0 𝔽 ならば、negative-zero を返す。str をNumber::toString (x , 10)とする。 text をStringToCodePoints (str )とする。literal をParseText (text , StringNumericLiteral )とする。literal がエラーのList ならば、not-a-number を返す。intlMV をliteral のStringIntlMV とする。intlMV が数学的値ならば、rounded をRoundMVResult (abs (intlMV ))とする。rounded が+∞ 𝔽 であり、かつintlMV < 0ならば、negative-infinity を返す。rounded が+∞ 𝔽 ならば、positive-infinity を返す。rounded が+0 𝔽 であり、かつintlMV < 0ならば、negative-zero を返す。rounded が+0 𝔽 ならば、0を返す。intlMV を返す。
16.5.17 GetUnsignedRoundingMode ( roundingMode , sign )
The abstract operation GetUnsignedRoundingMode takes arguments roundingMode (rounding mode ) and sign (negative またはpositive ) and returns Table 31 のUnsigned Rounding Mode列からの仕様型. roundingMode が数値の符号付き値に適用された場合と同じ結果を生成するために、数値の絶対値に適用されるべきrounding mode を返す(sign がnegative ならば負、それ以外ならば正)。 It performs the following steps when called:
Identifier列の値がroundingMode であり、Sign列の値がsign である行について、Table 31 のUnsigned Rounding Mode列にある仕様型を返す。
Table 31: rounding mode からunsigned rounding mode への変換
識別子
符号
Unsigned Rounding Mode
"ceil"
positive
infinity
negative
zero
"floor"
positive
zero
negative
infinity
"expand"
positive
infinity
negative
infinity
"trunc"
positive
zero
negative
zero
"halfCeil"
positive
half-infinity
negative
half-zero
"halfFloor"
positive
half-zero
negative
half-infinity
"halfExpand"
positive
half-infinity
negative
half-infinity
"halfTrunc"
positive
half-zero
negative
half-zero
"halfEven"
positive
half-even
negative
half-even
16.5.18 ApplyUnsignedRoundingMode ( x , r1 , r2 , unsignedRoundingMode )
The abstract operation ApplyUnsignedRoundingMode takes arguments x (数学的値), r1 (数学的値), r2 (数学的値), and unsignedRoundingMode (Table 31 のUnsigned Rounding Mode列からの仕様型、またはundefined ) and returns 数学的値. 下側をr1 、上側をr2 で挟まれたx を考慮し、unsignedRoundingMode に従ってr1 またはr2 のいずれかを返す。 It performs the following steps when called:
x がr1 ならば、r1 を返す。Assert : r1 < x < r2 である。Assert : unsignedRoundingMode はundefined でない。unsignedRoundingMode がzero ならば、r1 を返す。unsignedRoundingMode がinfinity ならば、r2 を返す。d1 をx – r1 とする。d2 をr2 – x とする。d1 < d2 ならば、r1 を返す。d2 < d1 ならば、r2 を返す。Assert : d1 はd2 である。unsignedRoundingMode がhalf-zero ならば、r1 を返す。unsignedRoundingMode がhalf-infinity ならば、r2 を返す。Assert : unsignedRoundingMode はhalf-even である。cardinality を(r1 / (r2 – r1 )) modulo 2 とする。cardinality が0ならば、r1 を返す。r2 を返す。
16.5.19 PartitionNumberRangePattern ( numberFormat , x , y )
The abstract operation PartitionNumberRangePattern takes arguments numberFormat (Intl.NumberFormat), x (Intl数学的値 ), and y (Intl数学的値 ) and returns フィールド[[Type]] (String)、[[Value]] (String)、および[[Source]] (String)を持つRecord のList を含む通常完了、またはthrow完了. x 、y 、およびnumberFormat の整形オプションに従って、ローカライズされた数値範囲の部分を作成する。 It performs the following steps when called:
x がnot-a-number またはy がnot-a-number ならば、RangeError 例外を投げる。xResult をPartitionNumberPattern (numberFormat , x )とする。yResult をPartitionNumberPattern (numberFormat , y )とする。FormatNumeric (numberFormat , x )がFormatNumeric (numberFormat , y )ならば、approximateResult をFormatApproximately (numberFormat , xResult )とする。approximateResult の各要素part について、次を行う:part .[[Source]] を"shared" に設定する。approximateResult を返す。result を新しい空のList とする。xResult の各要素part について、次を行う:Record { [[Type]] : part .[[Type]] , [[Value]] : part .[[Value]] , [[Source]] : "startRange" }をresult に追加する。rangeSeparator を、2つの数値を区切るために使用されるILND String値とする。Record { [[Type]] : "literal" , [[Value]] : rangeSeparator , [[Source]] : "shared" }をresult に追加する。yResult の各要素part について、次を行う:Record { [[Type]] : part .[[Type]] , [[Value]] : part .[[Value]] , [[Source]] : "endRange" }をresult に追加する。CollapseNumberRange (numberFormat , result )を返す。
16.5.20 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:
approximatelySign を、数値が概数であることを示すために使用されるILND String値とする。approximatelySign が空でないならば、Record { [[Type]] : "approximatelySign" , [[Value]] : approximatelySign }をresult 内のILND インデックスに挿入する。例えば、numberFormat が[[Locale]] "en-US" 、[[NumberingSystem]] "latn" 、および[[Style]] "decimal" を持つ場合、新しいRecord はresult の最初の要素の前に挿入されることがある。result を返す。
16.5.21 CollapseNumberRange ( numberFormat , result )
The implementation-defined abstract operation CollapseNumberRange takes arguments numberFormat (Intl.NumberFormat) and result (フィールド[[Type]] (String)、[[Value]] (String)、および[[Source]] (String)を持つ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.22 FormatNumericRange ( numberFormat , x , y )
The abstract operation FormatNumericRange takes arguments numberFormat (Intl.NumberFormat), x (Intl数学的値 ), and y (Intl数学的値 ) and returns Stringを含む通常完了またはthrow完了. It performs the following steps when called:
parts を? PartitionNumberRangePattern (numberFormat , x , y )とする。result を空のStringとする。parts の各要素part について、次を行う:result をresult とpart .[[Value]] の文字列連結に設定する。result を返す。
16.5.23 FormatNumericRangeToParts ( numberFormat , x , y )
The abstract operation FormatNumericRangeToParts takes arguments numberFormat (Intl.NumberFormat), x (Intl数学的値 ), and y (Intl数学的値 ) and returns Arrayを含む通常完了またはthrow完了. It performs the following steps when called:
parts を? PartitionNumberRangePattern (numberFormat , x , y )とする。result を! ArrayCreate (0)とする。n を0とする。parts の各要素part について、次を行う:partObj をOrdinaryObjectCreate (%Object.prototype% )とする。! CreateDataPropertyOrThrow (partObj , "type" , part .[[Type]] )を実行する。 ! CreateDataPropertyOrThrow (partObj , "value" , part .[[Value]] )を実行する。 ! CreateDataPropertyOrThrow (partObj , "source" , part .[[Source]] )を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), partObj )を実行する。 n を n + 1 に設定する。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 とともに呼び出されるとき、次の手順が実行される:
NewTargetがundefined ならば、TypeError 例外を投げる。 pluralRules を? OrdinaryCreateFromConstructor (NewTarget, "%Intl.PluralRules.prototype%" , « [[InitializedPluralRules]] , [[Locale]] , [[Type]] , [[Notation]] , [[CompactDisplay]] , [[MinimumIntegerDigits]] , [[MinimumFractionDigits]] , [[MaximumFractionDigits]] , [[MinimumSignificantDigits]] , [[MaximumSignificantDigits]] , [[RoundingType]] , [[RoundingIncrement]] , [[RoundingMode]] , [[ComputedRoundingPriority]] , [[TrailingZeroDisplay]] »)とする。optionsResolution を? ResolveOptions (%Intl.PluralRules% , %Intl.PluralRules% .[[LocaleData]] , locales , options , « coerce-options »)とする。options をoptionsResolution .[[Options]] に設定する。resolvedLocale をoptionsResolution .[[ResolvedLocale]] とする。pluralRules .[[Locale]] をresolvedLocale .[[Locale]] に設定する。type を? GetOption (options , "type" , string , « "cardinal" , "ordinal" », "cardinal" )とする。pluralRules .[[Type]] をtype に設定する。notation を? GetOption (options , "notation" , string , « "standard" , "scientific" , "engineering" , "compact" », "standard" )とする。pluralRules .[[Notation]] をnotation に設定する。compactDisplay を? GetOption (options , "compactDisplay" , string , « "short" , "long" », "short" )とする。notation が"compact" ならば、pluralRules .[[CompactDisplay]] をcompactDisplay に設定する。? SetNumberFormatDigitOptions (pluralRules , options , 0, 3, notation )を実行する。 pluralRules を返す。
17.2 Intl.PluralRulesコンストラクタのプロパティ
Intl.PluralRulesコンストラクタは、次のとおりである:
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 とともに呼び出されるとき、次の手順が実行される:
availableLocales を%Intl.PluralRules% .[[AvailableLocales]] とする。requestedLocales を? CanonicalizeLocaleList (locales )とする。? FilterLocales (availableLocales , requestedLocales , options )を返す。
17.2.3 内部スロット
[[AvailableLocales]] 内部スロットの値は、9.1 で述べられた制約の範囲内で実装定義である。
[[RelevantExtensionKeys]] 内部スロットの値は« »である。
[[ResolutionOptionDescriptors]] 内部スロットの値は« »である。
Note 1
[[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 ( )
この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。
pr をthis 値とする。? RequireInternalSlot (pr , [[InitializedPluralRules]] )を実行する。 options をOrdinaryObjectCreate (%Object.prototype% )とする。pluralCategories を、選択されたロケールpr .[[Locale]] についてPluralRuleSelect のすべての可能な結果を含み、次の順序:"zero" 、"one" 、"two" 、"few" 、"many" 、"other" に従ってソートされたStringのList とする。Table 32 の各行(ヘッダ行を除く)について、表の順序で、次を行う:propertyKey を現在の行のProperty値とする。propertyKey が"pluralCategories" ならば、value をCreateArrayFromList (pluralCategories )とする。そうでなければ、value を、その名前が現在の行のInternal Slot値であるpr の内部スロットの値とする。 value がundefined でないならば、現在の行にConversion値があるならば、Assert : 現在の行のConversion値はnumber である。value を𝔽 (value )に設定する。 ! CreateDataPropertyOrThrow (options , propertyKey , value )を実行する。 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 とともに呼び出されるとき、次の手順が実行される:
pr をthis 値とする。? RequireInternalSlot (pr , [[InitializedPluralRules]] )を実行する。 n を? ToIntlMathematicalValue (value )とする。ResolvePlural (pr , n ).[[PluralCategory]] を返す。
17.3.4 Intl.PluralRules.prototype.selectRange ( start , end )
selectRangeメソッドが引数start およびend とともに呼び出されるとき、次の手順が実行される:
pr をthis 値とする。? RequireInternalSlot (pr , [[InitializedPluralRules]] )を実行する。 start がundefined またはend がundefined ならば、TypeError 例外を投げる。x を? ToIntlMathematicalValue (start )とする。y を? ToIntlMathematicalValue (end )とする。? 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:
n がnot-a-number ならば、formattedString をNaN 値を示すILD String値とする。Record { [[PluralCategory]] : "other" , [[FormattedString]] : formattedString }を返す。n がpositive-infinity ならば、formattedString を正の無限大を示すILD String値とする。Record { [[PluralCategory]] : "other" , [[FormattedString]] : formattedString }を返す。n がnegative-infinity ならば、formattedString を負の無限大を示すILD String値とする。Record { [[PluralCategory]] : "other" , [[FormattedString]] : formattedString }を返す。res をFormatNumericToString (pluralRules , n )とする。formattedString をres .[[FormattedString]] とする。locale をpluralRules .[[Locale]] とする。type をpluralRules .[[Type]] とする。notation をpluralRules .[[Notation]] とする。compactDisplay をpluralRules .[[CompactDisplay]] とする。pluralCategory をPluralRuleSelect (locale , type , notation , compactDisplay , formattedString )とする。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:
x がnot-a-number またはy がnot-a-number ならば、RangeError 例外を投げる。xResult をResolvePlural (pluralRules , x )とする。yResult をResolvePlural (pluralRules , y )とする。xResult .[[FormattedString]] がyResult .[[FormattedString]] ならば、xResult .[[PluralCategory]] を返す。locale をpluralRules .[[Locale]] とする。type をpluralRules .[[Type]] とする。notation をpluralRules .[[Notation]] とする。compactDisplay をpluralRules .[[CompactDisplay]] とする。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 とともに呼び出されたとき、次の手順が実行される:
NewTarget が undefined なら、TypeError 例外を投げる。 relativeTimeFormat を ? OrdinaryCreateFromConstructor (NewTarget, "%Intl.RelativeTimeFormat.prototype%" , « [[InitializedRelativeTimeFormat]] , [[Locale]] , [[LocaleData]] , [[Style]] , [[Numeric]] , [[NumberFormat]] , [[NumberingSystem]] , [[PluralRules]] ») とする。optionsResolution を ? ResolveOptions (%Intl.RelativeTimeFormat% , %Intl.RelativeTimeFormat% .[[LocaleData]] , locales , options , « coerce-options ») とする。options を optionsResolution .[[Options]] に設定する。resolvedLocale を optionsResolution .[[ResolvedLocale]] とする。locale を resolvedLocale .[[Locale]] とする。relativeTimeFormat .[[Locale]] を locale に設定する。relativeTimeFormat .[[LocaleData]] を resolvedLocale .[[LocaleData]] に設定する。relativeTimeFormat .[[NumberingSystem]] を resolvedLocale .[[nu]] に設定する。style を ? GetOption (options , "style" , string , « "long" , "short" , "narrow" », "long" ) とする。relativeTimeFormat .[[Style]] を style に設定する。numeric を ? GetOption (options , "numeric" , string , « "always" , "auto" », "always" ) とする。relativeTimeFormat .[[Numeric]] を numeric に設定する。nfOptions を OrdinaryObjectCreate (null ) とする。! CreateDataPropertyOrThrow (nfOptions , "numberingSystem" , relativeTimeFormat .[[NumberingSystem]] ) を実行する。 relativeTimeFormat .[[NumberFormat]] を ! Construct (%Intl.NumberFormat% , « locale , nfOptions ») とする。relativeTimeFormat .[[PluralRules]] を ! Construct (%Intl.PluralRules% , « locale ») とする。relativeTimeFormat を返す。
18.2 Intl.RelativeTimeFormat コンストラクターのプロパティ
Intl.RelativeTimeFormat コンストラクターは次の通りである:
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 とともに呼び出されたとき、次の手順が実行される:
availableLocales を %Intl.RelativeTimeFormat% .[[AvailableLocales]] とする。requestedLocales を ? CanonicalizeLocaleList (locales ) とする。? FilterLocales (availableLocales , requestedLocales , options ) を返す。
18.2.3 内部スロット
[[AvailableLocales]] 内部スロットの値は、9.1 で記述される制約内で実装定義である。
[[RelevantExtensionKeys]] 内部スロットの値は « "nu" » である。
[[ResolutionOptionDescriptors]] 内部スロットの値は « { [[Key]] : "nu" , [[Property]] : "numberingSystem" } » である。
Note 1
[[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 ( )
この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。
relativeTimeFormat を this 値とする。? RequireInternalSlot (relativeTimeFormat , [[InitializedRelativeTimeFormat]] ) を実行する。 options を OrdinaryObjectCreate (%Object.prototype% ) とする。Table 33 の各行について、ヘッダー行を除き、表の順序で、次を行う。propertyKey を現在の行の Property 値とする。value を、現在の行の Internal Slot 値を名前とする relativeTimeFormat の内部スロットの値とする。Assert : value は undefined でない。! CreateDataPropertyOrThrow (options , propertyKey , value ) を実行する。 options を返す。
Table 33: RelativeTimeFormat インスタンスの解決済みオプション
内部スロット
プロパティ
[[Locale]]
"locale"
[[Style]]
"style"
[[Numeric]]
"numeric"
[[NumberingSystem]]
"numberingSystem"
18.3.3 Intl.RelativeTimeFormat.prototype.format ( value , unit )
format メソッドが引数 value および unit とともに呼び出されたとき、次の手順が実行される:
relativeTimeFormat を this 値とする。? RequireInternalSlot (relativeTimeFormat , [[InitializedRelativeTimeFormat]] ) を実行する。 value を ? ToNumber (value ) に設定する。unit を ? ToString (unit ) に設定する。? FormatRelativeTime (relativeTimeFormat , value , unit ) を返す。
18.3.4 Intl.RelativeTimeFormat.prototype.formatToParts ( value , unit )
formatToParts メソッドが引数 value および unit とともに呼び出されたとき、次の手順が実行される:
relativeTimeFormat を this 値とする。? RequireInternalSlot (relativeTimeFormat , [[InitializedRelativeTimeFormat]] ) を実行する。 value を ? ToNumber (value ) に設定する。unit を ? ToString (unit ) に設定する。? 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:
unit が "seconds" なら、"second" を返す。unit が "minutes" なら、"minute" を返す。unit が "hours" なら、"hour" を返す。unit が "days" なら、"day" を返す。unit が "weeks" なら、"week" を返す。unit が "months" なら、"month" を返す。unit が "quarters" なら、"quarter" を返す。unit が "years" なら、"year" を返す。unit が "second" 、"minute" 、"hour" 、"day" 、"week" 、"month" 、"quarter" 、または "year" のいずれでもないなら、RangeError 例外を投げる。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:
value が NaN 、+∞ 𝔽 、または -∞ 𝔽 なら、RangeError 例外を投げる。unit を ? SingularRelativeTimeUnit (unit ) に設定する。fields を relativeTimeFormat .[[LocaleData]] とする。patterns を fields .[[<unit >]] とする。style を relativeTimeFormat .[[Style]] とする。style が "short" または "narrow" なら、key を unit 、"-" 、および style の文字列連結とする。fields がフィールド [[<key >]] を持つなら、patterns を fields .[[<key >]] に設定する。relativeTimeFormat .[[Numeric]] が "auto" なら、valueString を ! ToString (value ) とする。patterns がフィールド [[<valueString >]] を持つなら、result を patterns .[[<valueString >]] とする。Record { [[Type]] : "literal" , [[Value]] : result , [[Unit]] : empty } を含む List を返す。value が -0 𝔽 または value < -0 𝔽 なら、tense を "past" とする。そうでなければ、tense を "future" とする。 tensePatterns を patterns .[[<tense >]] とする。formattedValue を PartitionNumberPattern (relativeTimeFormat .[[NumberFormat]] , ℝ (value )) とする。pluralCategory を ResolvePlural (relativeTimeFormat .[[PluralRules]] , value ).[[PluralCategory]] とする。pattern を tensePatterns .[[<pluralCategory >]] とする。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:
patternParts を PartitionPattern (pattern ) とする。result を新しい空の List とする。patternParts の各 Record { [[Type]] , [[Value]] } patternPart について、次を行う。patternPart .[[Type]] が "literal" なら、Record { [[Type]] : "literal" , [[Value]] : patternPart .[[Value]] , [[Unit]] : empty } を result に追加する。そうでなければ、Assert : patternPart .[[Type]] は "0" である。parts の各 Record { [[Type]] , [[Value]] } part について、次を行う。Record { [[Type]] : part .[[Type]] , [[Value]] : part .[[Value]] , [[Unit]] : unit } を result に追加する。 result を返す。
Note
例:
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:
parts を ? PartitionRelativeTimePattern (relativeTimeFormat , value , unit ) とする。result を空の String とする。parts の各 Record { [[Type]] , [[Value]] , [[Unit]] } part について、次を行う。result を result と part .[[Value]] の文字列連結に設定する。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:
parts を ? PartitionRelativeTimePattern (relativeTimeFormat , value , unit ) とする。result を ! ArrayCreate (0) とする。n を 0 とする。parts の各 Record { [[Type]] , [[Value]] , [[Unit]] } part について、次を行う。partObj を OrdinaryObjectCreate (%Object.prototype% ) とする。! CreateDataPropertyOrThrow (partObj , "type" , part .[[Type]] ) を実行する。 ! CreateDataPropertyOrThrow (partObj , "value" , part .[[Value]] ) を実行する。 part .[[Unit]] が empty でないなら、! CreateDataPropertyOrThrow (partObj , "unit" , part .[[Unit]] ) を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), partObj ) を実行する。 n を n + 1 に設定する。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 とともに呼び出されたとき、次の手順が実行される:
NewTarget が undefined なら、TypeError 例外を投げる。 internalSlotsList を « [[InitializedSegmenter]] , [[Locale]] , [[SegmenterGranularity]] » とする。segmenter を ? OrdinaryCreateFromConstructor (NewTarget, "%Intl.Segmenter.prototype%" , internalSlotsList ) とする。optionsResolution を ? ResolveOptions (%Intl.Segmenter% , %Intl.Segmenter% .[[LocaleData]] , locales , options ) とする。options を optionsResolution .[[Options]] に設定する。resolvedLocale を optionsResolution .[[ResolvedLocale]] とする。segmenter .[[Locale]] を resolvedLocale .[[Locale]] に設定する。granularity を ? GetOption (options , "granularity" , string , « "grapheme" , "word" , "sentence" », "grapheme" ) とする。segmenter .[[SegmenterGranularity]] を granularity に設定する。segmenter を返す。
19.2 Intl.Segmenter コンストラクターのプロパティ
Intl.Segmenter コンストラクターは次の通りである:
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 とともに呼び出されたとき、次の手順が実行される:
availableLocales を %Intl.Segmenter% .[[AvailableLocales]] とする。requestedLocales を ? CanonicalizeLocaleList (locales ) とする。? 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 ( )
この関数は、オブジェクトの初期化中に計算されたロケールおよびオプションへのアクセスを提供する。
segmenter を this 値とする。? RequireInternalSlot (segmenter , [[InitializedSegmenter]] ) を実行する。 options を OrdinaryObjectCreate (%Object.prototype% ) とする。Table 34 の各行について、ヘッダー行を除き、表の順序で、次を行う。propertyKey を現在の行の Property 値とする。value を、現在の行の Internal Slot 値を名前とする segmenter の内部スロットの値とする。Assert : value は undefined でない。! CreateDataPropertyOrThrow (options , propertyKey , value ) を実行する。 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 インスタンス を作成する。次の手順が実行される:
segmenter を this 値とする。? RequireInternalSlot (segmenter , [[InitializedSegmenter]] ) を実行する。 string を ? ToString (string ) に設定する。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:
internalSlotsList を « [[SegmentsSegmenter]] , [[SegmentsString]] » とする。segments を OrdinaryObjectCreate (%IntlSegmentsPrototype% , internalSlotsList ) とする。segments .[[SegmentsSegmenter]] を segmenter に設定する。segments .[[SegmentsString]] を string に設定する。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 オブジェクト を返す。次の手順が実行される:
segments を this 値とする。? RequireInternalSlot (segments , [[SegmentsSegmenter]] ) を実行する。 segmenter を segments .[[SegmentsSegmenter]] とする。string を segments .[[SegmentsString]] とする。length を string の長さとする。n を ? ToIntegerOrInfinity (index ) とする。n < 0 または n ≥ length なら、undefined を返す。startIndex を FindBoundary (segmenter , string , n , before ) とする。endIndex を FindBoundary (segmenter , string , n , after ) とする。CreateSegmentDataObject (segmenter , string , startIndex , endIndex ) を返す。
19.5.2.2 %IntlSegmentsPrototype% [ %Symbol.iterator% ] ( )
%Symbol.iterator% メソッドは、Segments インスタンス 上で呼び出され、その構築元の Intl.Segmenter インスタンスのロケールおよびオプションを使用して、その文字列上の Segment Iterator を作成する。次の手順が実行される:
segments を this 値とする。? RequireInternalSlot (segments , [[SegmentsSegmenter]] ) を実行する。 segmenter を segments .[[SegmentsSegmenter]] とする。string を segments .[[SegmentsString]] とする。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:
internalSlotsList を « [[IteratingSegmenter]] , [[IteratedString]] , [[IteratedStringNextSegmentCodeUnitIndex]] » とする。iterator を OrdinaryObjectCreate (%IntlSegmentIteratorPrototype% , internalSlotsList ) とする。iterator .[[IteratingSegmenter]] を segmenter に設定する。iterator .[[IteratedString]] を string に設定する。iterator .[[IteratedStringNextSegmentCodeUnitIndex]] を 0 に設定する。iterator を返す。
19.6.2 %IntlSegmentIteratorPrototype% オブジェクト
%IntlSegmentIteratorPrototype% オブジェクトは次の通りである:
19.6.2.1 %IntlSegmentIteratorPrototype%.next ( )
next メソッドは、Segment Iterator インスタンス上で呼び出され、それを 1 セグメント分前進させ、新しいセグメントを記述するか反復の完了を宣言する IteratorResult オブジェクトを返す。次の手順が実行される:
iterator を this 値とする。? RequireInternalSlot (iterator , [[IteratingSegmenter]] ) を実行する。 segmenter を iterator .[[IteratingSegmenter]] とする。string を iterator .[[IteratedString]] とする。startIndex を iterator .[[IteratedStringNextSegmentCodeUnitIndex]] とする。length を string の長さとする。startIndex ≥ length なら、CreateIteratorResultObject (undefined , true ) を返す。endIndex を FindBoundary (segmenter , string , startIndex , after ) とする。iterator .[[IteratedStringNextSegmentCodeUnitIndex]] を endIndex に設定する。segmentData を CreateSegmentDataObject (segmenter , string , startIndex , endIndex ) とする。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:
length を string の長さとする。Assert : endIndex ≤ length である。Assert : startIndex < endIndex である。result を OrdinaryObjectCreate (%Object.prototype% ) とする。segment を string の startIndex から endIndex までの部分文字列とする。! CreateDataPropertyOrThrow (result , "segment" , segment ) を実行する。 ! CreateDataPropertyOrThrow (result , "index" , 𝔽 (startIndex )) を実行する。 ! CreateDataPropertyOrThrow (result , "input" , string ) を実行する。 granularity を segmenter .[[SegmenterGranularity]] とする。granularity が "word" なら、isWordLike を、string 内の segment がロケール segmenter .[[Locale]] に従って「word-like」であるかどうかを示す Boolean とする。! CreateDataPropertyOrThrow (result , "isWordLike" , isWordLike ) を実行する。 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:
length を string の長さとする。Assert : startIndex < length である。locale を segmenter .[[Locale]] とする。granularity を segmenter .[[SegmenterGranularity]] とする。direction が before なら、ロケール locale およびテキスト要素粒度 granularity を使用して、先頭から最大で startIndex 個のコード単位が前にある最後のセグメンテーション境界を string 内で検索する。 境界が見つかったなら、その前にある string 内のコード単位数を返す。 0 を返す。 Assert : direction は after である。ロケール locale およびテキスト要素粒度 granularity を使用して、インデックス startIndex にあるコード単位の後に続く最初のセグメンテーション境界を string 内で検索する。 境界が見つかったなら、その前にある string 内のコード単位数を返す。 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 とともに呼び出されるとき、次の手順が実行される:
thisValue を? RequireObjectCoercible (this value)とする。string を? ToString (thisValue )とする。thatValue を? ToString (that )とする。collator を? Construct (%Intl.Collator% , « locales , options »)とする。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値をコードポイントの列として解釈する。次の手順が実行される:
thisValue を? RequireObjectCoercible (this value)とする。string を? ToString (thisValue )とする。? 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:
requestedLocales を? CanonicalizeLocaleList (locales )とする。requestedLocales が空のList でないならば、requestedLocale をrequestedLocales [0]とする。そうでなければ、requestedLocale をDefaultLocale ()とする。 availableLocales を、Unicode Character Databaseが言語依存のケースマッピングを含む言語タグ を含むAvailable Locales List とする。実装が追加のロケール依存ケースマッピングをサポートする場合、availableLocales はそれらに対応する言語タグ も含むべきである。match をLookupMatchingLocaleByPrefix (availableLocales , « requestedLocale »)とする。match がundefined でないならばlocale をmatch .[[locale]] とし、そうでなければlocale を"und" とする。codePoints をStringToCodePoints (string )とする。targetCase がlower ならば、newCodePoints を、locale を使用する実装由来のアルゴリズムまたはUnicode Default Case Conversionアルゴリズムに従ったcodePoints の小文字変換の結果を要素とするList とする。そうでなければ、Assert : targetCase はupper である。newCodePoints を、locale を使用する実装由来のアルゴリズムまたはUnicode Default Case Conversionアルゴリズムに従ったcodePoints の大文字変換の結果を要素とするList とする。 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値をコードポイントの列として解釈する。次の手順が実行される:
thisValue を? RequireObjectCoercible (this value)とする。string を? ToString (thisValue )とする。? 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 とともに呼び出されるとき、次の手順が実行される:
x を? ThisNumberValue (this value)とする。numberFormat を? Construct (%Intl.NumberFormat% , « locales , options »)とする。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 とともに呼び出されるとき、次の手順が実行される:
x を? ThisBigIntValue (this value)とする。numberFormat を? Construct (%Intl.NumberFormat% , « locales , options »)とする。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 とともに呼び出されるとき、次の手順が実行される:
dateObj をthis 値とする。? RequireInternalSlot (dateObj , [[DateValue]] )を実行する。 x をdateObj .[[DateValue]] とする。x がNaN ならば、"Invalid Date" を返す。dateFormat を? CreateDateTimeFormat (%Intl.DateTimeFormat% , locales , options , any , all )とする。! FormatDateTime (dateFormat , x )を返す。
20.4.2 Date.prototype.toLocaleDateString ( [ locales [ , options ] ] )
この定義は、Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] ) で提供される定義を置き換える。
toLocaleDateStringメソッドが省略可能な引数locales およびoptions とともに呼び出されるとき、次の手順が実行される:
dateObj をthis 値とする。? RequireInternalSlot (dateObj , [[DateValue]] )を実行する。 x をdateObj .[[DateValue]] とする。x がNaN ならば、"Invalid Date" を返す。dateFormat を? CreateDateTimeFormat (%Intl.DateTimeFormat% , locales , options , date , date )とする。! FormatDateTime (dateFormat , x )を返す。
20.4.3 Date.prototype.toLocaleTimeString ( [ locales [ , options ] ] )
この定義は、Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] ) で提供される定義を置き換える。
toLocaleTimeStringメソッドが省略可能な引数locales およびoptions とともに呼び出されるとき、次の手順が実行される:
dateObj をthis 値とする。? RequireInternalSlot (dateObj , [[DateValue]] )を実行する。 x をdateObj .[[DateValue]] とする。x がNaN ならば、"Invalid Date" を返す。timeFormat を? CreateDateTimeFormat (%Intl.DateTimeFormat% , locales , options , time , time )とする。! FormatDateTime (timeFormat , x )を返す。
20.5 Arrayプロトタイプオブジェクトのプロパティ
20.5.1 Array.prototype.toLocaleString ( [ locales [ , options ] ] )
この定義は、Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) で提供される定義を置き換える。
toLocaleStringメソッドが省略可能な引数locales およびoptions とともに呼び出されるとき、次の手順が実行される:
array を? ToObject (this value)とする。length を? LengthOfArrayLike (array )とする。separator を、ホスト環境の現在のロケールに適した実装定義のリスト区切り文字String値(例えば", " )とする。result を空のStringとする。k を0とする。k < length である間、繰り返す:k > 0ならば、result をresult とseparator の文字列連結に設定する。element を? Get (array , ! ToString (𝔽 (k )))とする。element がundefined でもnull でもないならば、elementString を? ToString (? Invoke (element , "toLocaleString" , « locales , options »))とする。result をresult とelementString の文字列連結に設定する。k をk + 1に設定する。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) 実装依存の動作
この仕様書の以下の側面は実装依存です:
すべての機能において:
Collator において:
Unicode 拡張キー "kf" , "kn" および対応するオプションプロパティ "caseFirst" , "numeric" のサポート (10.1.1 )
デフォルトの照合順序以外のロケールごとの "co" キー値(照合順序)のサポートセット (10.2.3 )
ロケールごとの "kf" キー値(大文字小文字順)のサポートセット (10.2.3 )
ロケールごとの "kn" キー値(数値照合)のサポートセット (10.2.3 )
ロケールごとのデフォルト検索感度 (10.2.3 )
ロケールごとのデフォルト句読点無視値 (10.2.3 )
各ロケールとオプションの組み合わせごとの並び順 (10.3.3.1 )
DateTimeFormat において:
BestFitFormatMatcher アルゴリズム (11.1.2 )
ロケールごとの "ca" キー値(カレンダー)のサポートセット (11.2.3 )
ロケールごとの "nu" キー値(数字体系)のサポートセット (11.2.3 )
ロケールごとのデフォルト hourCycle 設定 (11.2.3 )
コアセットを超えるロケールごとの日付時刻フォーマットのサポートセット、各コンポーネントの表現と関連パターンを含む (11.2.3 )
ローカライズされた曜日名、時代名、月名、日中名、午前/午後表示、タイムゾーン名 (11.5.5 )
"gregory" 以外のカレンダーの暦計算 (11.5.12 )
IANA タイムゾーンデータベースのすべての登録済み Zone および Link 名と、それらの UTC からのオフセットや夏時間規則に関する情報 (21.4.1.19 )
DisplayNames において:
DurationFormat において:
ロケールごとの "nu" キー値(数字体系)のサポートセット (13.2.3 )
ロケールごとのデジタルフォーマット構成(スタイル "numeric" の二桁時間や、数値の時間・分・秒の区切り記号の使用) (13.2.3 )
ListFormat において:
Locale において:
NumberFormat において:
ロケールごとの "nu" キー値(数字体系)のサポートセット (16.2.3 )
ロケールごとの値を小数、パーセント、通貨、単位としてフォーマットするためのパターン(符号あり/なし、通貨の会計フォーマットあり/なし、標準・コンパクト・科学記法) (16.5.6 )
通貨値をフォーマットする際に使用される小数桁数 (16.5.6 )
NaN および Infinity のローカライズされた表現 (16.5.6 )
Table 30 に記載されていない数字体系の実装 (16.5.6 )
ローカライズされた小数点およびグループ区切り記号 (16.5.6 )
ローカライズされたプラス記号とマイナス記号 (16.5.6 )
ローカライズされた数字グループ化スキーマ (16.5.6 )
コンパクト記法のローカライズされた桁数閾値 (16.5.6 )
コンパクト記法および科学記法のローカライズされた記号 (16.5.6 )
ローカライズされた狭義・短縮・長形式の通貨記号と名称 (16.5.6 )
ローカライズされた狭義・短縮・長形式の単位記号 (16.5.6 )
PluralRules において:
ロケールごとの複数形選択の可能な結果を表す文字列リストとその順序 (17.1.1 )
RelativeTimeFormat において:
ロケールごとの "nu" キー値(数字体系)のサポートセット (18.2.3 )
値をフォーマットするためのパターン (18.2.3 )
Segmenter において:
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/
Copyright Notice
COPYRIGHT NOTICE
© 2026 Ecma International
By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
This document may be copied, published and distributed to others, and certain derivative works of it may be prepared, copied, published, and distributed, in whole or in part, provided that the above copyright notice and this Copyright License and Disclaimer are included on all such copies and derivative works. The only derivative works that are permissible under this Copyright License and Disclaimer are:
(i) works which incorporate all or portion of this document for the purpose of providing commentary or explanation (such as an annotated version of the document),
(ii) works which incorporate all or portion of this document for the purpose of incorporating features that provide accessibility,
(iii) translations of this document into languages other than English and into different formats and
(iv) works by making use of this specification in standard conformant products by implementing (e.g. by copy and paste wholly or partly) the functionality therein.
However, the content of this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma International, except as required to translate it into languages other than English or into a different format.
The official version of an Ecma International document is the English language version on the Ecma International website. In the event of discrepancies between a translated version and the official version, the official version shall govern.
The limited permissions granted above are perpetual and will not be revoked by Ecma International or its successors or assigns.
This document and the information contained herein is provided on an “AS IS” basis and ECMA INTERNATIONAL DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
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:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.