Draft ECMA-402 / February 21, 2026 ECMAScript® 2026 Internationalization API Specification
イントロダクション
この仕様のソースは https://github.com/tc39/ecma402 にあります。
ECMAScript 2026 国際化 API 仕様(ECMA-402 第13版)は、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版 プロジェクトエディター
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 2026 言語仕様 (ECMA-262 第17版、または後継)。
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)と一致したり変換されたりしてはなりません。
ASCII-大文字化 とは、String値S の各ASCII小文字コードユニット(0x0061から0x007Aまで)を対応するASCII大文字コードユニット(0x0041から0x005Aまで)に置き換え、他のコードユニットはそのままにしたString値です。
ASCII-小文字化 とは、String値S の各ASCII大文字コードユニット(0x0041から0x005Aまで)を対応するASCII小文字コードユニット(0x0061から0x007Aまで)に置き換え、他のコードユニットはそのままにしたString値です。
String値A がString値B のASCII大文字・小文字を区別しない一致 であるとは、AのASCII-大文字化がBのASCII-大文字化と完全に同じコードユニット列である場合を指します。Unicodeコードポイント列A がB のASCII大文字・小文字を区別しない一致であるとは、B がCodePointsToString (A )のASCII大文字・小文字を区別しない一致である場合を指します。
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正規化ロケール識別子 」と呼ばれます。
ロケール識別子は、ASCII大文字・小文字を区別しないUnicode Basic Latin英数字サブタグ を"-" (U+002D
HYPHEN-MINUS)で区切ったものです。1文字のサブタグ は「単一サブタグ 」と呼ばれます。
Unicode Technical Standard #35 Part 1 Core, Section 3.6
Unicode BCP 47 U Extension サブタグ 列が広く使われており、「 Unicodeロケール拡張列 」は、substring がunicode_locale_extensionsUnicodeロケール非終端記号に一致し、"-x-…" プライベート使用サブタグ列 の一部でない最長のsubstring を指します。"-u-" で始まり、直後の単一サブタグでないサブタグ とその直前の"-" 区切りを含みます。例えば、"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 (a String) and returns a Boolean. locale がunicode_bcp47_locale_id の正しい形式の言語タグ であるかどうかを判定します。意味的な妥当性や、エイリアスサブタグ とその推奨置換サブタグ の区別、正規化された大文字・小文字やサブタグ 順序は考慮しません。
It performs the following steps when called:
lowerLocale をlocale のASCII-小文字化 とする。lowerLocale がunicode_locale_idUnicodeロケール非終端記号 に一致しない場合、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 の後ろのsuffix とする。注: pu_extensionsUnicodeロケール非終端記号 に一致する"-x-…" プライベート使用サブタグ 列は無視するが、末尾の孤立した"x" サブタグ は以下の判定に影響しない。 puIndex をStringIndexOf (extensions , "-x-" , 0)とする。puIndex がnot-found でない場合、extensions を0からpuIndex までの部分文字列とする。extensions が空文字列でない場合、extensions に重複する単一サブタグ が含まれていれば、false を返す。
1.
transformExtension をextensions のうちtransformed_extensionsUnicodeロケール非終端記号 に一致する最長substring とする。なければtrue を返す。アサート: transformExtension の0から3までの部分文字列は"-t-" である。 tPrefix をtransformExtension の3以降の部分文字列とする。tlang をtPrefix のうちtlangUnicodeロケール非終端記号 に一致する最長prefixとする。なければtrue を返す。tlangVariants をGetLocaleVariants (tlang )とする。tlangVariants に重複するサブタグ が含まれていれば、false を返す。true を返す。
6.2.2 CanonicalizeUnicodeLocaleId ( locale )
The abstract operation CanonicalizeUnicodeLocaleId takes argument locale (a language tag) and returns a Unicode canonicalized locale identifier. locale の正規化および大文字・小文字を正規化した形を返します。 It performs the following steps when called:
#### ECMARKDOWN PARSE FAILED #### 1. _localeId_をProcessing
LocaleIds アルゴリズムにより_locale_を正規形に変換したString値とする(Unicode Technical Standard #35 Part 1 Core,
Annex C LocaleId Canonicalization 参照)。
1. [id="step-canonicalizeunicodelocaleid-u-extension"]_localeId_にUnicodeロケール拡張列が含まれている場合、
1. _extension_を_localeId_内のUnicodeロケール拡張列のsubstring とする。
1. _newExtension_を*"-u"*とする。
1. _components_をUnicodeExtensionComponents(_extension_)とする。
1. _components_.[[Attributes]]の各要素_attr_について、
1. _newExtension_を_newExtension_、*"-"*, _attr_の連結とする。
1. _components_.[[Keywords]]の各Record { [[Key]], [[Value]] } _keyword_について、
1. _newExtension_を_newExtension_、*"-"*, _keyword_.[[Key]]の連結とする。
1. _keyword_.[[Value]]が空文字列でない場合、
1. _newExtension_を_newExtension_、*"-"*, _keyword_.[[Value]]の連結とする。
1. アサート: _newExtension_は*"-u"*ではない。
1. _localeId_の最初の_extension_出現を_newExtension_で置換したコピーを_localeId_とする。
1. _localeId_を返す。
Note
のステップは、返される
言語タグ 内の
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 (a String) and returns a Boolean. currency 引数が正しい形式の3文字ISO 4217通貨コードであるかどうかを検証します。 It performs the following steps when called:
currency の長さが3でない場合、false を返す。normalized をcurrency のASCII-大文字化 とする。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のリスト. 返されるリストはコードユニット順にソートされ、重複のない正しい形式かつ大文字の正規化済み3文字ISO
4217通貨コードを含みます。実装がIntl.DisplayNamesおよびIntl.NumberFormatオブジェクトの機能を提供する通貨を識別します。
6.5 IANAタイムゾーンデータベースの利用
本仕様を採用する実装はタイムゾーン対応でなければなりません。IANAタイムゾーンデータベースhttps://www.iana.org/time-zones/ を使用して、利用可能な名前付きタイムゾーン識別子およびECMAScriptの計算や書式設定に使用されるデータを提供しなければなりません。
このセクションは、タイムゾーン対応実装がIANAタイムゾーンデータベースをどのように使用すべきかを定義します。
Zone名またはLink名でない限り、利用可能な名前付きタイムゾーン識別子としてStringを使用してはなりません。
ECMAScript組み込みオブジェクトが返す利用可能な名前付きタイムゾーン識別子は、IANAタイムゾーンデータベースで使用されている大文字・小文字を使用しなければなりません。
IANAタイムゾーンデータベースの各Zoneは主要タイムゾーン識別子であり、各Link名は対応するZone名に解決される非主要タイムゾーン識別子でなければなりません。以下の例外はAvailableNamedTimeZoneIdentifiers で実装されます:
歴史的理由により、"UTC" は主要タイムゾーン識別子でなければなりません。
"Etc/UTC" 、"Etc/GMT" 、"GMT" 、およびそれらに解決されるすべてのLink名は非主要タイムゾーン識別子であり、"UTC" に解決されなければなりません。
IANAタイムゾーンデータベースのzone.tabファイルの「TZ」列に存在するLink名は主要タイムゾーン識別子でなければなりません。
例えば、"Europe/Prague" と"Europe/Bratislava" は両方とも主要タイムゾーン識別子でなければなりません。
この要件は、各ISO 3166-1
Alpha-2 国コードごとに少なくとも1つの主要タイムゾーン識別子を保証し、将来のタイムゾーン規則の変更が他国のタイムゾーンを使用するECMAScriptプログラムに影響しないようにします(領土境界が変更されない限り)。
zone.tabファイルの「TZ」列に記載されていないLink名で、単一のISO
3166-1 Alpha-2 国コードの領域内に完全に含まれる地理的領域を表すものは、同じ国コードの領域内に完全に含まれる主要識別子に解決されなければなりません。
例えば、"Atlantic/Jan_Mayen" は"Arctic/Longyearbyen" に解決されなければなりません。
Note
IANAタイムゾーンデータベースは、主要タイムゾーン識別子がどれかに影響するビルドオプションを提供しています。
デフォルトのビルドオプションでは異なる国のタイムゾーンが統合され、例えば"Atlantic/Reykjavik" はZone*"Africa/Abidjan"*へのLinkとして構築されます。
地理的・政治的に異なる場所は、将来のIANAタイムゾーンデータベースのバージョンで異なるタイムゾーン規則を導入する可能性が高いです。
上記の例外は、将来の互換性問題を緩和するためのものです。
Unicode Common Locale Data Repository(CLDR )は、主要・非主要タイムゾーン識別子の判定時に上記の例外のほとんどを実装しています。
一貫性のためCLDRデータの利用が推奨されますが、必須ではありません。
CLDRベースでない実装もtimezone.xml の識別子データを利用できます。
実装はIANAタイムゾーンデータベースを直接ビルドすることもでき、例えばPACKRATDATA=backzone PACKRATLIST=zone.tabなどのビルドオプションを使い、上記要件を満たすための後処理を行うことができます。
IANAタイムゾーンデータベースは通常、年間5~10回更新されます。
これらの更新では新しいZoneやLink名が追加されたり、ZoneがLinkに変更されたり、Zoneに関連するUTCオフセットや遷移が変更される場合があります。
実装はIANAタイムゾーンデータベースの更新をできるだけ早く取り込むことが推奨されます。
迅速な対応により、ECMAScriptプログラムが正確なタイムゾーン計算を行い、外部入力やホスト環境から提供される新しい名前付きタイムゾーン識別子を利用できるようになります。
IANAタイムゾーンデータベースの管理者は安定性を重視していますが、まれに(年平均1回未満)Zoneが新しいZoneに置き換えられる場合があります。
例えば2022年には"Europe/Kiev" が新しいZone*"Europe/Kyiv"*へのLinkとして非推奨となりました。
非推奨となったLinkは改名タイムゾーン識別子 、新しく追加されたZoneは置換タイムゾーン識別子 と呼ばれます。
このような稀な変更による混乱を減らすため、実装はまず置換タイムゾーン識別子を既存の改名タイムゾーン識別子に解決される非主要タイムゾーン識別子として追加すべきです。
これにより両方の識別子を認識できますが、まだ認識されていないシステムに置換タイムゾーン識別子を送信するリスクも減ります。
改名待機期間 後、実装は新しいZoneを主要タイムゾーン識別子に昇格し、同時に改名タイムゾーン識別子を非主要に降格すべきです。
他システムが更新される十分な時間を確保するため、推奨される改名待機期間 は2年です。
ただし、厳密または動的である必要はありません。
むしろ、実装はタイムゾーンデータ更新の通常のリリースプロセスの一部として、待機期間後に置換タイムゾーン識別子を主要にすべきです。
待機期間は新しいZoneが既存Zoneの置換として追加された場合のみ適用されるべきです。
既存ZoneとLinkが入れ替わった場合、改名は発生しておらず待機期間は不要です。
実装がエージェントの存続期間中にタイムゾーン情報を修正する場合、利用可能な名前付きタイムゾーン識別子のリスト、各識別子に関連付けられた主要タイムゾーン識別子、各識別子に関連付けられたUTCオフセットや遷移は、以前そのエージェントで観測された結果と一貫性がなければなりません。
この要件をサポートする複雑さから、実装は各エージェントの存続期間中に完全に一貫したIANAタイムゾーンデータベースのコピーを維持することが推奨されます。
このセクションは21.4.1.19 を補完しますが、上書きするものではありません。
6.5.1 AvailableNamedTimeZoneIdentifiers ( )
The implementation-defined abstract operation AvailableNamedTimeZoneIdentifiers takes no arguments and returns タイムゾーン識別子レコードのリスト.
この結果は、実装内のすべての利用可能な名前付きタイムゾーン識別子と、それぞれに対応する主要タイムゾーン識別子を記述します。
リストは各タイムゾーン識別子レコードの[[Identifier]] フィールド順に並べられます。
この定義は21.4.1.23 で提供される定義を上書きします。
identifiers をIANAタイムゾーンデータベース内の各ZoneまたはLink名のString値を含むリストとする。アサート: identifiers の要素同士がASCII大文字・小文字を区別しない一致 にならない。 identifiers をコードユニット順にソートする。result を新しい空リストとする。identifiers の各要素identifier について、primary をidentifier とする。identifier がIANAタイムゾーンデータベースのLink名であり、zone.tabの「TZ」列に存在しない場合、zone をIANAタイムゾーンデータベースの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 をzone.tabファイルの「country-code」列がidentifierCountryCode である行数とする。countryCodeLineCount が1の場合、countryCodeLine を「country-code」列がidentifierCountryCode であるzone.tabファイルの行とする。primary をcountryCodeLine の「TZ」列の内容とする。それ以外の場合、 backzone をundefined とする。backzoneLinkLines をbackzoneファイル内で"Link " または"#PACKRATLIST zone.tab Link " で始まる行のリストとする。backzoneLinkLines の各要素line について、i をStringIndexOf (line , "Link " , 0)とする。line をi +5以降の部分文字列とする。backzoneAndLink をline を" " で分割したリストとする。アサート: backzoneAndLink は少なくとも2要素を持ち、両方とも利用可能な名前付きタイムゾーン識別子である。 backzoneAndLink [1]がidentifier の場合、アサート: backzone はundefined である。 backzone をbackzoneAndLink [0]とする。アサート: backzone はundefined でない。 primary をbackzone とする。primary が"Etc/UTC" 、"Etc/GMT" 、"GMT" のいずれかの場合、primary を"UTC" とする。primary が置換タイムゾーン識別子 であり、その改名待機期間 が終了していない場合、renamedIdentifier をprimary が置換した改名タイムゾーン識別子 とする。primary をrenamedIdentifier とする。record をタイムゾーン識別子レコード{ [[Identifier]] : identifier , [[PrimaryIdentifier]] : primary }とする。record をresult に追加する。アサート: result にr というタイムゾーン識別子レコードが含まれ、r .[[Identifier]] が"UTC" 、r .[[PrimaryIdentifier]] も"UTC" である。 result を返す。
Note 1
上記のLinkから主要タイムゾーン識別子への解決アルゴリズムは、International Components for Unicode(ICU )のicu::TimeZone::getIanaID()や、Unicode Common Locale Data
Repository(CLDR )のタイムゾーン識別子データ管理プロセスの動作に対応することを意図しています。
このアルゴリズムは、ISO 3166-1
Alpha-2国コードの境界を越えずに、zone.tabとbackzoneファイルのデータを用いてLinkを主要タイムゾーン識別子に解決します。
国コードがzone.tabで1行のみの場合、その行の「TZ」列が主要タイムゾーン識別子となります。
国コードが複数行の場合、backzoneの履歴マッピングを用いて正しい主要タイムゾーン識別子を特定します。
例えば、デフォルトビルドオプションで"Pacific/Truk"(国コード"FM")が"Pacific/Port_Moresby"(国コード"PG")へのLinkとして識別される場合、zone.tabの「country-code」列で"FM"に対応する行を確認します。
1行のみなら、その行の「TZ」列が"Pacific/Truk"の主要タイムゾーン識別子となります。
複数行の場合、backzoneを調査し、"Link Pacific/Chuuk Pacific/Truk"のような行があれば"Pacific/Chuuk"が主要タイムゾーン識別子となります。
zone.tabはマッピングデータの優先ソースですが、backzoneのマッピングはまれにISO 3166-1 Alpha-2国コードの境界を越える場合があります。
例えば、"Atlantic/Jan_Mayen"(国コード"SJ")はbackzoneで"Europe/Oslo"(国コード"NO")にマッピングされています。
2024aリリース時点で、このケースは"Atlantic/Jan_Mayen"のみです。
Note 2
タイムゾーン識別子はIANAタイムゾーンデータベースで随時変更される可能性があります。
最低限、AvailableNamedTimeZoneIdentifiersの結果の変更は、
GetAvailableNamedTimeZoneIdentifier で許可される変更に限定することが推奨されます(エージェントの存続期間中)。
この推奨事項をサポートする複雑さから、AvailableNamedTimeZoneIdentifiers(および
GetAvailableNamedTimeZoneIdentifier )の結果はエージェントの存続期間中同一であることが推奨されます。
6.5.2 GetAvailableNamedTimeZoneIdentifier ( timeZoneIdentifier )
The abstract operation GetAvailableNamedTimeZoneIdentifier takes argument timeZoneIdentifier (a String) and returns タイムゾーン識別子レコードまたはempty .
timeZoneIdentifier が利用可能な名前付きタイムゾーン識別子の場合、AvailableNamedTimeZoneIdentifiers のリスト内のレコードのいずれかを返します。
そうでなければempty を返します。
It performs the following steps when called:
AvailableNamedTimeZoneIdentifiers ()の各record について、record .[[Identifier]] がtimeZoneIdentifier とASCII大文字・小文字を区別しない一致 の場合、record を返す。empty を返す。
Note
任意の
timeZoneIdentifier またはその
ASCII大文字・小文字を区別しない一致 値について、結果のタイムゾーン識別子レコードのフィールド値はエージェントの存続期間中同一でなければなりません。
また、タイムゾーン識別子がエージェントの存続期間中に主要から非主要へ動的に変更されてはなりません。つまり、
timeZoneIdentifier が以前のGetAvailableNamedTimeZoneIdentifierの結果の
[[PrimaryIdentifier]] フィールドと
ASCII大文字・小文字を区別しない一致 の場合、GetAvailableNamedTimeZoneIdentifier(
timeZoneIdentifier )は
[[Identifier]] が
[[PrimaryIdentifier]] であるタイムゾーン識別子レコードを返さなければなりません。
この要件をサポートする複雑さから、
AvailableNamedTimeZoneIdentifiers (およびGetAvailableNamedTimeZoneIdentifier)の結果はエージェントの存続期間中同一であることが推奨されます。
6.5.3 AvailablePrimaryTimeZoneIdentifiers ( )
The abstract operation AvailablePrimaryTimeZoneIdentifiers takes no arguments and returns Stringのリスト. 返されるリストはIANAタイムゾーンデータベースでサポートされるZoneおよびLink名のソート済みリストです。 It performs the following steps when called:
records をAvailableNamedTimeZoneIdentifiers ()とする。result を新しい空リストとする。records の各timeZoneIdentifierRecord について、timeZoneIdentifierRecord .[[Identifier]] がtimeZoneIdentifierRecord .[[PrimaryIdentifier]] と同じ場合、timeZoneIdentifierRecord .[[Identifier]] をresult に追加する。result を返す。
6.5.4 StringSplitToList ( S , separator )
The abstract operation StringSplitToList takes arguments S (a String) and separator (a String) and returns Stringのリスト.
返されるリストは、S 内でseparator を含まず、separator_の直前または直後に現れるすべての非重複部分文字列を含みます。
隣接するseparator 間、S の先頭のseparator 前、末尾のseparator 後の空文字列も含みますが、それ以外は空文字列になりません。
It performs the following steps when called:
アサート: S は空文字列でない。 アサート: separator は空文字列でない。 separatorLength をseparator の長さとする。substrings を新しい空リストとする。i を0とする。j をStringIndexOf (S , separator , 0)とする。j がnot-found でない間繰り返す:T をS のi からj までの部分文字列とする。substrings にT を追加する。i をj +separatorLength とする。j をStringIndexOf (S , separator , i )とする。T をS のi 以降の部分文字列とする。substrings にT を追加する。substrings を返す。
6.6 計量単位識別子
本仕様はUnicode Technical Standard #35
Part 2 General, Section 6.2 Unit Identifiers で定義されるコア単位識別子 (または同義のコア単位ID )を用いて計量単位を識別します。正規形はUnicode
Basic Latin小文字(U+0061 LATIN SMALL LETTER AからU+007A LATIN SMALL LETTER Z)のみを含み、必要に応じて中間ハイフン(U+002D
HYPHEN-MINUS)を含みます。
コア単位識別子の許可集合は限定されています。
許可されていないコア単位識別子を使用しようとするとRangeError となります。
6.6.1 IsWellFormedUnitIdentifier ( unitIdentifier )
The abstract operation IsWellFormedUnitIdentifier takes argument unitIdentifier (a String) and returns a Boolean. unitIdentifier 引数が、許可された単一単位または許可された単一単位の除算による複合単位として正しい形式のコア単位識別子 であるかどうかを検証します。 It performs the following steps when called:
IsSanctionedSingleUnitIdentifier (unitIdentifier )がtrue の場合、true を返す。i をStringIndexOf (unitIdentifier , "-per-" , 0)とする。i がnot-found またはStringIndexOf (unitIdentifier , "-per-" , i +1)がnot-found でない場合、false を返す。アサート: "-per-" の5文字部分文字列がunitIdentifier 内にちょうど1回、インデックスi で現れる。 numerator をunitIdentifier の0からi までの部分文字列とする。denominator をunitIdentifier のi +5以降の部分文字列とする。IsSanctionedSingleUnitIdentifier (numerator )とIsSanctionedSingleUnitIdentifier (denominator )が両方ともtrue の場合、true を返す。false を返す。
6.6.2 IsSanctionedSingleUnitIdentifier ( unitIdentifier )
The abstract operation IsSanctionedSingleUnitIdentifier takes argument unitIdentifier (a String) and returns a Boolean. unitIdentifier 引数が本仕様の現行バージョンで許可された単一単位識別子(Common Locale Data Repositoryrelease 38 unit
validity data の部分集合)に含まれるかどうかを検証します。単一単位識別子は、他の単位識別子の乗算や除算によって構成されないコア単位識別子 です(Unicode Technical Standard #35
Part 2 General, Section 6.2 Unit Identifiers 参照)。 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のリスト. 返されるリストはコードユニット順にソートされ、Table 2 の各行(ヘッダー行を除く)に記載された単一単位識別子の重複のない値で構成されます。
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のリスト.
返されるリストはコードユニット順にソートされ、重複のない正規化済み番号体系識別子 を含みます。実装がIntl.DateTimeFormat、Intl.NumberFormat、Intl.RelativeTimeFormatオブジェクトの機能を提供する番号体系を識別します。リストには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)のみを含み、必要に応じて中間ハイフン(U+002D HYPHEN-MINUS)を含みます。
6.8.1 AvailableCanonicalCollations ( )
The implementation-defined abstract operation AvailableCanonicalCollations takes no arguments and returns Stringのリスト. 返されるリストはコードユニット順にソートされ、重複のない正規化済み照合順序タイプ を含みます。実装が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)のみを含み、必要に応じて中間ハイフン(U+002D HYPHEN-MINUS)を含みます。
6.9.1 AvailableCalendars ( )
The implementation-defined abstract operation AvailableCalendars takes no arguments and returns Stringのリスト. 返されるリストはコードユニット順にソートされ、重複のない正規形(6.9 )の暦タイプ を含みます。実装がIntl.DateTimeFormatオブジェクトの機能を提供する暦を識別し、エイリアス(例:
"islamicc" と"islamic-civil" の両方またはどちらも含まない)も含みます。リストには"iso8601" を含めなければなりません。
6.10 パターン文字列タイプ
パターン文字列 は、"
{key}" 形式の部分文字列を0個以上含むString値です。keyはASCII単語文字からなる非空の任意のシーケンスです。抽象パターン文字列の構文は実装詳細であり、ECMA-402の利用者には公開されません。
7 ECMAScript 標準組み込みオブジェクトの要件
本書で特に指定されていない限り、この標準で記述されているオブジェクト、関数、コンストラクターは、ECMAScript Standard Built-in Objects に指定された標準組み込み ECMAScript オブジェクトの一般的な要件および制限の対象となります。
8 Intl オブジェクト
Intl オブジェクト :
%Intl% である。
グローバルオブジェクトの "Intl" プロパティの初期値である。
通常のオブジェクトである。
[[Prototype]] 内部スロットの値は %Object.prototype% である。
関数オブジェクトではない。
[[Construct]] 内部メソッドを持たないため、new 演算子でコンストラクタとして使用できない。
[[Call]] 内部メソッドを持たないため、関数として呼び出すことはできない。
[[FallbackSymbol]] 内部スロットを持ち、現在の realm の新しい %Symbol% であり、[[Description]] は "IntlLegacyConstructedSymbol" である。
8.1 Intl オブジェクトの値プロパティ
8.1.1 Intl [ %Symbol.toStringTag% ]
%Symbol.toStringTag% プロパティの初期値は文字列値 "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 で呼び出された場合、次の手順を実行する:
ll を ? CanonicalizeLocaleList (locales ) とする。CreateArrayFromList (ll ) を返す。
8.3.2 Intl.supportedValuesOf ( key )
supportedValuesOf メソッドが引数 key で呼び出された場合、次の手順を実行する:
key を ? ToString (key ) とする。key が "calendar" ならば、新しい空のリスト 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
引数で表されるリクエストを、実装の実際の機能と照合するための共通パターンを使用します。その共通の動作は、内部スロットによって機能を説明し、これらの内部スロットを使用する抽象操作、および下記で定義される特殊なデータ型によって説明されます。
利用可能なロケールリスト は、任意の順序で重複のない言語タグ のリストであり、それぞれが 正しい形式 、正規化 され、Unicodeロケール拡張シーケンスを含みません。これは、特定のコンテキスト内で実装が機能を提供するすべてのロケールを表します。
言語優先リスト は、正しい形式 かつ正規化 された言語タグ のリストであり、優先度の高い順にロケールの希望を表します。これは BCP 47 の RFC 4647 セクション 2.3 で定義された同名の用語に対応しますが、" "*
要素を禁止し、正規化された内容のみを含みます。
解決オプション記述子 は、[[Key]] (文字列、通常は
[[RelevantExtensionKeys]] リストの要素)、[[Property]] (文字列)、およびオプションで [[Type]] (boolean または string )、[[Values]] (empty
または ECMAScript 言語値のリスト)を持つレコードです。これは、オブジェクト構築時のロケール解決に関連するオプションの読み取り方法を説明します。
9.1 サービスコンストラクターの内部スロット
各サービスコンストラクタ ーは以下の内部スロットを持ちます:
[[AvailableLocales]] は利用可能なロケールリスト です。DefaultLocale
が返す値を含めなければなりません。さらに、複数のサブタグ を持つ各要素については、同じ言語サブタグ と厳密な部分集合のサブタグ (つまり、1つ以上省略したもの)を持つ、より狭くない言語タグ も含める必要があります。これは
ResolveLocale
からのフォールバックとして機能します。特に、言語サブタグ ・スクリプトサブタグ ・地域サブタグ を持つ各要素には、同じ言語サブタグ と地域サブタグ のみを持ち、スクリプトサブタグ がない別の要素も含める必要があります。例:
[[AvailableLocales]] に "de-DE" が含まれている場合、"de" も含める必要があります(これは "de-AT" や "de-CH"
などのリクエストロケールを満たすために選択される場合があります)。
[[AvailableLocales]] に "az-Latn-AZ" が含まれている場合、"az-AZ" も含める必要があります(これは "az-Cyrl-AZ" のリクエストロケールを満たすために
"az-Cyrl" が利用できない場合に選択される場合があります)。
[[RelevantExtensionKeys]] は、Unicode
Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions で定義された、構築されたオブジェクトの機能に関連する
Unicode ロケール拡張シーケンスキーのリストです。
[[ResolutionOptionDescriptors]] は、オブジェクト構築時のオプション読み取りに使用される解決オプション記述子 のリストです。
[[SortLocaleData]] および [[SearchLocaleData]] (Intl.Collator
用)、[[LocaleData]] (他のサービスコンストラクタ ー用)はレコードです。サービスコンストラクタ ー固有のフィールドに加え、各レコードには [[AvailableLocales]]
に含まれる各ロケール名のフィールドがあります。各ロケール名フィールドの値はレコードであり、[[RelevantExtensionKeys]] の各要素がフィールド名となり、その値は該当ロケールで実装がサポートする
Unicode ロケール拡張シーケンスキーの型値を表す非空の文字列リストです。リストの最初の要素がそのロケールでのデフォルト値となります。
Note
例:DateTimeFormat の実装は
[[AvailableLocales]] 内部スロットに
言語タグ "fa-IR" を含めることがあり、
11.2.3 に従い、
[[RelevantExtensionKeys]] 内部スロットにキー
"ca" ,
"hc" ,
"nu" を含める必要があります。
そのロケールのデフォルトカレンダーは通常
"persian" ですが、実装によっては
"gregory" ,
"islamic" ,
"islamic-civil" もサポートされる場合があります。
DateTimeFormat の
[[LocaleData]] 内部スロットのレコードは、[[fa-IR]] フィールドの値として {
[[ca]] : «
"persian" ,
"gregory" ,
"islamic" ,
"islamic-civil" »,
[[hc]] : « … »,
[[nu]] : « … » } のようなレコードを含み、他のロケール名フィールドも同じ形状ですがリストの要素は異なります。
9.2 抽象操作
9.2.1 CanonicalizeLocaleList ( locales )
The abstract operation CanonicalizeLocaleList takes argument locales (ECMAScript 言語値) and returns 言語優先リスト を含む通常完了または throw 完了. It performs the following steps when called:
locales が undefined の場合、新しい空リストを返す。 seen を新しい空リストとする。locales が文字列またはオブジェクトで、locales が [[InitializedLocale]] 内部スロットを持つ場合、O を CreateArrayFromList (« locales ») とする。それ以外の場合、 O を ? ToObject (locales ) とする。len を ? LengthOfArrayLike (O ) とする。k を 0 とする。k < len の間繰り返す、Pk を ! ToString (𝔽 (k )) とする。kPresent を ? HasProperty (O , Pk ) とする。kPresent が true の場合、kValue を ? Get (O , Pk ) とする。kValue が文字列でもオブジェクトでもない場合、TypeError 例外を投げる。kValue がオブジェクトで [[InitializedLocale]] 内部スロットを持つ場合、tag を kValue .[[Locale]] とする。それ以外の場合、 tag を ? ToString (kValue ) とする。IsWellFormedLanguageTag (tag ) が false の場合、RangeError 例外を投げる。canonicalizedTag を CanonicalizeUnicodeLocaleId (tag ) とする。seen に canonicalizedTag が含まれていなければ、seen に canonicalizedTag を追加する。k を k + 1 に設定する。seen を返す。
Note 1
非規範的なまとめ:この抽象操作は
locales 引数を配列として解釈し、その要素をリストにコピーし、要素が正しい形式の
言語タグ かつ正規化されていることを検証し、重複を省きます。
Note 2
kValue を文字列またはオブジェクトに限定することで、数値値
NaN が Min Nan Chinese を表す
言語タグ "nan" として解釈されることはありません。
The abstract operation UNKNOWN takes UNPARSEABLE ARGUMENTS. 返される文字列は、ukey の値としての uvalue の正規化かつケース正則化された形式です。 It performs the following steps when called:
lowerValue を uvalue の ASCII 小文字化とする。canonicalized を Unicode Technical Standard
#35 Part 1 Core, Annex C LocaleId Canonicalization Section 5 Canonicalizing Syntax, Processing LocaleIds
に従い、ukey の値として lowerValue を正規化した文字列値とする。注:実装では Common Locale Data Repository の common/bcp47 の 'u' 拡張データ(https://cldr.unicode.org/ )の利用が推奨されます。 canonicalized を返す。
9.2.3 LookupMatchingLocaleByPrefix ( availableLocales , requestedLocales )
The abstract operation LookupMatchingLocaleByPrefix takes arguments availableLocales (利用可能なロケールリスト ) and requestedLocales (言語優先リスト ) and returns フィールド [[locale]] (Unicode 正規化ロケール識別子)と [[extension]] (Unicode ロケール拡張シーケンスまたは empty )を持つレコード、または undefined . これは BCP 47 の RFC 4647 セクション 3.4
で定義されたルックアップアルゴリズムを使用し、Unicode ロケール拡張シーケンスを無視して、requestedLocales を満たすための availableLocales
の最良の要素を決定します。非デフォルトの一致が見つかった場合、availableLocales から一致する言語タグ を [[locale]] フィールドに、requestedLocales の該当要素の
Unicode ロケール拡張シーケンス(または拡張シーケンスがなければ empty )を [[extension]] フィールドに含むレコードを返します。 It performs the following steps when called:
requestedLocales の各要素 locale について、extension を empty とする。locale が Unicode ロケール拡張シーケンスを含む場合、extension を locale の Unicode ロケール拡張シーケンスとする。locale を Unicode ロケール拡張シーケンスを除去した文字列値とする。prefix を locale とする。prefix が空文字列でない間繰り返す、availableLocales に prefix が含まれていれば、レコード { [[locale]] : prefix , [[extension]] : extension } を返す。prefix に "-" (コードユニット 0x002D HYPHEN-MINUS)が含まれていれば、prefix の最後の "-" の位置を pos とする。なければ pos を 0 とする。pos ≥ 2 かつ prefix の pos - 2 から pos - 1 の部分文字列が "-" の間繰り返す、pos を pos - 2 に設定する。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 (利用可能なロケールリスト ) and requestedLocales (言語優先リスト ) and returns フィールド [[locale]] (Unicode 正規化ロケール識別子)と [[extension]] (Unicode ロケール拡張シーケンスまたは empty )を持つレコード、または undefined . これは Unicode ロケール拡張シーケンスを無視して、requestedLocales を満たすための availableLocales
の最良の要素を決定します。アルゴリズムは実装依存ですが、LookupMatchingLocaleByPrefix
アルゴリズムの結果と同等以上とみなされる結果を生成するべきです。非デフォルトの一致が見つかった場合、availableLocales から一致する言語タグ を [[locale]]
フィールドに、requestedLocales の該当要素の Unicode ロケール拡張シーケンス(または拡張シーケンスがなければ empty )を [[extension]]
フィールドに含むレコードを返します。
9.2.5 UnicodeExtensionComponents ( extension )
The abstract operation UnicodeExtensionComponents takes argument extension (Unicode ロケール拡張シーケンス) and returns フィールド [[Attributes]] と [[Keywords]] を持つレコード. extension をユニークな属性のリストと、ユニークなキーを持つ keywords のリストに分解します。属性や
keyword キーが繰り返し現れた場合、最初以外は無視されます。
It performs the following steps when called:
アサート:extension の ASCII 小文字化は extension である。 アサート:extension の 0 から 3 の部分文字列は "-u-" である。 attributes を新しい空リストとする。keywords を新しい空リストとする。keyword を undefined とする。size を extension の長さとする。k を 3 とする。k < size の間繰り返す、e を StringIndexOf (extension , "-" , k ) とする。e が not-found の場合、len を size - k とする。そうでなければ len を e - k とする。subtag を extension の k から k + len の部分文字列とする。注:keyword は、最初が長さ2のキーで、以降(存在する場合)は長さ3~8のサブタグ の連続であり、"-" 区切りで値を構成します。属性は、すべての
keywords より前に現れる長さ3~8の単一サブタグ です。 アサート:len ≥ 2。 keyword が undefined かつ len ≠ 2 の場合、subtag が attributes に含まれていなければ、attributes に subtag を追加する。それ以外で len = 2 の場合、 keyword をレコード { [[Key]] : subtag , [[Value]] : "" } とする。keywords に [[Key]] が keyword .[[Key]] の要素が含まれていなければ、keywords に keyword を追加する。それ以外で keyword .[[Value]] が空文字列の場合、 keyword .[[Value]] を subtag に設定する。それ以外の場合、 keyword .[[Value]] を keyword .[[Value]] , "-" , subtag の文字列連結に設定する。k を k + len + 1 に設定する。レコード { [[Attributes]] : attributes , [[Keywords]] : keywords } を返す。
9.2.6 InsertUnicodeExtensionAndCanonicalize ( locale , attributes , keywords )
The abstract operation InsertUnicodeExtensionAndCanonicalize takes arguments locale (言語タグ ), attributes (文字列リスト), and keywords (レコードリスト) and returns Unicode 正規化ロケール識別子. attributes と keywords を Unicode ロケール拡張シーケンスとして locale に組み込み、正規化した結果を返します。 It performs the following steps when called:
アサート:locale は Unicode ロケール拡張シーケンスを含まない。 extension を "-u" とする。attributes の各要素 attr について、extension を extension , "-" , attr の文字列連結に設定する。各レコード { [[Key]] , [[Value]] } keyword について、 extension を extension , "-" , keyword .[[Key]] の文字列連結に設定する。keyword .[[Value]] が空文字列でなければ、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 の文字列連結とする。アサート:IsWellFormedLanguageTag (newLocale ) は true である。 CanonicalizeUnicodeLocaleId (newLocale ) を返す。
9.2.7 ResolveLocale ( availableLocales , requestedLocales , options , relevantExtensionKeys , localeData )
The abstract operation ResolveLocale takes arguments availableLocales (利用可能なロケールリスト ), requestedLocales (言語優先リスト ), options (レコード), relevantExtensionKeys (文字列リスト), and localeData (レコード) and returns レコード. これは BCP 47 の RFC 4647 セクション 3 で定義された "lookup"
を実行し、options .[[localeMatcher]] で指定されたアルゴリズム(LookupMatchingLocaleByBestFit または
LookupMatchingLocaleByPrefix )を使用して Unicode ロケール拡張シーケンスを無視し、requestedLocales を満たすための availableLocales
の最良の要素を決定します。さらに、localeData から対応するデータと、relevantExtensionKeys の各要素について解決された値(一致したロケールのデータをデフォルトとし、リクエストされた
Unicode ロケール拡張シーケンスのデータがあればそれを優先し、さらに options のデータがあればそれを優先)を含む表現を返します。一致した requestedLocales の要素が Unicode
ロケール拡張シーケンスを含む場合、[[Locale]] フィールドの言語タグ にコピーされます。ただし、relevantExtensionKeys に含まれない keyword Unicode
ロケール非終端や、options から上書きされた type 値は省略されます。 It performs the following steps when called:
matcher を options .[[localeMatcher]] とする。matcher が "lookup" の場合、r を LookupMatchingLocaleByPrefix (availableLocales , requestedLocales ) とする。それ以外の場合、 r を LookupMatchingLocaleByBestFit (availableLocales , requestedLocales ) とする。r が undefined の場合、r をレコード { [[locale]] : DefaultLocale (), [[extension]] : empty } とする。foundLocale を r .[[locale]] とする。foundLocaleData を localeData .[[<foundLocale >]] とする。アサート:foundLocaleData はレコードである。 result を新しいレコードとする。result .[[LocaleData]] に foundLocaleData を設定する。r .[[extension]] が empty でなければ、components を UnicodeExtensionComponents (r .[[extension]] ) とする。keywords を components .[[Keywords]] とする。それ以外の場合、 keywords を新しい空リストとする。supportedKeywords を新しい空リストとする。relevantExtensionKeys の各要素 key について、keyLocaleData を foundLocaleData .[[<key >]] とする。アサート:keyLocaleData はリストである。 value を keyLocaleData [0] とする。アサート:value は文字列または null である。 supportedKeyword を empty とする。keywords に [[Key]] が key の要素が含まれていれば、entry を keywords の [[Key]] が key の要素とする。requestedValue を entry .[[Value]] とする。requestedValue が空文字列でなければ、keyLocaleData に requestedValue が含まれていれば、value を requestedValue に設定する。supportedKeyword をレコード { [[Key]] : key , [[Value]] : value } に設定する。それ以外で keyLocaleData に "true" が含まれていれば、 value を "true" に設定する。supportedKeyword をレコード { [[Key]] : key , [[Value]] : "" } に設定する。アサート:options は [[<key >]] フィールドを持つ。 optionsValue を options .[[<key >]] とする。アサート:optionsValue は文字列、または undefined か null である。 optionsValue が文字列の場合、ukey を key の ASCII 小文字化とする。optionsValue を CanonicalizeUValue(ukey , optionsValue ) に設定する。optionsValue が空文字列の場合、optionsValue を "true" に設定する。SameValue (optionsValue , value ) が false かつ keyLocaleData に optionsValue が含まれていれば、value を optionsValue に設定する。supportedKeyword を empty に設定する。supportedKeyword が empty でなければ、supportedKeywords に supportedKeyword を追加する。result .[[<key >]] に value を設定する。supportedKeywords が空でなければ、supportedAttributes を新しい空リストとする。foundLocale を InsertUnicodeExtensionAndCanonicalize (foundLocale , supportedAttributes ,
supportedKeywords ) に設定する。result .[[Locale]] に foundLocale を設定する。result を返す。
9.2.8 ResolveOptions ( constructor , localeData , locales , options [ , specialBehaviours [ , modifyResolutionOptions ] ] )
The abstract operation ResolveOptions takes arguments constructor (サービスコンストラクタ ー), localeData (レコード), locales (ECMAScript 言語値), and options (ECMAScript 言語値) and optional arguments specialBehaviours (列挙型リスト) and modifyResolutionOptions (1パラメータの抽象クロージャ) and returns フィールド [[Options]] (オブジェクト)、[[ResolvedLocale]] (レコード)、[[ResolutionOptions]] (レコード)を持つ通常完了または throw 完了. constructor の入力を読み取り、ロケールに解決します。 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 をレコード { [[localeMatcher]] : matcher } とする。constructor .[[ResolutionOptionDescriptors]] の各解決オプション記述子 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 (constructor .[[AvailableLocales]] , requestedLocales , opt ,
constructor .[[RelevantExtensionKeys]] , localeData ) とする。レコード { [[Options]] : options , [[ResolvedLocale]] : resolution , [[ResolutionOptions]] : opt } を返す。
9.2.9 FilterLocales ( availableLocales , requestedLocales , options )
The abstract operation FilterLocales takes arguments availableLocales (利用可能なロケールリスト ), requestedLocales (言語優先リスト ), and options (ECMAScript 言語値) and returns Unicode 正規化ロケール識別子のリストを含む通常完了または throw 完了. これは BCP 47 の RFC 4647 セクション 3 で定義された "filtering"
を実行し、options で指定されたアルゴリズム(LookupMatchingLocaleByBestFit または
LookupMatchingLocaleByPrefix )を使用して、requestedLocales のうち availableLocales に一致するロケールを相対順序を保って返します。 It performs the following steps when called:
options を ? CoerceOptionsToObject (options ) に設定する。matcher を ? GetOption (options , "localeMatcher" , string , « "lookup" , "best fit" », "best fit" )
とする。subset を新しい空リストとする。requestedLocales の各要素 locale について、matcher が "lookup" の場合、match を LookupMatchingLocaleByPrefix (availableLocales , « locale ») とする。それ以外の場合、 match を LookupMatchingLocaleByBestFit (availableLocales , « locale ») とする。match が undefined でなければ、subset に locale を追加する。CreateArrayFromList (subset ) を返す。
9.2.10 CoerceOptionsToObject ( options )
The abstract operation CoerceOptionsToObject takes argument options (ECMAScript 言語値) and returns オブジェクトを含む通常完了または throw 完了.
options を GetOption で使用可能なオブジェクトに変換し、デフォルトは空オブジェクトとします。
null でないプリミティブ値もオブジェクトに変換するため、新しい機能では GetOptionsObject の利用が推奨されます。
It performs the following steps when called:
options が undefined の場合、OrdinaryObjectCreate (null ) を返す。? ToObject (options ) を返す。
9.2.11 GetOption ( options , property , type , values , default )
The abstract operation GetOption takes arguments options (オブジェクト), property (プロパティキー), type (boolean または string ), values (empty または ECMAScript 言語値のリスト), and default (required または ECMAScript 言語値) and returns ECMAScript 言語値を含む通常完了または throw 完了. 指定されたプロパティの値を抽出し、必要な type に変換し、values が empty でなければ許可された値か確認し、値が undefined なら default を代用します。 It performs the following steps when called:
value を ? Get (options , property ) とする。value が undefined の場合、default が required なら、RangeError 例外を投げる。default を返す。type が boolean の場合、value を ToBoolean (value ) に設定する。それ以外の場合、 アサート:type は string である。 value を ? ToString (value ) に設定する。values が empty でなく、values に value が含まれていなければ、RangeError 例外を投げる。value を返す。
9.2.12 GetBooleanOrStringNumberFormatOption ( options , property , stringValues , fallback )
The abstract operation GetBooleanOrStringNumberFormatOption takes arguments options (オブジェクト), property (プロパティキー), stringValues (文字列リスト), and fallback (ECMAScript 言語値) and returns Boolean, 文字列、fallback のいずれかを含む通常完了または throw 完了. options オブジェクトから property 名の値を抽出します。値が undefined なら fallback を返し、値が true なら true
を返し、ToBoolean (value ) が false なら false を返し、それ以外は文字列に変換し、stringValues に含まれていなければ RangeError
例外を投げ、含まれていればその値を返します。 It performs the following steps when called:
value を ? Get (options , property ) とする。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 , property , minimum , maximum , fallback )
The abstract operation GetNumberOption takes arguments options (オブジェクト), property (文字列), minimum (整数), maximum (整数), and fallback (整数または undefined ) and returns 整数または undefined を含む通常完了または throw 完了. options オブジェクトから property 名の値を抽出し、整数に変換し、許可された範囲内か確認し、必要に応じて fallback 値を補います。 It performs the following steps when called:
value を ? Get (options , property ) とする。? DefaultNumberOption (value , minimum , maximum , fallback ) を返す。
9.2.15 PartitionPattern ( pattern )
The abstract operation PartitionPattern takes argument pattern (パターン文字列 ) and returns フィールド [[Type]] (文字列)と [[Value]] (文字列または undefined )を持つレコードのリスト.
[[Type]] が "literal" の場合、[[Value]] フィールドは文字列値となり、それ以外の場合は undefined となります。
It performs the following steps when called:
result を新しい空リストとする。placeholderEnd を -1 とする。placeholderStart を StringIndexOf (pattern , "{" , 0) とする。placeholderStart が not-found でない間繰り返す、literal を pattern の placeholderEnd + 1 から placeholderStart までの部分文字列とする。literal が空文字列でなければ、レコード { [[Type]] : "literal" , [[Value]] : literal } を result に追加する。 placeholderEnd を StringIndexOf (pattern , "}" , placeholderStart ) とする。アサート:placeholderEnd は not-found でなく、placeholderStart < placeholderEnd である。 placeholderName を pattern の placeholderStart + 1 から placeholderEnd までの部分文字列とする。レコード { [[Type]] : placeholderName , [[Value]] : undefined } を result に追加する。 placeholderStart を StringIndexOf (pattern , "{" , placeholderEnd ) に設定する。tail を pattern の placeholderEnd + 1 からの部分文字列とする。tail が空文字列でなければ、レコード { [[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 ) とする。r を optionsResolution .[[ResolvedLocale]] とする。collator .[[Locale]] に r .[[Locale]] を設定する。r .[[co]] が null なら collation を "default" とし、そうでなければ collation を r .[[co]] とする。collator .[[Collation]] に collation を設定する。collator .[[Numeric]] に SameValue (r .[[kn]] , "true" ) を設定する。collator .[[CaseFirst]] に r .[[kf]] を設定する。resolvedLocaleData を r .[[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 の各行(ヘッダー行を除く)について、テーブル順に次を行うp を現在の行の Property 値とする。v を collator の内部スロットのうち、現在の行の Internal Slot 値の名前を持つものの値とする。現在の行に Extension Key 値がある場合、 extensionKey を現在の行の Extension Key 値とする。%Intl.Collator% .[[RelevantExtensionKeys]] が extensionKey を含まない場合、v を undefined に設定する。v が undefined でない場合、! CreateDataPropertyOrThrow (options , p , v ) を実行する。 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 なら、F を 10.3.3.1 で定義された新しい組み込み関数オブジェクトとする。F .[[Collator]] に collator を設定する。collator .[[BoundCompare]] に F を設定する。collator .[[BoundCompare]] を返す。
Note
返される関数は collator にバインドされているため、Array.prototype.sort や他の関数に直接渡すことができる。
10.3.3.1 Collator 比較関数
Collator 比較関数は [[Collator]] 内部スロットを持つ匿名組み込み関数である。
Collator 比較関数 F が引数 x と y で呼び出された場合、次の手順を実行する:
collator を F .[[Collator]] とする。collator はオブジェクトであり、[[InitializedCollator]] 内部スロットを持つことをアサートする。x が指定されていない場合、x を undefined とする。y が指定されていない場合、y を undefined とする。X を ? ToString (x ) とする。Y を ? ToString (y ) とする。CompareStrings (collator , X , Y ) を返す。
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 日付時刻フォーマットオブジェクト
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 正常完了値としてオブジェクト、または 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]] ») とする。hour12 を undefined とする。modifyResolutionOptions を (options ) をパラメータとし、hour12 をキャプチャし、呼び出された時に次の手順を行う新しい抽象クロージャとする:hour12 を options .[[hour12]] とする。options から [[hour12]] フィールドを削除する。hour12 が undefined でない場合、options .[[hc]] を null とする。optionsResolution を ? ResolveOptions (%Intl.DateTimeFormat% , %Intl.DateTimeFormat% .[[LocaleData]] ,
locales , options , « coerce-options », modifyResolutionOptions ) とする。options を optionsResolution .[[Options]] とする。r を optionsResolution .[[ResolvedLocale]] とする。dateTimeFormat .[[Locale]] を r .[[Locale]] とする。resolvedCalendar を r .[[ca]] とする。dateTimeFormat .[[Calendar]] を resolvedCalendar とする。dateTimeFormat .[[NumberingSystem]] を r .[[nu]] とする。resolvedLocaleData を r .[[LocaleData]] とする。hour12 が true の場合、hc を resolvedLocaleData .[[hourCycle12]] とする。hour12 が false の場合、hc を resolvedLocaleData .[[hourCycle24]] とする。それ以外の場合、 hour12 が undefined であることをアサートする。hc を r .[[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 ) とする。parseResult が Parse Node であることをアサートする。parseResult が複数の MinuteSecond Parse Node を含む場合、RangeError 例外を投げる。offsetNanoseconds を ParseTimeZoneOffsetString (timeZone ) とする。offsetMinutes を offsetNanoseconds / (6 × 1010 ) とする。offsetMinutes が整数であることをアサートする。timeZone を FormatOffsetTimeZoneIdentifier (offsetMinutes ) とする。それ以外の場合、 timeZoneIdentifierRecord を GetAvailableNamedTimeZoneIdentifier (timeZone ) とする。timeZoneIdentifierRecord が empty の場合、RangeError 例外を投げる。timeZone を timeZoneIdentifierRecord .[[PrimaryIdentifier]] とする。dateTimeFormat .[[TimeZone]] を timeZone とする。formatOptions を新しいレコードとする。formatOptions .[[hourCycle]] を hc とする。hasExplicitFormatComponents を false とする。Table 16 の各行(ヘッダー行を除く)を順番に処理する:prop を現在の行の Property 列の名前とする。prop が "fractionalSecondDigits" の場合、value を ? GetNumberOption (options , "fractionalSecondDigits" , 1, 3, undefined ) とする。それ以外の場合、 values を現在の行の Values 列に記載された文字列のリストとする。value を ? GetOption (options , prop , string , values , undefined ) とする。formatOptions .[[<prop >]] を 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 または 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" » の各プロパティ名 prop について、 value を formatOptions .[[<prop >]] とする。value が undefined でない場合、needDefaults を false とする。required が time または any の場合、« "dayPeriod" , "hour" , "minute" , "second" , "fractionalSecondDigits" » の各プロパティ名 prop について、 value を formatOptions .[[<prop >]] とする。value が undefined でない場合、needDefaults を false とする。needDefaults が true かつ defaults が date または all の場合、« "year" , "month" , "day" » の各プロパティ名 prop について、 formatOptions .[[<prop >]] を "numeric" とする。needDefaults が true かつ defaults が time または all の場合、« "hour" , "minute" , "second" » の各プロパティ名 prop について、 formatOptions .[[<prop >]] を "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 文字列.
UTCオフセット(分単位)を ±HH:MM の形式のUTCオフセット文字列にフォーマットする。
It performs the following steps when called:
offsetMinutes ≥ 0 の場合、sign をコードユニット 0x002B (プラス記号) とし、そうでなければコードユニット 0x002D (ハイフンマイナス) とする。absoluteMinutes を abs (offsetMinutes ) とする。hours を floor (absoluteMinutes / 60) とする。minutes を absoluteMinutes の 60 で割った余りとする。sign 、ToZeroPaddedDecimalString (hours , 2)、コードユニット 0x003A (コロン)、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 では、タイムゾーンはオプションオブジェクトの
"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" の値を含まないリストでなければならない。
[[LocaleData]] .[[<locale >]].[[hc]] は « null , "h11" , "h12" , "h23" , "h24" » でなければならない。
[[LocaleData]] .[[<locale >]].[[hourCycle]] は "h11" , "h12" , "h23" , "h24" のいずれかの文字列値でなければならない。
[[LocaleData]] .[[<locale >]].[[hourCycle12]] は "h11" または "h12" のいずれかの文字列値でなければならない。
[[LocaleData]] .[[<locale >]].[[hourCycle24]] は "h23" または "h24" のいずれかの文字列値でなければならない。
[[LocaleData]] .[[<locale >]] は [[formats]] フィールドを持たなければならない。この [[formats]] フィールドの値は、各カレンダー値 calendar
について [[<calendar >]] フィールドを持つレコードでなければならない。各 [[<calendar >]] フィールドの値は DateTime Format Record
のリストでなければならない。そのリスト内の複数のレコードは、対応する値が少なくとも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 >]] フィールドを持つレコードでなければならない。各 [[<calendar >]] フィールドの値は DateTime Styles Record でなければならない。
11.2.3.1 DateTime Format Record
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}" のいずれかの部分文字列が含まれている場合に存在する。
[[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]]
パターン文字列
Contains 各日付・時刻フォーマットコンポーネントフィールドについて、レコードの文字列は "{" で始まり、フィールド名、"}"
で終わる部分文字列を含む。レコードが [[year]] フィールドを持つ場合、文字列は "{yearName}" や "{relatedYear}" の部分文字列を含むことがある。
[[pattern12]]
パターン文字列
オプションフィールド。[[hour]] フィールドが存在する場合に存在する。[[pattern]] フィールドの部分文字列に加え、"{ampm}" または "{dayPeriod}"
のいずれかの部分文字列を含む。
[[rangePatterns]]
DateTime Range Pattern Record
このフィールドのパターン文字列 は [[pattern]] と類似している。
[[rangePatterns12]]
DateTime Range Pattern Record
オプションフィールド。[[hour]] フィールドが存在する場合に存在する。パターン文字列 は [[pattern12]] と類似している。
11.2.3.2 DateTime Range Pattern Record
DateTime Range Pattern Record は Table 6 で定義されたフィールドを持つ。
Table 6: DateTime Range Pattern Record
11.2.3.3 DateTime Range Pattern Format Record
DateTime Range Pattern Format Record は Table 7 で定義されたフィールドを持つ。
Table 7: DateTime Range Pattern Format Record
フィールド名
値の型
説明
[[weekday]]
Table 16 の Values 列の [[Weekday]] 値
オプションフィールド。[[PatternParts]] のパターン文字列 に "{weekday}" の部分文字列が含まれている場合に存在する。
[[era]]
Table 16 の Values 列の [[Era]] 値
オプションフィールド。[[PatternParts]] のパターン文字列 に "{era}" の部分文字列が含まれている場合に存在する。
[[year]]
Table 16 の Values 列の [[Year]] 値
オプションフィールド。[[PatternParts]] のパターン文字列 に "{year}" 、"{yearName}" 、"{relatedYear}"
のいずれかの部分文字列が含まれている場合に存在する。
[[month]]
Table 16 の Values 列の [[Month]] 値
オプションフィールド。[[PatternParts]] のパターン文字列 に "{month}" の部分文字列が含まれている場合に存在する。
[[day]]
Table 16 の Values 列の [[Day]] 値
オプションフィールド。[[PatternParts]] のパターン文字列 に "{day}" の部分文字列が含まれている場合に存在する。
[[dayPeriod]]
Table 16 の Values 列の [[DayPeriod]] 値
オプションフィールド。[[PatternParts]] のパターン文字列 に "{dayPeriod}" の部分文字列が含まれている場合に存在する。
[[hour]]
Table 16 の Values 列の [[Hour]] 値
オプションフィールド。[[PatternParts]] のパターン文字列 に "{hour}" の部分文字列が含まれている場合に存在する。
[[minute]]
Table 16 の Values 列の [[Minute]] 値
オプションフィールド。[[PatternParts]] のパターン文字列 に "{minute}" の部分文字列が含まれている場合に存在する。
[[second]]
Table 16 の Values 列の [[Second]] 値
オプションフィールド。[[PatternParts]] のパターン文字列 に "{second}" の部分文字列が含まれている場合に存在する。
[[fractionalSecondDigits]]
Table 16 の Values 列の [[FractionalSecondDigits]] 値
オプションフィールド。[[PatternParts]] のパターン文字列 に "{fractionalSecondDigits}" の部分文字列が含まれている場合に存在する。
[[timeZoneName]]
Table 16 の Values 列の [[TimeZoneName]] 値
オプションフィールド。[[PatternParts]] のパターン文字列 に "{timeZoneName}" の部分文字列が含まれている場合に存在する。
[[PatternParts]]
DateTime Range Pattern Part Record のリスト
各レコードは範囲パターンの一部を表す。
11.2.3.4 DateTime Range Pattern Part Record
DateTime
Range Pattern Part Record は Table 8 で定義されたフィールドを持つ。
Table 8: DateTime Range Pattern Part Record
フィールド名
値の型
説明
[[Source]]
"shared" , "startRange" , "endRange" のいずれか
どちらの日付を [[Pattern]] フィールドの値でフォーマットするかを示す。
[[Pattern]]
パターン文字列
通常の日付パターン文字列 と同じ形式の文字列。
11.2.3.5 DateTime Styles Record
DateTime Styles Record は Table 9 で定義されたフィールドを持つ。
Table 9: DateTime Styles Record
11.2.3.6 DateTime Style Record
DateTime Style Record は Table 10 で定義されたフィールドを持つ。
Table 10: DateTime Style Record
11.2.3.7 DateTime Connector Record
DateTime Connector Record は Table 11 で定義されたフィールドを持つ。すべてのコネクターパターン文字列 は "{0}" と "{1}"
を含まなければならない。
Table 11: DateTime Connector Record
フィールド名
値の型
説明
[[full]]
パターン文字列
日付スタイルが "full" の場合のコネクターパターン。
[[long]]
パターン文字列
日付スタイルが "long" の場合のコネクターパターン。
[[medium]]
パターン文字列
日付スタイルが "medium" の場合のコネクターパターン。
[[short]]
パターン文字列
日付スタイルが "short" の場合のコネクターパターン。
11.2.3.8 DateTime Date Range Record
DateTime Date Range Record は Table 12 で定義されたフィールドを持つ。
Table 12: DateTime Date Range Record
11.2.3.9 DateTime Time Range Record
DateTime Time Range Record は Table 13 で定義されたフィールドを持つ。
Table 13: DateTime Time Range Record
11.2.3.10 DateTime Style Range Record
DateTime Style Range Record は Table 14 で定義されたフィールドを持つ。
Table 14: DateTime Style Range Record
Note 2
例えば、実装は英語ロケールデータの一部として次のレコードを含めることができる:
[[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
実装は
https://cldr.unicode.org/ で提供されている Common Locale Data Repository
のロケールデータを使用することが推奨される。
11.3 Intl.DateTimeFormat プロトタイプオブジェクトのプロパティ
Intl.DateTimeFormat プロトタイプオブジェクト :
%Intl.DateTimeFormat.prototype% である。
通常のオブジェクトである。
Intl.DateTimeFormat インスタンスではなく、[[InitializedDateTimeFormat]] 内部スロットや他のインスタンスオブジェクトの内部スロットを持たない。
[[Prototype]] 内部スロットの値は %Object.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 の各行(ヘッダー行を除く)を順番に処理する:p を現在の行の Property 値とする。現在の行に Internal Slot 値がある場合、 v を dtf の内部スロットの値(Internal Slot 値の名前)とする。それ以外の場合、 format を dtf .[[DateTimeFormat]] とする。format が [[<p >]] フィールドを持ち、dtf .[[DateStyle]] と dtf .[[TimeStyle]] が undefined の場合、v を format .[[<p >]] とする。それ以外の場合、 v を undefined とする。v が undefined でない場合、現在の行に Conversion 値がある場合、 conversion を現在の行の Conversion 値とする。conversion が hour12 の場合、v が "h11" または "h12" の場合、v を true とする。そうでなければ、v を false とする。それ以外の場合、 アサート: conversion は number である。 v を 𝔽 (v ) とする。! CreateDataPropertyOrThrow (options , p , v ) を実行する。 options を返す。
Table 15: DateTimeFormat インスタンスの resolvedOptions
Internal Slot
Property
Conversion
[[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"
ウェブ互換性の理由により、"hourCycle" プロパティが設定されている場合、"hourCycle" が "h11" または "h12" のときは "hour12" プロパティを true
に、"hourCycle" が "h23" または "h24" のときは false に設定する必要がある。
Note 1
この API のバージョンでは、"timeZone" プロパティは Intl.DateTimeFormat コンストラクターにオプションオブジェクトで "timeZone"
プロパティが指定されていない場合、ホスト環境のタイムゾーン識別子となる。初版ではこの場合 "timeZone" プロパティは undefined だった。
Note 2
第五版より前のバージョンとの互換性のため、"hourCycle" プロパティに加えて "hour12" プロパティも設定される。
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 の場合、11.5.4 で定義された新しい組み込み関数オブジェクト F を作成する。F .[[DateTimeFormat]] を dtf に設定する。dtf .[[BoundFormat]] を F に設定する。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 または 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 または 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% プロパティの初期値は文字列値 "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]] は、フォーマットに使用されるロケールの言語タグ を表す文字列値です。
[[Calendar]] は、フォーマットに使用される Unicode
カレンダー識別子 を表す文字列値です。
[[NumberingSystem]] は、フォーマットに使用される Unicode 数字体系識別子 を表す文字列値です。
[[TimeZone]] は、フォーマットに使用される文字列値で、利用可能な名前付きタイムゾーン識別子またはオフセットタイムゾーン識別子です。
[[HourCycle]] は、12時間形式("h11" , "h12" )または24時間形式("h23" , "h24" )のどちらを使用するかを示す文字列値です。"h11" と "h23" はそれぞれ
0 から 11、0 から 23 までの時間で始まります。"h12" と "h24" はそれぞれ 1 から 12、1 から 24 までの時間で始まります。[[HourCycle]] は
[[DateTimeFormat]] に [[hour]] フィールドがある場合のみ使用されます。
[[DateStyle]] 、[[TimeStyle]] はそれぞれ undefined または文字列値で、"full" , "long" , "medium" , "short" のいずれかです。
[[DateTimeFormat]] は DateTime Format Record です。
最後に、Intl.DateTimeFormat インスタンスは format アクセサ(11.3.3 )によって返される関数をキャッシュする [[BoundFormat]] 内部スロットを持ちます。
11.5 日付時刻フォーマットオブジェクトの抽象操作
いくつかの日付時刻フォーマットアルゴリズムは、次の表の値を使用します。この表は、日付と時刻フォーマットの各コンポーネントの内部スロット、プロパティ名、許容値を示します:
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 . It performs the following steps when called:
アサート: dateStyle が undefined でない、または timeStyle が undefined でない。 timeStyle が undefined でない場合、アサート: timeStyle は "full" , "long" , "medium" , "short" のいずれか。 timeFormat を styles .[[Time]] .[[<timeStyle >]] とする。dateStyle が undefined でない場合、アサート: dateStyle は "full" , "long" , "medium" , "short" のいずれか。 dateFormat を styles .[[Date]] .[[<dateStyle >]] とする。dateStyle と timeStyle が両方 undefined でない場合、format を新しい DateTime Format Record とする。format に dateFormat の全フィールド([[pattern]] と [[rangePatterns]] を除く)を追加する。format に timeFormat の全フィールド([[pattern]] , [[rangePatterns]] , [[pattern12]] , [[rangePatterns12]]
を除く)を追加する(存在する場合)。connector を styles .[[Connector]] .[[<dateStyle >]] とする。pattern を connector の "{0}" を timeFormat .[[pattern]] に、"{1}" を dateFormat .[[pattern]]
に置換した文字列とする。format .[[pattern]] を pattern に設定する。timeFormat が [[pattern12]] フィールドを持つ場合、pattern12 を connector の "{0}" を timeFormat .[[pattern12]] に、"{1}" を dateFormat .[[pattern]]
に置換した文字列とする。format .[[pattern12]] を pattern12 に設定する。dateTimeRangeFormat を styles .[[DateTimeRangeFormat]] .[[<dateStyle >]].[[<timeStyle >]] とする。format .[[rangePatterns]] を dateTimeRangeFormat .[[rangePatterns]] に設定する。dateTimeRangeFormat が [[rangePatterns12]] フィールドを持つ場合、format .[[rangePatterns12]] を dateTimeRangeFormat .[[rangePatterns12]] に設定する。format を返す。timeStyle が undefined でない場合、timeFormat を返す。アサート: dateStyle が undefined でない。 dateFormat を返す。
11.5.2 BasicFormatMatcher ( options , formats )
The abstract operation BasicFormatMatcher takes arguments options (レコード) and formats (DateTime Format Record のリスト) 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 >]] とし、そうでなければ
undefined とする。format が [[<property >]] フィールドを持つ場合、formatProp を format .[[<property >]] とし、そうでなければ 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 (レコード) and formats (DateTime Format Record のリスト) and returns DateTime Format Record .
11.5.4 日付時刻フォーマット関数
日付時刻フォーマット関数は [[DateTimeFormat]] 内部スロットを持つ匿名組み込み関数です。
日付時刻フォーマット関数 F がオプション引数 date で呼び出された場合、次の手順を行います:
dtf を F .[[DateTimeFormat]] とする。アサート: dtf はオブジェクトであり、[[InitializedDateTimeFormat]] 内部スロットを持つ。 date が指定されていない、または undefined の場合、x を ! Call (%Date.now%, undefined ) とする。それ以外の場合、 x を ? ToNumber (date ) とする。? FormatDateTime (dtf , x ) を返す。
日付時刻フォーマット関数の "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 (パターン文字列 ), and epochNanoseconds (BigInt) and returns レコードのリスト([[Type]] (文字列)、[[Value]] (文字列)フィールドを持つ). 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 ») とする。tm を ToLocalTime (epochNanoseconds , dateTimeFormat .[[Calendar]] , dateTimeFormat .[[TimeZone]] ) とする。patternParts を PartitionPattern (pattern ) とする。result を新しい空リストとする。patternParts の各レコード { [[Type]] , [[Value]] } patternPart について、p を patternPart .[[Type]] とする。p が "literal" の場合、レコード { [[Type]] : "literal" , [[Value]] : patternPart .[[Value]] } を result に追加する。 p が "fractionalSecondDigits" の場合、アサート: format が [[fractionalSecondDigits]] フィールドを持つ。 v を tm .[[Millisecond]] とする。v を floor (v × 10( fractionalSecondDigits - 3 ) ) とする。fv を FormatNumeric (nf3 , v ) とする。レコード { [[Type]] : "fractionalSecond" , [[Value]] : fv } を result に追加する。 p が "dayPeriod" の場合、アサート: format が [[dayPeriod]] フィールドを持つ。 f を format .[[dayPeriod]] とする。fv を tm の day period を f 形式で表す文字列値とする(値は実装とロケール依存)。レコード { [[Type]] : p , [[Value]] : fv } を result に追加する。 p が "timeZoneName" の場合、アサート: format が [[timeZoneName]] フィールドを持つ。 f を format .[[timeZoneName]] とする。v を dateTimeFormat .[[TimeZone]] とする。fv を v を f 形式で表す文字列値とする(値は実装とロケール依存。[[InDST]] の値によっても変化する場合あり。ローカライズ表現がない場合は v の文字列値を使う)。レコード { [[Type]] : p , [[Value]] : fv } を result に追加する。 p が Table 16 の Property 列と一致する場合、アサート: format が [[<p >]] フィールドを持つ。 f を format .[[<p >]] とする。v を tm のフィールド(Internal Slot 列の名前)値とする。p が "year" かつ v ≤ 0 の場合、v を 1 - v とする。p が "month" の場合、v を v + 1 とする。p が "hour" かつ dateTimeFormat .[[HourCycle]] が "h11" または "h12" の場合、v を v mod 12 とする。v が 0 かつ dateTimeFormat .[[HourCycle]] が "h12" の場合、v を 12 とする。p が "hour" かつ dateTimeFormat .[[HourCycle]] が "h24" の場合、v が 0 の場合、v を 24 とする。f が "numeric" の場合、fv を FormatNumeric (nf , v ) とする。f が "2-digit" の場合、fv を FormatNumeric (nf2 , v ) とする。codePoints を StringToCodePoints (fv ) とする。count を codePoints の要素数とする。count > 2 の場合、tens を codePoints [count - 2] とする。ones を codePoints [count - 1] とする。fv を CodePointsToString (« tens , ones ») とする。f が "narrow" , "short" , "long" の場合、fv を v を f 形式で表す文字列値とする(値は実装とロケール・カレンダー依存。p が "month" の場合は format .[[day]] の有無にも依存。ローカライズ表現がない場合は
v の文字列値を使う)。レコード { [[Type]] : p , [[Value]] : fv } を result に追加する。 p が "ampm" の場合、v を tm .[[Hour]] とする。v > 11 の場合、fv を ILD 文字列値("post meridiem" )とする。それ以外の場合、 fv を ILD 文字列値("ante meridiem" )とする。レコード { [[Type]] : "dayPeriod" , [[Value]] : fv } を result に追加する。 p が "relatedYear" の場合、v を tm .[[RelatedYear]] とする。fv を FormatNumeric (nf , v ) とする。レコード { [[Type]] : "relatedYear" , [[Value]] : fv } を result に追加する。 p が "yearName" の場合、v を tm .[[YearName]] とする。fv を ILD 文字列値(v )とする。レコード { [[Type]] : "yearName" , [[Value]] : fv } を result に追加する。 それ以外の場合、 unknown を実装・ロケール・数字体系依存の文字列(epochNanoseconds と p に基づく)とする。レコード { [[Type]] : "unknown" , [[Value]] : unknown } を result に追加する。 result を返す。
Note
実装は Common Locale Data Repository(
https://cldr.unicode.org/ )のロケール・カレンダー依存文字列を利用し、DateTimeFormat の
"short"
文字列には CLDR の
"abbreviated" 、
"long" 文字列には CLDR の
"wide" を使うことが推奨されます。
11.5.6 PartitionDateTimePattern ( dateTimeFormat , x )
The abstract operation PartitionDateTimePattern takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (数値) and returns 正常完了値としてレコードのリスト([[Type]] (文字列)、[[Value]] (文字列)フィールドを持つ)、または throw 完了値. 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 (数値) and returns 正常完了値として文字列、または throw 完了値. It performs the following steps when called:
parts を ? PartitionDateTimePattern (dateTimeFormat , x ) とする。result を空文字列とする。parts の各レコード { [[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 (数値) and returns 正常完了値として配列、または throw 完了値. It performs the following steps when called:
parts を ? PartitionDateTimePattern (dateTimeFormat , x ) とする。result を ! ArrayCreate (0) とする。n を 0 とする。parts の各レコード { [[Type]] , [[Value]] } part について、O を OrdinaryObjectCreate (%Object.prototype% ) とする。! CreateDataPropertyOrThrow (O , "type" , part .[[Type]] ) を実行する。 ! CreateDataPropertyOrThrow (O , "value" , part .[[Value]] ) を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), O ) を実行する。 n を 1 増やす。result を返す。
11.5.9 PartitionDateTimeRangePattern ( dateTimeFormat , x , y )
The abstract operation PartitionDateTimeRangePattern takes arguments dateTimeFormat (Intl.DateTimeFormat), x (数値), and y (数値) and returns 正常完了値としてレコードのリスト([[Type]] (文字列)、[[Value]] (文字列)、[[Source]] (文字列)フィールドを持つ)、または throw 完了値. 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 ) とする。tm1 を ToLocalTime (xEpochNanoseconds , dateTimeFormat .[[Calendar]] , dateTimeFormat .[[TimeZone]] ) とする。tm2 を 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 をそのフィールドとし、そうでなければ undefined とする。selectedRangePattern が undefined でなく rangePattern が undefined の場合、注: このフィールド以下の差異に対する範囲パターンがないため、以降のチェックは行わない。 checkMoreFields を false とする。fieldName が [[Default]] でなく relevantFieldsEqual が true かつ checkMoreFields が true の場合、selectedRangePattern を rangePattern に設定する。fieldName が [[AmPm]] の場合、tm1 .[[Hour]] < 12 の場合、v1 を "am" 、そうでなければ "pm" とする。 1. tm2 .[[Hour]] < 12 の場合、v2 を "am" 、そうでなければ
"pm" とする。 1. fieldName が [[DayPeriod]] の場合、 1. v1 を tm1 の day period を表す文字列値とする(値は実装とロケール依存)。 1. v2
を tm2 の day period を表す文字列値とする(値は実装とロケール依存)。 1. fieldName が [[FractionalSecondDigits]] の場合、 1. format が
[[fractionalSecondDigits]] フィールドを持つ場合、 1. fractionalSecondDigits を format .[[fractionalSecondDigits]] とする。それ以外の場合、 1. fractionalSecondDigits を 3 とする。 1. exp を fractionalSecondDigits - 3 とする。 1. v1 を
floor (tm1 .[[Millisecond]] × 10exp ) とする。 v2 を floor (tm2 .[[Millisecond]] × 10exp ) とする。それ以外の場合、 v1 を tm1 の fieldName フィールド値とする。v2 を tm2 の fieldName フィールド値とする。v1 ≠ v2 の場合、relevantFieldsEqual を false とする。relevantFieldsEqual が true の場合、collapsedResult を新しい空リストとする。resultParts を FormatDateTimePattern (dateTimeFormat , format , pattern , xEpochNanoseconds ) とする。resultParts の各レコード { [[Type]] , [[Value]] } r について、レコード { [[Type]] : r .[[Type]] , [[Value]] : r .[[Value]] , [[Source]] : "shared" } を collapsedResult
に追加する。 collapsedResult を返す。rangeResult を新しい空リストとする。selectedRangePattern が undefined の場合、selectedRangePattern を rangePatterns .[[Default]] に設定する。selectedRangePattern .[[PatternParts]] の各レコード { [[Pattern]] , [[Source]] } rangePatternPart について、pattern を rangePatternPart .[[Pattern]] とする。source を rangePatternPart .[[Source]] とする。source が "startRange" または "shared" の場合、z を xEpochNanoseconds とする。それ以外の場合、 z を yEpochNanoseconds とする。resultParts を FormatDateTimePattern (dateTimeFormat , selectedRangePattern , pattern , z ) とする。resultParts の各レコード { [[Type]] , [[Value]] } r について、レコード { [[Type]] : r .[[Type]] , [[Value]] : r .[[Value]] , [[Source]] : source } を rangeResult に追加する。 rangeResult を返す。
11.5.10 FormatDateTimeRange ( dateTimeFormat , x , y )
The abstract operation FormatDateTimeRange takes arguments dateTimeFormat (Intl.DateTimeFormat), x (数値), and y (数値) and returns 正常完了値として文字列、または throw 完了値. It performs the following steps when called:
parts を ? PartitionDateTimeRangePattern (dateTimeFormat , x , y ) とする。result を空文字列とする。parts の各レコード { [[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 (数値), and y (数値) and returns 正常完了値として配列、または throw 完了値. It performs the following steps when called:
parts を ? PartitionDateTimeRangePattern (dateTimeFormat , x , y ) とする。result を ! ArrayCreate (0) とする。n を 0 とする。parts の各レコード { [[Type]] , [[Value]] , [[Source]] } part について、O を OrdinaryObjectCreate (%Object.prototype% ) とする。! CreateDataPropertyOrThrow (O , "type" , part .[[Type]] ) を実行する。 ! CreateDataPropertyOrThrow (O , "value" , part .[[Value]] ) を実行する。 ! CreateDataPropertyOrThrow (O , "source" , part .[[Source]] ) を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), O ) を実行する。 n を 1 増やす。result を返す。
11.5.12 ToLocalTime ( epochNs , calendar , timeZoneIdentifier )
The implementation-defined abstract operation ToLocalTime takes arguments epochNs (BigInt), calendar (文字列), and timeZoneIdentifier (文字列) and returns ToLocalTime Record . It performs the following steps when called:
IsTimeZoneOffsetString (timeZoneIdentifier ) が true の場合、offsetNs を ParseTimeZoneOffsetString (timeZoneIdentifier ) とする。それ以外の場合、 アサート: 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 レコード
各 ToLocalTime Record は Table 17 で定義されたフィールドを持ちます。
Table 17: ToLocalTime が返すレコード
11.5.14 UnwrapDateTimeFormat ( dtf )
The abstract operation UnwrapDateTimeFormat takes argument dtf (ECMAScript 言語値) and returns 正常完了値として ECMAScript 言語値、または throw 完了値. It performs the following steps when called:
dtf がオブジェクトでない場合、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]] に設定する。r を 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" », undefined ) の結果とする。type が undefined なら、TypeError 例外を投げる。displayNames .[[Type]] に type を設定する。fallback を GetOption (options , "fallback" , string , « "code" , "none" », "code" ) の結果とする。displayNames .[[Fallback]] に fallback を設定する。displayNames .[[Locale]] に r .[[Locale]] を設定する。resolvedLocaleData を r .[[LocaleData]] に設定する。types を resolvedLocaleData .[[types]] に設定する。アサート: types は Record である (12.2.3 を参照)。 languageDisplay を GetOption (options , "languageDisplay" , string , « "dialect" , "standard" »,
"dialect" ) の結果とする。typeFields を types .[[<type >]] に設定する。アサート: typeFields は Record である (12.2.3 を参照)。 type が "language" ならdisplayNames .[[LanguageDisplay]] に languageDisplay を設定する。typeFields を typeFields .[[<languageDisplay >]] に設定する。アサート: typeFields は Record である (12.2.3 を参照)。 styleFields を typeFields .[[<style >]] に設定する。アサート: 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 であり、有効な language display の名前 ("dialect" , "standard" ) のフィールドを持たなければならない。
表示名タイプ "language" の下の language display フィールドは、表示名スタイル ("narrow" , "short" , "long" ) の名前のフィールドを持つ
Record を含むべきである。
"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 インスタンスオブジェクトの他の内部スロットを持たない。
[[Prototype]] 内部スロットの値は %Object.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 の各行(ヘッダー行を除く)について、テーブル順に次を行うp を現在の行の Property 値とする。v を displayNames の内部スロットで、現在の行の Internal Slot 名の値とする。v が undefined でない場合! CreateDataPropertyOrThrow (options , p , v ) を実行する。 options を返す。
Table 18: DisplayNames インスタンスの解決済みオプション
内部スロット
プロパティ
[[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% プロパティの初期値は文字列値 "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]] は、フォーマットに使用されるロケールの言語タグ を持つ文字列値である。
[[Style]] は、表示名スタイル ("narrow" , "short" , "long" ) のいずれかの文字列値で、使用される表示名スタイルを識別する。
[[Type]] は、要求された表示名のタイプ ("language" , "region" , "script" , "currency" , "calendar" , "dateTimeField" )
のいずれかの文字列値である。
[[Fallback]] は、システムが要求された表示名を持たない場合のフォールバック返却 ("code" , "none" ) のいずれかの文字列値である。
[[LanguageDisplay]] は、言語表示種別 ("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 (文字列) and code (文字列) and returns 文字列を含む通常の完了または throw 完了. 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 例外を投げる。アサート: 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 を返す。アサート: type は "currency" である。 IsWellFormedCurrencyCode (code ) の結果が false なら、RangeError 例外を投げる。code の ASCII 大文字化を返す。
12.5.2 IsValidDateTimeFieldCode ( field )
The abstract operation IsValidDateTimeFieldCode takes argument field (文字列) and returns ブール値. It performs the following steps when called:
field が Table 19 の Code 列に記載されている場合、true を返す。false を返す。
Table 19: DisplayNames の日付時刻フィールドのコード
コード
説明
"era"
暦やユリウス暦などの時代を示すフィールド。例: AD や BC。
"year"
時代内の年を示すフィールド。
"quarter"
四半期を示すフィールド。例: Q2、2nd quarter など。
"month"
月を示すフィールド。例: Sep、September など。
"weekOfYear"
年内の週番号を示すフィールド。
"weekday"
曜日を示すフィールド。例: Tue、Tuesday など。
"day"
月内の日を示すフィールド。
"dayPeriod"
日中の区分を示すフィールド。am、pm、noon、evening など。
"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]] に設定する。r を optionsResolution .[[ResolvedLocale]] に設定する。durationFormat .[[Locale]] を r .[[Locale]] に設定する。resolvedLocaleData を r .[[LocaleData]] に設定する。digitalFormat を resolvedLocaleData .[[DigitalFormat]] に設定する。durationFormat .[[HourMinuteSeparator]] を digitalFormat .[[HourMinuteSeparator]] に設定する。durationFormat .[[MinuteSecondSeparator]] を digitalFormat .[[MinuteSecondSeparator]] に設定する。durationFormat .[[NumberingSystem]] を r .[[nu]] に設定する。style を ? GetOption (options , "style" , string , « "long" , "short" , "narrow" , "digital" »,
"short" ) に設定する。durationFormat .[[Style]] を style に設定する。prevStyle を空文字列に設定する。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 インスタンスの内部スロットとプロパティ名
Internal Slot
Unit
Styles
Digital Default
[[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]] は、そのロケールで利用可能な各番号体系に対応するキーを持つ Record
でなければならない。それぞれのキーに対応する値は次のフィールドを含む Record でなければならない:
[[HourMinuteSeparator]] は、style "numeric" または "2-digit"
を使用する場合、そのロケールと番号体系の組み合わせに適切な時間と分の間の区切り文字列でなければならない。
[[MinuteSecondSeparator]] は、style "numeric" または "2-digit"
を使用する場合、そのロケールと番号体系の組み合わせに適切な分と秒の間の区切り文字列でなければならない。
[[TwoDigitHours]] は、style "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
インスタンスオブジェクトの内部スロットを持たない。
[[Prototype]] 内部スロットの値は %Object.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 の各行(ヘッダー行を除く)について、表順で繰り返す:p を現在の行の Property 値とする。v を df の内部スロットで、現在の行の Internal Slot 名の値とする。v が undefined でない場合、現在の行に Conversion 値があれば conversion をその値とし、なければ empty とする。 conversion が number なら、v を 𝔽 (v ) に設定する。それ以外で conversion が empty でない場合、 Assert : conversion は style+display であり、v は Duration Unit Options Record である。NOTE: v .[[Style]] は p (複数形 Temporal 単位)というプロパティ名で表現され、v .[[Display]] は p に "Display"
を付加したプロパティ名で表現される。 style を v .[[Style]] とする。style が "fractional" なら、Assert : IsFractionalSecondUnitName (p ) は true である。style を "numeric" に設定する。! CreateDataPropertyOrThrow (options , p , style ) を実行する。 p を p と "Display" の連結文字列に設定する。v を v .[[Display]] に設定する。! CreateDataPropertyOrThrow (options , p , v ) を実行する。 options を返す。
Table 21: DurationFormat インスタンスの resolvedOptions プロパティ
Internal Slot
Property
Conversion
[[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 を空文字列とする。各 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 とする。各 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% プロパティの初期値は文字列値 "Intl.DurationFormat" である。
このプロパティの属性は { [[Writable]] : false , [[Enumerable]] : false , [[Configurable]] : true } である。
13.4 Intl.DurationFormat インスタンスのプロパティ
Intl.DurationFormat インスタンスは %Intl.DurationFormat.prototype% からプロパティを継承する。
Intl.DurationFormat インスタンスは [[InitializedDurationFormat]] 内部スロットを持つ。
Intl.DurationFormat インスタンスは Intl.DurationFormat コンストラクター
で計算される複数の内部スロットも持つ:
[[Locale]] は、フォーマットに使用されるロケールの言語タグ を持つ文字列値である。
[[NumberingSystem]] は、フォーマットに使用される Unicode Number System Identifier
を表す文字列値である。
[[Style]] は、使用される期間フォーマットスタイルを示す "long" , "short" , "narrow" , "digital" のいずれかの文字列値である。
[[YearsOptions]] は、Duration Record の [[Years]] フィールドのフォーマットスタイルと表示条件を示す Duration Unit Options Record である。
[[MonthsOptions]] は、Duration Record の [[Months]] フィールドのフォーマットスタイルと表示条件を示す Duration Unit Options Record である。
[[WeeksOptions]] は、Duration Record の [[Weeks]] フィールドのフォーマットスタイルと表示条件を示す Duration Unit Options Record である。
[[DaysOptions]] は、Duration Record の [[Days]] フィールドのフォーマットスタイルと表示条件を示す Duration Unit Options Record である。
[[HoursOptions]] は、Duration Record の [[Hours]] フィールドのフォーマットスタイルと表示条件を示す Duration Unit Options Record である。
[[MinutesOptions]] は、Duration Record の [[Minutes]] フィールドのフォーマットスタイルと表示条件を示す Duration Unit Options Record である。
[[SecondsOptions]] は、Duration Record の [[Seconds]] フィールドのフォーマットスタイルと表示条件を示す Duration Unit Options Record である。
[[MillisecondsOptions]] は、Duration Record の [[Milliseconds]] フィールドのフォーマットスタイルと表示条件を示す Duration Unit Options
Record である。
[[MicrosecondsOptions]] は、Duration Record の [[Microseconds]] フィールドのフォーマットスタイルと表示条件を示す Duration Unit Options
Record である。
[[NanosecondsOptions]] は、Duration Record の [[Nanoseconds]] フィールドのフォーマットスタイルと表示条件を示す Duration Unit Options
Record である。
[[HourMinuteSeparator]] は、両方のフィールドが表示され、両方が数値スタイルでフォーマットされる場合に、時間と分の間に使用される区切り文字列値である。
[[MinuteSecondSeparator]] は、両方のフィールドが表示され、両方が数値スタイルでフォーマットされる場合に、分と秒の間に使用される区切り文字列値である。
[[FractionalDigits]] は、undefined または数値スタイルで使用される小数桁数を示す非負整数である。
13.5 DurationFormat オブジェクトの抽象演算
13.5.1 Duration レコード
Duration レコード は、期間を表すために使用される Record 値である。
Duration レコードは Table 22 に記載されたフィールドを持つ。
Table 22: Duration レコード のフィールド
Field
意味
[[Years]]
期間内の年数。
[[Months]]
期間内の月数。
[[Weeks]]
期間内の週数。
[[Days]]
期間内の日数。
[[Hours]]
期間内の時間数。
[[Minutes]]
期間内の分数。
[[Seconds]]
期間内の秒数。
[[Milliseconds]]
期間内のミリ秒数。
[[Microseconds]]
期間内のマイクロ秒数。
[[Nanoseconds]]
期間内のナノ秒数。
13.5.2 ToIntegerIfIntegral ( argument )
The abstract operation ToIntegerIfIntegral takes argument argument (ECMAScript 言語値) and returns 正常完了時は整数、または throw 完了. It performs the following steps when called:
number を ? ToNumber (argument ) とする。number が整数の Number でなければ、RangeError 例外を投げる。ℝ (number ) を返す。
13.5.3 ToDurationRecord ( input )
The abstract operation ToDurationRecord takes argument input (ECMAScript 言語値) and returns 正常完了時は Duration レコード 、または throw 完了. It performs the following steps when called:
input がオブジェクトでなければ、input が文字列なら、RangeError 例外を投げる。TypeError 例外を投げる。各フィールドを 0 に設定した新しい Duration レコード result を作成する。 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 レコード ) and returns -1, 0, または 1. 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. 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 とする。注: 上記のステップは浮動小数点演算で直接実装できない。milliseconds , microseconds , nanoseconds が安全な整数の場合、10-3 ,
10-6 , 10-9 の乗算は不正確になる可能性がある。C++ では十分なビット数の std::remquo() で実装できる。文字列操作でも正確な結果が得られる。 abs (normalizedSeconds ) ≥ 253 なら false を返す。true を返す。
13.5.6 GetDurationUnitOptions ( unit , options , baseStyle , stylesList , digitalBase , prevStyle , twoDigitHours )
The abstract operation GetDurationUnitOptions takes arguments unit (文字列), options (オブジェクト), baseStyle (文字列), stylesList (文字列のリスト), digitalBase (文字列), prevStyle (文字列), and twoDigitHours (Boolean) and returns 正常完了時は Duration Unit Options レコード 、または throw 完了. 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 レコード { [[Style]] : style , [[Display]] : display } を返す。
13.5.6.1 Duration Unit Options レコード
各 Duration Unit Options レコード は Table 23 で定義されたフィールドを持つ。
Table 23: Duration Unit Options レコード
フィールド名
値の型
[[Style]]
Table 20 の Styles 列の文字列
[[Display]]
"auto" または "always"
13.5.6.2 ValidateDurationUnitStyle ( unit , style , display , prevStyle )
The abstract operation ValidateDurationUnitStyle takes arguments unit (文字列), style (文字列), display (文字列), and prevStyle (文字列) 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 オブジェクト) and duration (Duration レコード ) and returns 数学的値. It performs the following steps when called:
result を 0 に設定する。exponent を 3 に設定する。Table 24 の各行(ヘッダー行を除く)について、表順で繰り返す:unitOptions を durationFormat の内部スロットで、現在の行の Internal Slot 名の値とする。unitOptions .[[Style]] が "fractional" なら、unit を現在の行の Unit 値とする。Assert : IsFractionalSecondUnitName (unit ) は true である。value を duration のフィールドで、現在の行の Value Field 名の値とする。result を result + (value / 10exponent ) に設定する。exponent を exponent + 3 に設定する。result を返す。
13.5.8 NextUnitFractional ( durationFormat , unit )
The abstract operation NextUnitFractional takes arguments durationFormat (DurationFormat オブジェクト) and unit (文字列) and returns Boolean. 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 レコードのリスト. It performs the following steps when called:
result を新しい空のリストとする。hoursStyle を durationFormat .[[HoursOptions]] .[[Style]] とする。Assert : hoursStyle は "numeric" または "2-digit" である。nfOpts を OrdinaryObjectCreate (null ) とする。numberingSystem を durationFormat .[[NumberingSystem]] とする。! CreateDataPropertyOrThrow (nfOpts , "numberingSystem" , numberingSystem ) を実行する。 hoursStyle が "2-digit" なら、! CreateDataPropertyOrThrow (nfOpts , "minimumIntegerDigits" , 2 𝔽 ) を実行する。 signDisplayed が false なら、! CreateDataPropertyOrThrow (nfOpts , "signDisplay" , "never" ) を実行する。 ! CreateDataPropertyOrThrow (nfOpts , "useGrouping" , false ) を実行する。 nf を ! Construct (%Intl.NumberFormat% , « durationFormat .[[Locale]] , nfOpts ») とする。hoursParts を PartitionNumberPattern (nf , hoursValue ) とする。各レコード { [[Type]] , [[Value]] } part について、 レコード { [[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 オブジェクト), minutesValue (整数), hoursDisplayed (Boolean), and signDisplayed (Boolean) and returns レコードのリスト. It performs the following steps when called:
result を新しい空のリストとする。hoursDisplayed が true なら、separator を durationFormat .[[HourMinuteSeparator]] とする。レコード { [[Type]] : "literal" , [[Value]] : separator , [[Unit]] : empty } を result に追加する。 minutesStyle を durationFormat .[[MinutesOptions]] .[[Style]] とする。Assert : minutesStyle は "numeric" または "2-digit" である。nfOpts を OrdinaryObjectCreate (null ) とする。numberingSystem を durationFormat .[[NumberingSystem]] とする。! CreateDataPropertyOrThrow (nfOpts , "numberingSystem" , numberingSystem ) を実行する。 minutesStyle が "2-digit" なら、! CreateDataPropertyOrThrow (nfOpts , "minimumIntegerDigits" , 2 𝔽 ) を実行する。 signDisplayed が false なら、! CreateDataPropertyOrThrow (nfOpts , "signDisplay" , "never" ) を実行する。 ! CreateDataPropertyOrThrow (nfOpts , "useGrouping" , false ) を実行する。 nf を ! Construct (%Intl.NumberFormat% , « durationFormat .[[Locale]] , nfOpts ») とする。minutesParts を PartitionNumberPattern (nf , minutesValue ) とする。各レコード { [[Type]] , [[Value]] } part について、 レコード { [[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 オブジェクト), secondsValue (数学的値), minutesDisplayed (Boolean), and signDisplayed (Boolean) and returns レコードのリスト. It performs the following steps when called:
result を新しい空のリストとする。minutesDisplayed が true なら、separator を durationFormat .[[MinuteSecondSeparator]] とする。レコード { [[Type]] : "literal" , [[Value]] : separator , [[Unit]] : empty } を result に追加する。 secondsStyle を durationFormat .[[SecondsOptions]] .[[Style]] とする。Assert : secondsStyle は "numeric" または "2-digit" である。nfOpts を OrdinaryObjectCreate (null ) とする。numberingSystem を durationFormat .[[NumberingSystem]] とする。! CreateDataPropertyOrThrow (nfOpts , "numberingSystem" , numberingSystem ) を実行する。 secondsStyle が "2-digit" なら、! CreateDataPropertyOrThrow (nfOpts , "minimumIntegerDigits" , 2 𝔽 ) を実行する。 signDisplayed が false なら、! CreateDataPropertyOrThrow (nfOpts , "signDisplay" , "never" ) を実行する。 ! CreateDataPropertyOrThrow (nfOpts , "useGrouping" , false ) を実行する。 fractionDigits を durationFormat .[[FractionalDigits]] とする。fractionDigits が undefined なら、! CreateDataPropertyOrThrow (nfOpts , "maximumFractionDigits" , 9 𝔽 ) を実行する。 ! CreateDataPropertyOrThrow (nfOpts , "minimumFractionDigits" , +0 𝔽 ) を実行する。 それ以外の場合、 ! CreateDataPropertyOrThrow (nfOpts , "maximumFractionDigits" , fractionDigits ) を実行する。 ! CreateDataPropertyOrThrow (nfOpts , "minimumFractionDigits" , fractionDigits ) を実行する。 ! CreateDataPropertyOrThrow (nfOpts , "roundingMode" , "trunc" ) を実行する。 nf を ! Construct (%Intl.NumberFormat% , « durationFormat .[[Locale]] , nfOpts ») とする。secondsParts を PartitionNumberPattern (nf , secondsValue ) とする。各レコード { [[Type]] , [[Value]] } part について、 レコード { [[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 オブジェクト), duration (Duration レコード ), firstNumericUnit (文字列), and signDisplayed (Boolean) and returns レコードのリスト. It performs the following steps when called:
Assert : firstNumericUnit は "hours" , "minutes" , または "seconds" である。numericPartsList を新しい空のリストとする。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" または "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 (文字列) 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 オブジェクト) and partitionedPartsList (レコードのリストのリスト) and returns リスト. It performs the following steps when called:
lfOpts を OrdinaryObjectCreate (null ) とする。! CreateDataPropertyOrThrow (lfOpts , "type" , "unit" ) を実行する。 listStyle を durationFormat .[[Style]] とする。listStyle が "digital" なら、listStyle を "short" に設定する。! CreateDataPropertyOrThrow (lfOpts , "style" , listStyle ) を実行する。 lf を ! Construct (%Intl.ListFormat% , « durationFormat .[[Locale]] , lfOpts ») とする。strings を新しい空のリストとする。partitionedPartsList の各要素 parts について、string を空文字列とする。parts 内の各レコード { [[Type]] , [[Value]] , [[Unit]] } part について、string を string と part .[[Value]] の連結文字列に設定する。strings に string を追加する。formattedPartsList を CreatePartsFromList (lf , strings ) とする。partitionedPartsIndex を 0 とする。partitionedLength を partitionedPartsList の要素数とする。flattenedPartsList を新しい空のリストとする。formattedPartsList の各レコード { [[Type]] , [[Value]] } listPart について、listPart .[[Type]] が "element" なら、Assert : partitionedPartsIndex < partitionedLength である。parts を partitionedPartsList [partitionedPartsIndex ] とする。parts 内の各レコード { [[Type]] , [[Value]] , [[Unit]] } part について、flattenedPartsList に part を追加する。partitionedPartsIndex を partitionedPartsIndex + 1 に設定する。それ以外の場合、 Assert : listPart .[[Type]] は "literal" である。レコード { [[Type]] : "literal" , [[Value]] : listPart .[[Value]] , [[Unit]] : empty } を flattenedPartsList
に追加する。 flattenedPartsList を返す。
13.5.15 PartitionDurationFormatPattern ( durationFormat , duration )
The abstract operation PartitionDurationFormatPattern takes arguments durationFormat (a DurationFormat) and duration (a Duration Record ) and returns a List . It creates the corresponding parts for duration according to the effective locale and the formatting
options of durationFormat . It performs the following steps when called:
Let result be a new empty List . Let signDisplayed be true . Let numericUnitFound be false . While numericUnitFound is false , repeat for each row in Table 24 in table order, except the header row: Let value be the value of duration 's field whose name is the Value Field value of the current row. Let unitOptions be the value of durationFormat 's internal slot whose name is the Internal Slot value of
the current row. Let style be unitOptions .[[Style]] . Let display be unitOptions .[[Display]] . Let unit be the Unit value of the current row. Let numberFormatUnit be the NumberFormat Unit value of the current row. If style is "numeric" or "2-digit" , then Let numericPartsList be FormatNumericUnits (durationFormat , duration , unit , signDisplayed ). If numericPartsList is not empty, append numericPartsList to result . Set numericUnitFound to true . Else, Let nfOpts be OrdinaryObjectCreate (null ). If NextUnitFractional (durationFormat , unit ) is true , then Set value to value + ComputeFractionalDigits (durationFormat , duration ). Let fractionDigits be durationFormat .[[FractionalDigits]] . If fractionDigits is undefined , then Perform ! CreateDataPropertyOrThrow (nfOpts , "maximumFractionDigits" , 9 𝔽 ). Perform ! CreateDataPropertyOrThrow (nfOpts , "minimumFractionDigits" , +0 𝔽 ). Else, Perform ! CreateDataPropertyOrThrow (nfOpts , "maximumFractionDigits" , fractionDigits ). Perform ! CreateDataPropertyOrThrow (nfOpts , "minimumFractionDigits" , fractionDigits ). Perform ! CreateDataPropertyOrThrow (nfOpts , "roundingMode" , "trunc" ). Set numericUnitFound to true . If display is "always" or value is not 0, then Perform ! CreateDataPropertyOrThrow (nfOpts , "numberingSystem" , durationFormat .[[NumberingSystem]] ). If signDisplayed is true , then Set signDisplayed to false . If value is 0 and DurationSign (duration ) is -1, set value to negative-zero . Else, Perform ! CreateDataPropertyOrThrow (nfOpts , "signDisplay" , "never" ). Perform ! CreateDataPropertyOrThrow (nfOpts , "style" , "unit" ). Perform ! CreateDataPropertyOrThrow (nfOpts , "unit" , numberFormatUnit ). Perform ! CreateDataPropertyOrThrow (nfOpts , "unitDisplay" , style ). Let nf be ! Construct (%Intl.NumberFormat% , « durationFormat .[[Locale]] , nfOpts »). Let parts be PartitionNumberPattern (nf , value ). Let list be a new empty List . For each Record { [[Type]] , [[Value]] } part of parts , do Append the Record { [[Type]] : part .[[Type]] , [[Value]] : part .[[Value]] , [[Unit]] : numberFormatUnit } to
list . Append list to result . Return ListFormatParts (durationFormat , result ).
Table 24: DurationFormat instance internal slots and properties relevant to
PartitionDurationFormatPattern
Value Field
Internal Slot
Unit
NumberFormat Unit
[[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]] に設定する。r を optionsResolution .[[ResolvedLocale]] に設定する。listFormat .[[Locale]] を r .[[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 を r .[[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]] 内部スロットの値は 9.1 で記載された制約および次の追加制約内で実装依存である。各ロケール値
locale について %Intl.ListFormat% .[[AvailableLocales]] 内:
[[LocaleData]] .[[<locale >]] は Record であり、3つのフィールド [[conjunction]] , [[disjunction]] , [[unit]]
を持つ。それぞれは3つの書式スタイル名 [[long]] , [[short]] , [[narrow]] を持つ Record である。
各フィールドは ListFormat テンプレートセット とみなされ、LDML List Format Rules で指定されたテンプレート文字列を持つ [[Pair]] , [[Start]] ,
[[Middle]] , [[End]] フィールド名の Record のリストである。各テンプレート文字列は "{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 インスタンスオブジェクトの内部スロットを持たない。
[[Prototype]] 内部スロットの値は %Object.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 の各行(ヘッダー行を除く)について、テーブル順に:p を現在の行の Property 値とする。v を lf の内部スロットで、現在の行の Internal Slot 名の値とする。Assert : v は undefined ではない。! CreateDataPropertyOrThrow (options , p , v ) を実行する。 options を返す。
Table 25: ListFormat インスタンスの解決済みオプション
内部スロット
プロパティ
[[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% プロパティの初期値は文字列値 "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]] はリスト書式スタイルのローカライズに使用されるロケールの言語タグ の文字列値である。
[[Type]] は "conjunction" , "disjunction" , "unit" のいずれかの文字列値で、使用されるリストタイプを識別する。
[[Style]] は "long" , "short" , "narrow" のいずれかの文字列値で、使用されるリスト書式スタイルを識別する。
[[Templates]] は ListFormat テンプレートセット である。
14.5 ListFormat オブジェクトの抽象操作
14.5.1 DeconstructPattern ( pattern , placeables )
The abstract operation DeconstructPattern takes arguments pattern (パターン文字列 ) and placeables (Record ) and returns リスト. It performs the following steps when called:
patternParts を PartitionPattern (pattern ) とする。result を新しい空リストとする。各 Record { [[Type]] , [[Value]] } patternPart について: part を patternPart .[[Type]] とする。part が "literal" の場合、Record { [[Type]] : "literal" , [[Value]] : patternPart .[[Value]] } を result に追加する。それ以外の場合、 Assert : placeables はフィールド [[<part >]] を持つ。subst を placeables .[[<part >]] とする。subst がリストの場合、各要素 s について: s を result に追加する。それ以外の場合、 subst を result に追加する。result を返す。
14.5.2 CreatePartsFromList ( listFormat , list )
The abstract operation CreatePartsFromList takes arguments listFormat (Intl.ListFormat) and list (文字列のリスト) and returns フィールド [[Type]] ("element" または "literal" ) と [[Value]] (文字列)を持つ Record のリスト. It performs the following steps when called:
size を list の要素数とする。size が 0 の場合、新しい空リストを返す。 size が 2 の場合、n を listFormat .[[Templates]] 内のインデックスとし、listFormat .[[Locale]] , list [0], list [1] に基づく。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 .[[Templates]] 内の実装依存インデックスとし、listFormat .[[Locale]] , head , parts に基づく。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 を 1 減らす。parts を返す。
Note
複数テンプレートから選択するインデックス n により、スペイン語のように次の単語によって「y」または「e」が選択されるなど、接続詞が文脈に依存できる。
14.5.3 FormatList ( listFormat , list )
The abstract operation FormatList takes arguments listFormat (Intl.ListFormat) and list (文字列のリスト) and returns 文字列. It performs the following steps when called:
parts を CreatePartsFromList (listFormat , list ) とする。result を空文字列とする。各 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 (文字列のリスト) and returns 配列. It performs the following steps when called:
parts を CreatePartsFromList (listFormat , list ) とする。result を ! ArrayCreate (0) とする。n を 0 とする。各 Record { [[Type]] , [[Value]] } part について: O を OrdinaryObjectCreate (%Object.prototype% ) とする。! CreateDataPropertyOrThrow (O , "type" , part .[[Type]] ) を実行する。 ! CreateDataPropertyOrThrow (O , "value" , part .[[Value]] ) を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), O ) を実行する。 n を 1 増やす。result を返す。
14.5.5 StringListFromIterable ( iterable )
The abstract operation StringListFromIterable takes argument iterable (ECMAScript 言語値) and returns 正常完了の場合は文字列リスト、または throw 完了. It performs the following steps when called:
iterable が undefined の場合、新しい空リストを返す。 iteratorRecord を ? GetIterator (iterable , sync ) とする。list を新しい空リストとする。繰り返す: next を ? IteratorStepValue (iteratorRecord ) とする。next が done の場合、list を返す。next が文字列でない場合、error を新規作成した TypeError オブジェクトで ThrowCompletion とする。? IteratorClose (iteratorRecord , error ) を返す。 next を list に追加する。
Note
このアルゴリズムは文字列でない値に遭遇した場合例外を発生させる。なぜなら任意の値に対する明確なロケール対応の型変換がないためである。
15 ロケールオブジェクト
15.1 Intl.Locale コンストラクター
Intl.Locale コンストラクター:
15.1.1 Intl.Locale ( tag [ , options ] )
Intl.Locale 関数が引数 tag とオプションの引数 options で呼び出された場合、次の手順を実行する:
#### ECMARKDOWN PARSE FAILED #### 1. NewTarget が *undefined* なら、*TypeError* 例外を投げる。
1. _localeExtensionKeys_ を %Intl.Locale%.[[LocaleExtensionKeys]] とする。
1. _internalSlotsList_ を « [[InitializedLocale]], [[Locale]], [[Calendar]], [[Collation]], [[FirstDayOfWeek]],
[[HourCycle]], [[NumberingSystem]] » とする。
1. _localeExtensionKeys_ に *"kf"* が含まれている場合、
1. [[CaseFirst]] を _internalSlotsList_ に追加する。
1. _localeExtensionKeys_ に *"kn"* が含まれている場合、
1. [[Numeric]] を _internalSlotsList_ に追加する。
1. _locale_ を ? OrdinaryCreateFromConstructor(NewTarget, *"%Intl.Locale.prototype%"*, _internalSlotsList_) とする。
1. _tag_ が String でも Object でもない場合、*TypeError* 例外を投げる。
1. _tag_ が Object で、[[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. _r_ を MakeLocaleRecord(_tag_, _opt_, _localeExtensionKeys_) とする。
1. _locale_.[[Locale]] を _r_.[[locale]] とする。
1. _locale_.[[Calendar]] を _r_.[[ca]] とする。
1. _locale_.[[Collation]] を _r_.[[co]] とする。
1. _locale_.[[FirstDayOfWeek]] を _r_.[[fw]] とする。
1. _locale_.[[HourCycle]] を _r_.[[hc]] とする。
1. _localeExtensionKeys_ に *"kf"* が含まれている場合、
1. _locale_.[[CaseFirst]] を _r_.[[kf]] とする。
1. _localeExtensionKeys_ に *"kn"* が含まれている場合、
1. SameValue(_r_.[[kn]], *"true"*) が *true* または _r_.[[kn]] が空文字列の場合、
1. _locale_.[[Numeric]] を *true* とする。
1. それ以外の場合、
1. _locale_.[[Numeric]] を *false* とする。
1. _locale_.[[NumberingSystem]] を _r_.[[nu]] とする。
1. _locale_ を返す。
15.1.2 UpdateLanguageId ( tag , options )
The abstract operation UpdateLanguageId takes arguments tag (well-formed language tag) and options (オブジェクト) and returns 正常完了時は well-formed language tag、または throw completion . 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 が空文字列の場合、RangeError 例外を投げる。lowerVariants を variants の ASCII 小文字化とする。variantSubtags を StringSplitToList (lowerVariants , "-" ) とする。variantSubtags の各要素 variant について、variant が unicode_variant_subtag Unicode ロケール非終端記号にマッチしない場合、RangeError 例外を投げる。variantSubtags に重複要素がある場合、RangeError 例外を投げる。allExtensions を tag の baseName の後ろのサフィックスとする。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 (language tag), options (Record ), and localeExtensionKeys (String のリスト) and returns Record . 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 を新しい空リストとする。keywords を新しい空リストとする。result を新しい Record とする。localeExtensionKeys の各要素 key について、keywords に [[Key]] が key の要素が含まれている場合、entry を keywords の [[Key]] が key の要素とする。value を entry .[[Value]] とする。それ以外の場合、 entry を empty とする。value を undefined とする。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 を tag から Unicode ロケール拡張シーケンスを除いた 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" » の要素も含み、他の要素は含まないリストである。
15.3 Intl.Locale プロトタイプオブジェクトのプロパティ
Intl.Locale プロトタイプオブジェクト :
%Intl.Locale.prototype% である。
通常のオブジェクトである。
Intl.Locale インスタンスではなく、[[InitializedLocale]] 内部スロットや他の Intl.Locale インスタンスオブジェクトの内部スロットを持たない。
[[Prototype]] 内部スロットの値は %Object.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 を Add Likely Subtags アルゴリズムを
loc .[[Locale]] に適用した結果とする。エラーが発生した場合、maximal を loc .[[Locale]] とする。! Construct (%Intl.Locale% , maximal ) を返す。
15.3.10 Intl.Locale.prototype.minimize ( )
loc を this 値とする。? RequireInternalSlot (loc , [[InitializedLocale]] ) を実行する。 minimal を Remove Likely Subtags アルゴリズムを
loc .[[Locale]] に適用した結果とする。エラーが発生した場合、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% ) とする。wi を WeekInfoOfLocale (loc ) とする。! CreateDataPropertyOrThrow (info , "firstDay" , wi .[[FirstDay]] ) を実行する。 ! CreateDataPropertyOrThrow (info , "weekend" , CreateArrayFromList (wi .[[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% プロパティの初期値は文字列値 "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 ロケールオブジェクトの抽象操作
15.5.1 GetLocaleBaseName ( locale )
The abstract operation GetLocaleBaseName takes argument locale (文字列) and returns 文字列. It performs the following steps when called:
アサート: locale は unicode_locale_id Unicode ロケール非終端記号にマッチできる。 locale のうち、unicode_language_id Unicode ロケール非終端記号にマッチする最長の接頭辞を返す。
15.5.2 GetLocaleLanguage ( locale )
The abstract operation GetLocaleLanguage takes argument locale (文字列) and returns 文字列. It performs the following steps when called:
baseName を GetLocaleBaseName (locale ) とする。アサート: baseName の最初のサブタグ は unicode_language_subtag Unicode ロケール非終端記号にマッチできる。 baseName の最初のサブタグ を返す。
15.5.3 GetLocaleScript ( locale )
The abstract operation GetLocaleScript takes argument locale (文字列) and returns 文字列 または undefined . It performs the following steps when called:
baseName を GetLocaleBaseName (locale ) とする。アサート: baseName は unicode_script_subtag Unicode ロケール非終端記号にマッチするサブタグ を最大1つ含む。 baseName が unicode_script_subtag Unicode ロケール非終端記号にマッチするサブタグ を含む場合、そのサブタグ を返す。undefined を返す。
15.5.4 GetLocaleRegion ( locale )
The abstract operation GetLocaleRegion takes argument locale (文字列) and returns 文字列 または undefined . It performs the following steps when called:
baseName を GetLocaleBaseName (locale ) とする。注: unicode_region_subtag サブタグ は、初期の unicode_language_subtag サブタグ の直後、オプションで1つの
unicode_script_subtag サブタグ を挟んだ位置のみ有効である。その位置では、unicode_region_subtag
は他の有効なサブタグ と混同されることはない。すべての生成規則は互いに重複しない。 アサート: baseName の最初のサブタグ は unicode_language_subtag Unicode ロケール非終端記号にマッチできる。 baseNameTail を baseName の最初のサブタグ の後ろの接尾辞とする。アサート: baseNameTail は unicode_region_subtag Unicode ロケール非終端記号にマッチするサブタグ を最大1つ含む。 baseNameTail が unicode_region_subtag Unicode ロケール非終端記号にマッチするサブタグ を含む場合、そのサブタグ を返す。undefined を返す。
15.5.5 GetLocaleVariants ( locale )
The abstract operation GetLocaleVariants takes argument locale (文字列) and returns 文字列 または undefined . It performs the following steps when called:
baseName を GetLocaleBaseName (locale ) とする。注: baseName 内の "-" で始まる各サブタグ は unicode_script_subtag, unicode_region_subtag, または
unicode_variant_subtag のいずれかであるが、unicode_variant_subtag にマッチする
substring は、他の生成規則にマッチする任意の接頭辞よりも厳密に長い。 variants を、baseName のうち "-" で始まり、substring が
unicode_variant_subtag Unicode ロケール非終端記号にマッチする最長の接尾辞とする。該当する接尾辞がなければ undefined を返す。variants の1からの部分文字列を返す。
15.5.6 UnicodeExtensionValue ( locale , key )
The abstract operation UnicodeExtensionValue takes arguments locale (Unicode 正規化ロケール識別子) and key (文字列) and returns 文字列 または 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 文字列 または undefined . It performs the following steps when called:
subdivision を UnicodeExtensionValue (locale , key ) とする。subdivision が empty なら undefined を返す。subdivision が unicode_subdivision_id Unicode ロケール非終端記号にマッチできない場合、undefined を返す。region を subdivision のうち unicode_region_subtag Unicode ロケール非終端記号にマッチする最長の接頭辞とする。regionLocale を "und-" と region の連結とする。regionLocale を CanonicalizeUnicodeLocaleId (regionLocale ) とする。GetLocaleRegion (regionLocale ) を返す。
15.5.8 RegionPreference ( locale )
The abstract operation RegionPreference takes argument locale (Unicode 正規化ロケール識別子) and returns Record { [[Region]] : 文字列, [[RegionOverride]] : 文字列 または undefined }. It performs the following steps when called:
region を GetLocaleRegion (locale ) とする。region が undefined の場合、region を CanonicalUnicodeSubdivision (locale , "sd" ) とする。region が undefined の場合、maximal を Add Likely Subtags アルゴリズムを
locale に適用した結果とする。エラーが発生した場合、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 配列. 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 を、lookupRegion で日付や時刻のフォーマットに一般的に使われるカレンダー型の正規化形式 (6.9 )
のユニークなリストで、優先度順に降順ソートしたものとする。lookupRegion のカレンダー優先データが利用できない場合は空リストとする。list が空の場合、list を « "gregory" » とする。CreateArrayFromList (list ) を返す。
15.5.10 CollationsOfLocale ( loc )
The implementation-defined abstract operation CollationsOfLocale takes argument loc (Intl.Locale) and returns 配列. It performs the following steps when called:
loc .[[Collation]] が undefined でない場合、CreateArrayFromList (« loc .[[Collation]] ») を返す。language を GetLocaleLanguage (loc .[[Locale]] ) とする。language が "und" でない場合、r を LookupMatchingLocaleByPrefix (%Intl.Collator% .[[AvailableLocales]] , « loc .[[Locale]] ») とする。r が undefined でない場合、foundLocale を r .[[locale]] とする。それ以外の場合、 foundLocale を DefaultLocale () とする。foundLocaleData を %Intl.Collator% .[[SortLocaleData]] .[[<foundLocale >]] とする。list を foundLocaleData .[[co]] のコピーとする。アサート: 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 配列. 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 を、lookupRegion で日付や時刻のフォーマットに一般的に使われるユニークな時間周期識別子(小文字の文字列値で "h11" , "h12" , "h23" , "h24"
のいずれか)、優先度順に降順ソートしたリストとする。lookupRegion の時刻データが利用できない場合は空リストとする。list が空の場合、list を « "h23" » とする。CreateArrayFromList (list ) を返す。
15.5.12 NumberingSystemsOfLocale ( loc )
The implementation-defined abstract operation NumberingSystemsOfLocale takes argument loc (Intl.Locale) and returns 配列. It performs the following steps when called:
loc .[[NumberingSystem]] が undefined でない場合、CreateArrayFromList (« loc .[[NumberingSystem]] ») を返す。r を LookupMatchingLocaleByPrefix (%Intl.NumberFormat% .[[AvailableLocales]] , « loc .[[Locale]] ») とする。r が undefined でない場合、foundLocale を r .[[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 配列 または undefined . It performs the following steps when called:
region を GetLocaleRegion (loc .[[Locale]] ) とする。region が undefined の場合、undefined を返す。list を、region で一般的に使われるユニークな正規化タイムゾーン識別子(IANAタイムゾーンデータベースの正規Zone名の文字列値)のリストとする。region
で一般的に使われるタイムゾーンがない場合は空リストとする。リストはコードユニット順にソートする。CreateArrayFromList (list ) を返す。
15.5.14 TextDirectionOfLocale ( loc )
The implementation-defined abstract operation TextDirectionOfLocale takes argument loc (an Intl.Locale) and returns a String or undefined . It performs the following steps when called:
locale を loc .[[Locale]] とする。script を GetLocaleScript (locale ) とする。script が undefined の場合、maximal を Add Likely
Subtags アルゴリズムを locale に適用した結果とする。エラーが発生した場合、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 (a String) and returns a String. It performs the following steps when called:
Table 26 の各行(ヘッダー行を除く)について、表順に次を行う。現在の行の Weekday 値を w とする。 現在の行の String 値を s とする。 fw が w と等しい場合、s を返す。fw を返す。
Table 26: 曜日の文字列と値
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 (a String) and returns an integral Number or undefined . It performs the following steps when called:
Table 26 の各行(ヘッダー行を除く)について、表順に次を行う。現在の行の String 値を s とする。 現在の行の Value 値を v とする。 fw が s と等しい場合、v を返す。undefined を返す。
15.5.17 WeekInfoOfLocale ( loc )
The implementation-defined abstract operation WeekInfoOfLocale takes argument loc (an Intl.Locale) and returns a Record . It performs the following steps when called:
locale を loc .[[Locale]] とする。Table 27 で定義されたフィールドを持つ Record r を、locale に基づく値で作成する。fws を loc .[[FirstDayOfWeek]] とする。fw を WeekdayUValueToNumber (fws ) とする。fw が undefined でない場合、r .[[FirstDay]] を fw に設定する。r を返す。
Note
Table 27: WeekInfo レコードのフィールド
フィールド名
値
意味
[[FirstDay]]
ISO 8601 calendar day of week の曜日の 1 から始まる序数値。週の曜日の並びは月曜 1 𝔽 から日曜 7 𝔽
まで。
カレンダー上で「週の最初」とされる曜日。
[[Weekend]]
ISO 8601 calendar day of week の整数値 1 𝔽 (月曜)から 7 𝔽 (日曜)までの昇順リスト。
カレンダー上で「週末」とされる曜日の値のリスト。週末の日数や連続性はロケールによって異なる場合がある。
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]] に設定する。r を optionsResolution .[[ResolvedLocale]] に設定する。numberFormat .[[Locale]] を r .[[Locale]] に設定する。numberFormat .[[LocaleData]] を r .[[LocaleData]] に設定する。numberFormat .[[NumberingSystem]] を r .[[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" に設定する。注: 歴史的理由により、文字列 "true" と "false" は受け入れられ、デフォルト値に置き換えられる。 useGrouping を ? GetBooleanOrStringNumberFormatOption (options , "useGrouping" , « "min2" , "auto" ,
"always" , "true" , "false" », defaultUseGrouping ) に設定する。useGrouping が "true" または "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 (an Intl.NumberFormat), newTarget (an ECMAScript 言語値), and this (an 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 (オブジェクト), options (オブジェクト), mnfdDefault (整数), mxfdDefault (整数), and notation (文字列) and returns 正常完了値として unused を含むか、throw 完了値. 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" ) に設定する。注: SetNumberFormatDigitOptions で必要な全てのフィールドは options から読み取られた。残りの AO は options を解釈し、例外を投げる場合がある。 roundingIncrement が 1 でない場合、mxfdDefault を mnfdDefault に設定する。intlObj .[[RoundingIncrement]] を roundingIncrement に設定する。intlObj .[[RoundingMode]] を roundingMode に設定する。intlObj .[[TrailingZeroDisplay]] を trailingZeroDisplay に設定する。mnsd と mxsd が両方 undefined の場合、hasSd を false とし、そうでなければ true とする。mnfd と mxfd が両方 undefined の場合、hasFd を false とし、そうでなければ 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 (オブジェクト) and returns 正常完了値として unused を含むか、throw 完了値. 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 大文字化に設定する。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 は、通貨フォーマットの通貨を options オブジェクトの currency プロパティで指定し、通貨フォーマットスタイルを options オブジェクトの
currencySign プロパティで指定することを要求する。
[[LocaleData]] 内部スロットの値は 9.1 で記述された制約内で実装依存であり、以下の追加制約がある:
任意のロケールフィールドの "nu" フィールド値のリストは "native" , "traditio" , "finance" を含んではならない。
[[LocaleData]] .[[<locale >]] は全てのロケール値 locale に対して [[patterns]] フィールドを持たなければならない。このフィールドの値は Record
であり、4 つの数値フォーマットスタイル名 "decimal" , "percent" , "currency" , "unit" をフィールドとして持つ必要がある。
上記の "currency" と "unit" フィールドは、少なくとも "fallback" フィールドを持つ Record でなければならない。
"currency" は 6.3 に従う通貨コードに対応する追加フィールドを持つ場合がある。
各 "currency" フィールドは、currencyDisplay 値 "code" , "symbol" , "narrowSymbol" , "name" に対応するフィールドを持つ Record
でなければならない。
それぞれのフィールドは currencySign 値 "standard" または "accounting" に対応するフィールドを持つ Record でなければならない。"unit"
フィールド([[LocaleData]] .[[<locale >]] の)は 6.6
に対応するコア測定単位識別子に対応する追加フィールドを持つ場合がある。
各 "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" フィールド内の値は "{currencyCode}" ,
"{currencyPrefix}" , "{currencySuffix}" のいずれかを含む必要があり、"unit" フィールド内の値は "{unitPrefix}" または
"{unitSuffix}" のいずれかを含む必要がある。
パターン文字列 は、ECMA-262 6.1.4 で説明されている UTF-16
エンコードされたコードポイントの列として解釈した場合、Unicode 標準で指定された General Category "Number, decimal digit" のコードポイントを含んではならない。
[[LocaleData]] .[[<locale >]] は全てのロケール値 locale に対して [[notationSubPatterns]] フィールドも持たなければならない。このフィールドの値は
Record であり、[[scientific]] と [[compact]] の 2 つのフィールドを持つ必要がある。[[scientific]] フィールドは "{number}" ,
"{scientificSeparator}" , "{scientificExponent}" サブストリングを含む文字列値でなければならない。[[compact]] フィールドは "short" と
"long" の 2 つのフィールドを持つ Record でなければならない。各フィールドは実装がサポートする全ての離散的な compact notation の magnitude に対応する整数キーを持つ
Record でなければならない。各フィールドは "{number}" サブストリングを含む場合がある文字列値でなければならない。"short" から派生した文字列は "{compactSymbol}"
サブストリングを含み、"long" から派生した文字列は "{compactName}" サブストリングを含む必要がある。
Note 2
実装は
https://cldr.unicode.org/ で提供されている Common Locale Data Repository
のロケールデータを使用することが推奨される。
16.3 Intl.NumberFormat プロトタイプオブジェクトのプロパティ
Intl.NumberFormat プロトタイプオブジェクト :
%Intl.NumberFormat.prototype% である。
通常のオブジェクトである。
Intl.NumberFormat インスタンスではなく、[[InitializedNumberFormat]] 内部スロットや Intl.NumberFormat インスタンスオブジェクトの他の内部スロットを持たない。
[[Prototype]] 内部スロットの値は %Object.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 の各行(ヘッダー行を除く)について、テーブル順に、現在の行の Property 値を p に設定する。 現在の行の Internal Slot 名の内部スロット値を v に設定する。 v が undefined でない場合、現在の行に Conversion 値がある場合、 現在の行の Conversion 値が number であることをアサートする。 v を 𝔽 (v ) に設定する。! CreateDataPropertyOrThrow (options , p , v ) を実行する。 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 の場合、F を Number Format Functions (16.5.2 )
で定義された新しい組み込み関数オブジェクトとする。F .[[NumberFormat]] を nf に設定する。nf .[[BoundFormat]] を F に設定する。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% プロパティの初期値は文字列値 "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]] はフォーマットに使用されるロケールの言語タグ を持つ文字列値である。
[[LocaleData]] は実装がフォーマットに利用可能なデータを表す Record であり、[[Locale]] の値またはその接頭辞に関連付けられた
%Intl.NumberFormat% .[[LocaleData]] のエントリの値である。
[[NumberingSystem]] はフォーマットに使用される Unicode Number System Identifier
を表す文字列値である。
[[Style]] は "decimal" , "currency" , "percent" , "unit" のいずれかの文字列値であり、測定される量の種類を識別する。
[[Currency]] は "currency" 単位タイプでフォーマットする場合に使用する通貨コードを持つ文字列値である。[[Style]] が "currency" の場合のみ使用される。
[[CurrencyDisplay]] は "code" , "symbol" , "narrowSymbol" , "name" のいずれかの文字列値であり、"currency"
スタイルでフォーマットする場合に通貨を ISO 4217 アルファベット通貨コード、ローカライズされた通貨記号、またはローカライズされた通貨名として表示するかを指定する。[[Style]] が "currency"
の場合のみ使用される。
[[CurrencySign]] は "standard" または "accounting"
のいずれかの文字列値であり、負の数値を会計形式(しばしば括弧で示される)で表示するかどうかを指定する。[[Style]] が "currency" かつ [[SignDisplay]] が "never"
でない場合のみ使用される。
[[Unit]] はコア単位識別子 である。[[Style]] が "unit" の場合のみ使用される。
[[UnitDisplay]] は "short" , "narrow" , "long" のいずれかの文字列値であり、"unit"
スタイルでフォーマットする場合に単位を記号、狭い記号、またはローカライズされた長い名前として表示するかを指定する。[[Style]] が "unit" の場合のみ使用される。
[[MinimumIntegerDigits]] は使用する最小整数桁数を示す非負整数である。必要に応じて先頭にゼロが追加される。
[[MinimumFractionDigits]] および [[MaximumFractionDigits]]
は使用する最小および最大小数桁数を示す非負整数である。必要に応じて数値は丸められたり末尾にゼロが追加されたりする。これらのプロパティは [[RoundingType]] が fraction-digits ,
more-precision , less-precision の場合のみ使用される。
[[MinimumSignificantDigits]] および [[MaximumSignificantDigits]]
は表示する最小および最大有効桁数を示す正の整数である。存在する場合、フォーマッターは指定された有効桁数を表示するために必要な小数桁数を使用する。これらのプロパティは [[RoundingType]] が
significant-digits , more-precision , less-precision の場合のみ使用される。
[[UseGrouping]] はグループ区切り記号を使用する条件を示す Boolean または文字列値である。グループ区切り記号の位置や表示するかどうかは実装依存である。"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]] は "auto" , "morePrecision" , "lessPrecision" のいずれかの文字列値であり、16.3.2 で [[RoundingType]] を有効な
"roundingPriority" オプションに戻すためだけに使用される。
[[Notation]] は "standard" , "scientific" , "engineering" , "compact"
のいずれかの文字列値であり、フォーマットされた数値をスケーリングせずに表示するか、科学記法で10のべき乗にスケーリングして表示するか、エンジニアリング記法で千単位にスケーリングして表示するか、またはロケール依存のコンパクト記法でスケーリングして表示するかを指定する。
[[CompactDisplay]] は "short" または "long" のいずれかの文字列値であり、"compact"
記法でフォーマットする場合に短縮形("5K")または長形("5千")で表示するかを指定する。[[Notation]] が "compact" の場合のみ使用される。
[[SignDisplay]] は "auto" , "always" , "never" , "exceptZero" , "negative"
のいずれかの文字列値であり、符号をいつ含めるかを指定する("auto"
以外のオプションはそれぞれ常に、決して、ゼロ以外の場合のみ、またはゼロ以外の負の数値の場合のみ符号を含める)。科学記法では、このスロットは仮数の符号表示に影響するが指数には影響しない。
[[RoundingIncrement]] は10, 100, 1000, 10000を等分する整数であり、丸めの増分を示す。例えば [[MaximumFractionDigits]] が2で
[[RoundingIncrement]] が5の場合、フォーマットされた数値は最も近い0.05(「ニッケル丸め」)に丸められる。
[[RoundingMode]] は 丸めモード であり、Table 29 の Identifier 列の文字列値のいずれかである。
[[TrailingZeroDisplay]] は "auto" または "stripIfInteger"
のいずれかの文字列値であり、フォーマットされた数値が整数(すなわち非ゼロの小数桁を持たない)である場合に末尾のゼロを削除するかどうかを示す。
Table 29: Intl.NumberFormat の丸めモード
Identifier
説明
例: 小数桁数 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 (文字列) and returns 非負整数. It performs the following steps when called:
Assert : IsWellFormedCurrencyCode (currency ) は true である。currency に対応する通貨の数量をフォーマットする際に使用される小数桁数を示す非負整数を返す。使用する桁数に関する情報が利用できない場合は 2 を返す。
16.5.2 数値フォーマット関数
数値フォーマット関数は、[[NumberFormat]] 内部スロットを持つ匿名の組み込み関数である。
数値フォーマット関数 F がオプション引数 value で呼び出された場合、次の手順を実行する:
nf を F .[[NumberFormat]] に設定する。アサート: nf はオブジェクトであり、[[InitializedNumberFormat]] 内部スロットを持つ。 value が与えられていない場合、value を undefined に設定する。x を ? ToIntlMathematicalValue (value ) に設定する。FormatNumeric (nf , x ) を返す。
数値フォーマット関数の "length" プロパティは 1 𝔽 である。
16.5.3 FormatNumericToString ( intlObject , x )
The abstract operation FormatNumericToString takes arguments intlObject (オブジェクト) and x (数学的値または negative-zero ) and returns [[RoundedNumber]] (数学的値または negative-zero )と [[FormattedString]] (文字列)フィールドを持つ Record . It performs the following steps when called:
アサート: intlObject は [[RoundingMode]] , [[RoundingType]] , [[MinimumSignificantDigits]] ,
[[MaximumSignificantDigits]] , [[MinimumIntegerDigits]] , [[MinimumFractionDigits]] , [[MaximumFractionDigits]] ,
[[RoundingIncrement]] , [[TrailingZeroDisplay]] 内部スロットを持つ。 x が negative-zero の場合、sign を negative に設定する。x を 0 に設定する。それ以外の場合、 アサート: x は数学的値である。 x < 0 の場合、sign を negative に、そうでなければ positive に設定する。sign が negative の場合、x を -x に設定する。unsignedRoundingMode を GetUnsignedRoundingMode (intlObject .[[RoundingMode]] , sign ) に設定する。intlObject .[[RoundingType]] が significant-digits の場合、result を ToRawPrecision(x , intlObject .[[MinimumSignificantDigits]] ,
intlObject .[[MaximumSignificantDigits]] , unsignedRoundingMode ) に設定する。それ以外で intlObject .[[RoundingType]] が fraction-digits の場合、 result を ToRawFixed(x , intlObject .[[MinimumFractionDigits]] , intlObject .[[MaximumFractionDigits]] ,
intlObject .[[RoundingIncrement]] , unsignedRoundingMode ) に設定する。それ以外の場合、 sResult を ToRawPrecision(x , intlObject .[[MinimumSignificantDigits]] ,
intlObject .[[MaximumSignificantDigits]] , unsignedRoundingMode ) に設定する。fResult を ToRawFixed(x , intlObject .[[MinimumFractionDigits]] , intlObject .[[MaximumFractionDigits]] ,
intlObject .[[RoundingIncrement]] , unsignedRoundingMode ) に設定する。fResult .[[RoundingMagnitude]] < sResult .[[RoundingMagnitude]] の場合、fixedIsMorePrecise を true
に、そうでなければ false に設定する。intlObject .[[RoundingType]] が more-precision かつ fixedIsMorePrecise が true の場合、result を fResult に設定する。それ以外で intlObject .[[RoundingType]] が less-precision かつ fixedIsMorePrecise が false の場合、 result を fResult に設定する。それ以外の場合、 result を sResult に設定する。x を result .[[RoundedNumber]] に設定する。string を result .[[FormattedString]] に設定する。intlObject .[[TrailingZeroDisplay]] が "stripIfInteger" かつ x modulo 1 = 0 の場合、i を StringIndexOf (string , "." , 0) に設定する。i が not-found でない場合、string を 0 から i までの部分文字列に設定する。int を result .[[IntegerDigitsCount]] に設定する。minInteger を intlObject .[[MinimumIntegerDigits]] に設定する。int < minInteger の場合、forwardZeros を 0x0030(DIGIT ZERO)のコードユニットを minInteger - int 回繰り返した文字列に設定する。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]] (文字列)と [[Value]] (文字列)フィールドを持つ Record のリスト. It performs the following steps when called:
exponent を 0 に設定する。x が not-a-number の場合、n を ILD 文字列値(NaN を示す)に設定する。それ以外で x が positive-infinity の場合、 n を ILD 文字列値(正の無限大を示す)に設定する。それ以外で x が negative-infinity の場合、 n を ILD 文字列値(負の無限大を示す)に設定する。それ以外の場合、 x が negative-zero でない場合、アサート: x は数学的値である。 numberFormat .[[Style]] が "percent" の場合、x を 100 × x に設定する。exponent を ComputeExponent (numberFormat , x ) に設定する。x を x × 10-exponent に設定する。formatNumberResult を FormatNumericToString (numberFormat , x ) に設定する。n を formatNumberResult .[[FormattedString]] に設定する。x を formatNumberResult .[[RoundedNumber]] に設定する。pattern を GetNumberFormatPattern (numberFormat , x ) に設定する。result を新しい空リストに設定する。patternParts を PartitionPattern (pattern ) に設定する。各 Record { [[Type]] , [[Value]] } patternPart について、 p を patternPart .[[Type]] に設定する。p が "literal" の場合、Record { [[Type]] : "literal" , [[Value]] : patternPart .[[Value]] } を result に追加する。それ以外で p が "number" の場合、 notationSubParts を PartitionNotationSubPattern (numberFormat , x , n , exponent ) に設定する。result を result と notationSubParts のリスト連結に設定する。それ以外で p が "plusSign" の場合、 plusSignSymbol をプラス記号を表す ILND 文字列に設定する。Record { [[Type]] : "plusSign" , [[Value]] : plusSignSymbol } を result に追加する。それ以外で p が "minusSign" の場合、 minusSignSymbol をマイナス記号を表す ILND 文字列に設定する。Record { [[Type]] : "minusSign" , [[Value]] : minusSignSymbol } を result に追加する。それ以外で p が "percentSign" かつ numberFormat .[[Style]] が "percent" の場合、 percentSignSymbol をパーセント記号を表す ILND 文字列に設定する。Record { [[Type]] : "percentSign" , [[Value]] : percentSignSymbol } を result に追加する。それ以外で p が "unitPrefix" かつ numberFormat .[[Style]] が "unit" の場合、 unit を numberFormat .[[Unit]] に設定する。unitDisplay を numberFormat .[[UnitDisplay]] に設定する。mu を unit を x の前に unitDisplay 形式で表す ILD 文字列値に設定する(言語によって異なる複数形がある場合は x に依存する)。Record { [[Type]] : "unit" , [[Value]] : mu } を result に追加する。それ以外で p が "unitSuffix" かつ numberFormat .[[Style]] が "unit" の場合、 unit を numberFormat .[[Unit]] に設定する。unitDisplay を numberFormat .[[UnitDisplay]] に設定する。mu を unit を x の後に unitDisplay 形式で表す ILD 文字列値に設定する(言語によって異なる複数形がある場合は x に依存する)。Record { [[Type]] : "unit" , [[Value]] : mu } を result に追加する。それ以外で p が "currencyCode" かつ numberFormat .[[Style]] が "currency" の場合、 currency を numberFormat .[[Currency]] に設定する。cd を currency に設定する。Record { [[Type]] : "currency" , [[Value]] : cd } を result に追加する。それ以外で p が "currencyPrefix" かつ numberFormat .[[Style]] が "currency" の場合、 currency を numberFormat .[[Currency]] に設定する。currencyDisplay を numberFormat .[[CurrencyDisplay]] に設定する。cd を currency を x の前に currencyDisplay 形式で表す ILD 文字列値に設定する(言語によって異なる複数形がある場合は x に依存する)。Record { [[Type]] : "currency" , [[Value]] : cd } を result に追加する。それ以外で p が "currencySuffix" かつ numberFormat .[[Style]] が "currency" の場合、 currency を numberFormat .[[Currency]] に設定する。currencyDisplay を numberFormat .[[CurrencyDisplay]] に設定する。cd を currency を x の後に currencyDisplay 形式で表す ILD 文字列値に設定する(言語によって異なる複数形がある場合は x に依存する。実装にその表現がない場合は
currency 自体を使う)。Record { [[Type]] : "currency" , [[Value]] : cd } を result に追加する。それ以外の場合、 unknown を x と p に基づく ILND 文字列に設定する。Record { [[Type]] : "unknown" , [[Value]] : unknown } を result に追加する。result を返す。
16.5.5 PartitionNotationSubPattern ( numberFormat , x , n , exponent )
The abstract operation PartitionNotationSubPattern takes arguments numberFormat (Intl.NumberFormat), x (Intl 数学的値), n (文字列), and exponent (整数) and returns [[Type]] (文字列)と [[Value]] (文字列)フィールドを持つ Record のリスト. It performs the following steps when called:
result を新しい空リストに設定する。x が not-a-number の場合、Record { [[Type]] : "nan" , [[Value]] : n } を result に追加する。それ以外で x が positive-infinity または negative-infinity の場合、 Record { [[Type]] : "infinity" , [[Value]] : n } を result に追加する。それ以外の場合、 notationSubPattern を GetNotationSubPattern (numberFormat , exponent ) に設定する。patternParts を PartitionPattern (notationSubPattern ) に設定する。各 Record { [[Type]] , [[Value]] } patternPart について、 p を patternPart .[[Type]] に設定する。p が "literal" の場合、Record { [[Type]] : "literal" , [[Value]] : patternPart .[[Value]] } を result に追加する。それ以外で p が "number" の場合、 numberFormat .[[NumberingSystem]] が下記 Table 30 の
Numbering System 列の値のいずれかと一致する場合、digits を一致する行の Digits 列に指定されたコードポイントのリストに設定する。アサート: digits の長さは 10 である。 transliterated を空文字列に設定する。len を n の長さに設定する。position を 0 に設定する。position < len の間繰り返す、c を n の position 番目のコードユニットに設定する。0x0030 ≤ c ≤ 0x0039 の場合、 注: c は ASCII 数字。 i を c - 0x0030 に設定する。c を CodePointsToString (« digits [i ] ») に設定する。transliterated を transliterated と c の連結に設定する。position を position + 1 に設定する。n を transliterated に設定する。それ以外の場合、 実装依存アルゴリズムで n を指定された番号体系の適切な表現に変換する。 decimalSepIndex を StringIndexOf (n , "." , 0) に設定する。decimalSepIndex が not-found でなく、かつ decimalSepIndex > 0 の場合、integer を n の 0 から decimalSepIndex までの部分文字列に設定する。fraction を n の decimalSepIndex + 1 からの部分文字列に設定する。それ以外の場合、 integer を n に設定する。fraction を undefined に設定する。numberFormat .[[UseGrouping]] が false の場合、Record { [[Type]] : "integer" , [[Value]] : integer } を result に追加する。それ以外の場合、 groupSepSymbol をグループ区切り記号を表す ILND 文字列に設定する。groups を integer 内の ILND 場所集合で定義される部分文字列のリスト(左から右の順)に設定する(numberFormat .[[UseGrouping]] の値に依存)。アサート: groups リストの要素数は 0 より大きい。 groups リストが空でない間繰り返す、最初の要素を削除し、その値を integerGroup に設定する。 Record { [[Type]] : "integer" , [[Value]] : integerGroup } を result に追加する。groups リストが空でない場合、Record { [[Type]] : "group" , [[Value]] : groupSepSymbol } を result に追加する。fraction が undefined でない場合、decimalSepSymbol を小数点記号を表す ILND 文字列に設定する。Record { [[Type]] : "decimal" , [[Value]] : decimalSepSymbol } を result に追加する。Record { [[Type]] : "fraction" , [[Value]] : fraction } を result に追加する。それ以外で p が "compactSymbol" の場合、 compactSymbol を短縮形で exponent を表す ILD 文字列に設定する(言語によって異なる複数形がある場合は x
に依存。実装はこの文字列を提供できなければならない。そうでなければパターンに "{compactSymbol}" プレースホルダーはない)。Record { [[Type]] : "compact" , [[Value]] : compactSymbol } を result に追加する。それ以外で p が "compactName" の場合、 compactName を長形で exponent を表す ILD 文字列に設定する(言語によって異なる複数形がある場合は x に依存。実装はこの文字列を提供できなければならない。そうでなければパターンに
"{compactName}" プレースホルダーはない)。Record { [[Type]] : "compact" , [[Value]] : compactName } を result に追加する。それ以外で p が "scientificSeparator" の場合、 scientificSeparator を指数区切り記号を表す ILND 文字列に設定する。Record { [[Type]] : "exponentSeparator" , [[Value]] : scientificSeparator } を result に追加する。それ以外で p が "scientificExponent" の場合、 exponent < 0 の場合、minusSignSymbol をマイナス記号を表す ILND 文字列に設定する。Record { [[Type]] : "exponentMinusSign" , [[Value]] : minusSignSymbol } を result に追加する。exponent を -exponent に設定する。exponentResult を ToRawFixed(exponent , 0, 0, 1, undefined ) に設定する。Record { [[Type]] : "exponentInteger" , [[Value]] : exponentResult .[[FormattedString]] } を result に追加する。それ以外の場合、 unknown を x と p に基づく ILND 文字列に設定する。Record { [[Type]] : "unknown" , [[Value]] : unknown } を result に追加する。result を返す。
Table 30: 単純な数字マッピングを持つ番号体系
Numbering System
Digits
adlm
U+1E950 から U+1E959
ahom
U+11730 から U+11739
arab
U+0660 から U+0669
arabext
U+06F0 から U+06F9
bali
U+1B50 から U+1B59
beng
U+09E6 から U+09EF
bhks
U+11C50 から U+11C59
brah
U+11066 から U+1106F
cakm
U+11136 から U+1113F
cham
U+AA50 から U+AA59
deva
U+0966 から U+096F
diak
U+11950 から U+11959
fullwide
U+FF10 から U+FF19
gara
U+10D40 から U+10D49
gong
U+11DA0 から U+11DA9
gonm
U+11D50 から U+11D59
gujr
U+0AE6 から U+0AEF
gukh
U+16130 から U+16139
guru
U+0A66 から U+0A6F
hanidec
U+3007, U+4E00, U+4E8C, U+4E09, U+56DB, U+4E95, U+516D, U+4E03, U+516B, U+4E5D
hmng
U+16B50 から U+16B59
hmnp
U+1E140 から U+1E149
java
U+A9D0 から U+A9D9
kali
U+A900 から U+A909
kawi
U+11F50 から U+11F59
khmr
U+17E0 から U+17E9
knda
U+0CE6 から U+0CEF
krai
U+16D70 から U+16D79
lana
U+1A80 から U+1A89
lanatham
U+1A90 から U+1A99
laoo
U+0ED0 から U+0ED9
latn
U+0030 から U+0039
lepc
U+1C40 から U+1C49
limb
U+1946 から U+194F
mathbold
U+1D7CE から U+1D7D7
mathdbl
U+1D7D8 から U+1D7E1
mathmono
U+1D7F6 から U+1D7FF
mathsanb
U+1D7EC から U+1D7F5
mathsans
U+1D7E2 から U+1D7EB
mlym
U+0D66 から U+0D6F
modi
U+11650 から U+11659
mong
U+1810 から U+1819
mroo
U+16A60 から U+16A69
mtei
U+ABF0 から U+ABF9
mymr
U+1040 から U+1049
mymrepka
U+116DA から U+116E3
mymrpao
U+116D0 から U+116D9
mymrshan
U+1090 から U+1099
mymrtlng
U+A9F0 から U+A9F9
nagm
U+1E4F0 から U+1E4F9
newa
U+11450 から U+11459
nkoo
U+07C0 から U+07C9
olck
U+1C50 から U+1C59
onao
U+1E5F1 から U+1E5FA
orya
U+0B66 から U+0B6F
osma
U+104A0 から U+104A9
outlined
U+1CCF0 から U+1CCF9
rohg
U+10D30 から U+10D39
saur
U+A8D0 から U+A8D9
segment
U+1FBF0 から U+1FBF9
shrd
U+111D0 から U+111D9
sind
U+112F0 から U+112F9
sinh
U+0DE6 から U+0DEF
sora
U+110F0 から U+110F9
sund
U+1BB0 から U+1BB9
sunu
U+11BF0 から U+11BF9
takr
U+116C0 から U+116C9
talu
U+19D0 から U+19D9
tamldec
U+0BE6 から U+0BEF
telu
U+0C66 から U+0C6F
thai
U+0E50 から U+0E59
tibt
U+0F20 から U+0F29
tirh
U+114D0 から U+114D9
tnsa
U+16AC0 から U+16AC9
tols
U+11DE0 から U+11DE9
vaii
U+A620 から U+A629
wara
U+118E0 から U+118E9
wcho
U+1E2F0 から U+1E2F9
Note 1
計算は
ILD および
ILND 文字列値と数値文字列内の場所に依存し、
numberFormat の有効ロケールや番号体系に依存する。通貨名以外の
ILD および
ILND 文字列値は Unicode 標準で指定された
General Category "Number, decimal digit" のコードポイントを含んではならない。
Note 2
実装は
https://cldr.unicode.org/ で提供されている Common Locale Data Repository
のロケールを使用することが推奨される。
16.5.6 FormatNumeric ( numberFormat , x )
The abstract operation FormatNumeric takes arguments numberFormat (Intl.NumberFormat オブジェクト) and x (Intl 数学的値) and returns 文字列. It performs the following steps when called:
parts を PartitionNumberPattern (numberFormat , x ) に設定する。result を空文字列に設定する。各 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 配列. It performs the following steps when called:
parts を PartitionNumberPattern (numberFormat , x ) に設定する。result を ! ArrayCreate (0) に設定する。n を 0 に設定する。各 Record { [[Type]] , [[Value]] } part について、 O を OrdinaryObjectCreate (%Object.prototype% ) に設定する。! CreateDataPropertyOrThrow (O , "type" , part .[[Type]] ) を実行する。 ! CreateDataPropertyOrThrow (O , "value" , part .[[Value]] ) を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), O ) を実行する。 n を 1 増やす。result を返す。
16.5.8
ToRawPrecision (
x : 非負の数学的値,
minPrecision : 1 から 21 の範囲の整数,
maxPrecision : 1 から 21 の範囲の整数,
unsignedRoundingMode : Table 31 の Unsigned Rounding
Mode 列の仕様型、または undefined ,
): Record { [[FormattedString]] (文字列), [[RoundedNumber]] (数学的値), [[IntegerDigitsCount]] (整数),
[[RoundingMagnitude]] (整数) }
The abstract operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It performs the following steps when called:
p を maxPrecision に設定する。x = 0 の場合、m を p 回 0x0030(DIGIT ZERO)のコードユニットからなる文字列に設定する。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進表現の数字列(順序通り、先頭ゼロなし)からなる文字列に設定する。e ≥ (p - 1) の場合、m を m と (e - p + 1) 回 0x0030(DIGIT ZERO)のコードユニットの連結に設定する。int を e + 1 に設定する。それ以外で e ≥ 0 の場合、 m を最初の e + 1 コードユニット、0x002E(FULL STOP)、残りの p - (e + 1) コードユニットの連結に設定する。int を e + 1 に設定する。それ以外の場合、 アサート: e < 0。 m を "0." 、-(e + 1) 回 0x0030(DIGIT ZERO)、m の連結に設定する。int を 1 に設定する。m が 0x002E(FULL STOP)を含み、maxPrecision > minPrecision の場合、cut を maxPrecision - minPrecision に設定する。cut > 0 かつ m の末尾が 0x0030(DIGIT ZERO)の間繰り返す、m の末尾のコードユニットを削除する。cut を 1 減らす。m の末尾が 0x002E(FULL STOP)の場合、m の末尾のコードユニットを削除する。Record { [[FormattedString]] : m , [[RoundedNumber]] : xFinal , [[IntegerDigitsCount]] : int ,
[[RoundingMagnitude]] : e –p +1 } を返す。
16.5.9
ToRawFixed (
x : 非負の数学的値,
minFraction : 0 から 100 の範囲の整数,
maxFraction : 0 から 100 の範囲の整数,
roundingIncrement : 整数,
unsignedRoundingMode : Table 31 の Unsigned Rounding
Mode 列の仕様型、または undefined ,
): Record { [[FormattedString]] (文字列), [[RoundedNumber]] (数学的値), [[IntegerDigitsCount]] (整数),
[[RoundingMagnitude]] (整数) }
The abstract operation UNKNOWN takes UNPARSEABLE ARGUMENTS. 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進表現の数字列(順序通り、先頭ゼロなし)からなる文字列に設定する。f ≠ 0 の場合、k を m の長さに設定する。k ≤ f の場合、z を (f + 1 - k ) 回 0x0030(DIGIT ZERO)のコードユニットからなる文字列に設定する。m を z と m の連結に設定する。k を f + 1 に設定する。a を m の最初の k - f コードユニット、b を残りの f コードユニットに設定する。m を a 、"." 、b の連結に設定する。int を a の長さに設定する。それ以外の場合、 int を m の長さに設定する。cut を maxFraction - minFraction に設定する。cut > 0 かつ m の末尾が 0x0030(DIGIT ZERO)の間繰り返す、m の末尾のコードユニットを削除する。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 完了値. It performs the following steps when called:
nf がオブジェクトでない場合、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 文字列. It performs the following steps when called:
resolvedLocaleData を numberFormat .[[LocaleData]] に設定する。patterns を resolvedLocaleData .[[patterns]] に設定する。アサート: 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 >]] に設定する。それ以外の場合、 アサート: 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 に設定する。それ以外の場合、 アサート: 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]] に設定する。それ以外の場合、 アサート: 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 (an Intl.NumberFormat) and exponent (an integer ) and returns a String. It performs the following steps when called:
resolvedLocaleData を numberFormat .[[LocaleData]] に設定する。notationSubPatterns を resolvedLocaleData .[[notationSubPatterns]] に設定する。アサート: notationSubPatterns は Record である(16.2.3
参照)。 notation を numberFormat .[[Notation]] に設定する。notation が "scientific" または "engineering" の場合、notationSubPatterns .[[scientific]] を返す。それ以外で exponent が 0 でない場合、 アサート: 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 (an Intl.NumberFormat) and x (a mathematical value ) and returns an integer . 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 (an Intl.NumberFormat) and magnitude (an integer ) and returns an integer . It performs the following steps when called:
notation を numberFormat .[[Notation]] に設定する。notation が "standard" の場合、0 を返す。 それ以外で notation が "scientific" の場合、 magnitude を返す。それ以外で notation が "engineering" の場合、 thousands を magnitude / 3 以下の最大整数に設定する。thousands × 3 を返す。それ以外の場合、 アサート: notation は "compact" である。 exponent を現在のロケールの compact 記法で与えられた桁数を持つ数値をスケーリングするべき 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
最初の DecimalDigits の MV を a に設定する。 2番目の DecimalDigits が存在する場合、 2番目の DecimalDigits の MV を b に設定する。 2番目の DecimalDigits のコードポイント数を n に設定する。 それ以外の場合、 b を 0 に設定する。n を 0 に設定する。ExponentPart が存在する場合、e を ExponentPart の MV に設定する。存在しない場合、e を 0 に設定する。(a + (b × 10-n )) × 10e を返す。
StrUnsignedDecimalLiteral :::
.
DecimalDigits
ExponentPart opt
DecimalDigits の MV を b に設定する。ExponentPart が存在する場合、e を ExponentPart の MV に設定する。存在しない場合、e を 0 に設定する。DecimalDigits のコードポイント数を n に設定する。b × 10e - n を返す。
StrUnsignedDecimalLiteral :::
DecimalDigits
ExponentPart opt
DecimalDigits の MV を a に設定する。ExponentPart が存在する場合、e を ExponentPart の MV に設定する。存在しない場合、e を 0 に設定する。a × 10e を返す。
16.5.16 ToIntlMathematicalValue ( value )
The abstract operation ToIntlMathematicalValue takes argument value (an ECMAScript language value ) and returns either a normal completion containing an Intl mathematical value or a throw completion . 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 がエラーのリストの場合、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 (a rounding mode) and sign (negative or positive ) and returns a specification type from the Unsigned Rounding Mode column of . It performs the following steps when called:
Table 31 の Identifier 列が roundingMode かつ Sign 列が
sign の行の Unsigned Rounding Mode 列の仕様型を返す。
Table 31: 丸めモード から符号なし丸めモード への変換
Identifier
Sign
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 : a mathematical value,
r1 : a mathematical value,
r2 : a mathematical value,
unsignedRoundingMode : a specification type from the Unsigned Rounding Mode column of Table 31 , or undefined ,
): a mathematical value
The abstract operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It performs the following steps when called:
x が r1 の場合、r1 を返す。アサート: r1 < x < r2 。 アサート: unsignedRoundingMode は undefined でない。 unsignedRoundingMode が zero の場合、r1 を返す。unsignedRoundingMode が infinity の場合、r2 を返す。d1 を x – r1 に設定する。d2 を r2 – x に設定する。d1 < d2 の場合、r1 を返す。d2 < d1 の場合、r2 を返す。アサート: d1 は d2 である。 unsignedRoundingMode が half-zero の場合、r1 を返す。unsignedRoundingMode が half-infinity の場合、r2 を返す。アサート: 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 (an Intl.NumberFormat), x (an Intl mathematical value ), and y (an Intl mathematical value ) and returns either a normal completion containing a List of Records with fields [[Type]] (a String), [[Value]] (a. 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 ) の場合、appxResult を FormatApproximately (numberFormat , xResult ) に設定する。各要素 r について、 r .[[Source]] を "shared" に設定する。appxResult を返す。result を新しい空リストに設定する。xResult の各要素 r について、Record { [[Type]] : r .[[Type]] , [[Value]] : r .[[Value]] , [[Source]] : "startRange" } を result に追加する。rangeSeparator を2つの数値を区切るための ILND 文字列値に設定する。Record { [[Type]] : "literal" , [[Value]] : rangeSeparator , [[Source]] : "shared" } を result に追加する。yResult の各要素 r について、Record { [[Type]] : r .[[Type]] , [[Value]] : r .[[Value]] , [[Source]] : "endRange" } を result に追加する。CollapseNumberRange (numberFormat , result ) を返す。
16.5.20 FormatApproximately ( numberFormat , result )
The abstract operation FormatApproximately takes arguments numberFormat (an Intl.NumberFormat) and result (a List of Records with fields [[Type]] (a String) and [[Value]] (a String)) and returns a List of Records with fields [[Type]] (a String) and [[Value]] (a String). It performs the following steps when called:
approximatelySign を数値が概算であることを示す ILND 文字列値に設定する。approximatelySign が空でない場合、result の ILND インデックスに Record { [[Type]] : "approximatelySign" , [[Value]] :
approximatelySign } を挿入する。例えば、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 (an Intl.NumberFormat) and result (a List of Records with fields [[Type]] (a String), [[Value]] (a String), and [[Source]] (a String)) and returns a List of Records with fields [[Type]] (a String), [[Value]] (a String), and [[Source]] (a String).
例えば、実装は範囲区切り記号の後の通貨記号の Record を削除し、"$3–$5" を "$3–5" に変換することができる。
実装はまた、文法的な正しさのために Record の [[Value]] フィールドを修正することができる。例えば、"0.5 miles–1 mile" を "0.5–1 miles" に変換することができる。
result をそのまま返すことは CollapseNumberRange の正しい実装であることが保証されている。
16.5.22 FormatNumericRange ( numberFormat , x , y )
The abstract operation FormatNumericRange takes arguments numberFormat (an Intl.NumberFormat), x (an Intl mathematical value ), and y (an Intl mathematical value ) and returns either a normal completion containing a String or a throw completion . It performs the following steps when called:
parts を ? PartitionNumberRangePattern (numberFormat , x , y ) に設定する。result を空文字列に設定する。各要素 part について、 result を result と part .[[Value]] の連結に設定する。result を返す。
16.5.23 FormatNumericRangeToParts ( numberFormat , x , y )
The abstract operation FormatNumericRangeToParts takes arguments numberFormat (an Intl.NumberFormat), x (an Intl mathematical value ), and y (an Intl mathematical value ) and returns either a normal completion containing an Array or a throw completion . It performs the following steps when called:
parts を ? PartitionNumberRangePattern (numberFormat , x , y ) に設定する。result を ! ArrayCreate (0) に設定する。n を 0 に設定する。各要素 part について、 O を OrdinaryObjectCreate (%Object.prototype% ) に設定する。! CreateDataPropertyOrThrow (O , "type" , part .[[Type]] ) を実行する。 ! CreateDataPropertyOrThrow (O , "value" , part .[[Value]] ) を実行する。 ! CreateDataPropertyOrThrow (O , "source" , part .[[Source]] ) を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), O ) を実行する。 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]] に設定する。r を optionsResolution .[[ResolvedLocale]] とする。pluralRules .[[Locale]] を r .[[Locale]] に設定する。t を ? GetOption (options , "type" , string , « "cardinal" , "ordinal" », "cardinal" ) とする。pluralRules .[[Type]] を t に設定する。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 インスタンスオブジェクトの内部スロットを持たない。
[[Prototype]] 内部スロットの値は %Object.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" 。Table 32 の各行(ヘッダー行を除く)について、表の順序で次を行う:現在の行の Property 値を p とする。 p が "pluralCategories" ならv を CreateArrayFromList (pluralCategories ) とする。それ以外の場合、 v を pr の内部スロットで、現在の行の Internal Slot 名の値とする。v が undefined でない場合、現在の行に Conversion 値がある場合、 現在の行の Conversion 値は number であることをアサートする。 v を 𝔽 (v ) に設定する。! CreateDataPropertyOrThrow (options , p , v ) を実行する。 options を返す。
Table 32: PluralRules インスタンスの解決オプション
内部スロット
プロパティ
変換
[[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 または end が undefined なら、TypeError 例外を投げる。x を ? ToIntlMathematicalValue (start ) とする。y を ? ToIntlMathematicalValue (end ) とする。? ResolvePluralRange (pr , x , y ) を返す。
17.3.5 Intl.PluralRules.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% プロパティの初期値は文字列値 "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]] は、複数形ルールで使用されるロケールの言語タグ を持つ文字列値である。
[[Type]] は "cardinal" または "ordinal" のいずれかの文字列値で、使用される複数形ルールを識別する。
[[Notation]] は "standard" , "scientific" , "engineering" , "compact" のいずれかの文字列値で、使用される表記法を識別する。
[[CompactDisplay]] は "short" または "long" のいずれかの文字列値で、"compact" 表記法でフォーマットする場合に短縮形("5K")または長形式("5
thousand")のどちらで表示するかを指定する。これは [[Notation]] が "compact" の場合のみ使用される。
[[MinimumIntegerDigits]] は使用する最小整数桁数を示す非負整数である。
[[MinimumFractionDigits]] および [[MaximumFractionDigits]] は使用する最小および最大小数桁数を示す非負整数である。必要に応じて数値は丸められたり、末尾ゼロで埋められる。
[[MinimumSignificantDigits]] および [[MaximumSignificantDigits]]
は使用する最小および最大有効桁数を示す正の整数である。これらのプロパティはどちらも存在しないか、両方存在する。存在する場合は、最小・最大整数桁数と小数桁数を上書きする。
[[RoundingType]] は fraction-digits , significant-digits , more-precision , less-precision
のいずれかの値で、どの丸め戦略を使用するかを示す。詳細は 16.4 を参照。
[[ComputedRoundingPriority]] は "auto" , "morePrecision" , "lessPrecision" のいずれかの文字列値で、17.3.2 で [[RoundingType]] を "roundingPriority"
オプションに戻すためだけに使用される。
[[RoundingIncrement]] は 10, 100, 1000, 10000 を均等に分割する整数で、計算された丸め桁数に対して丸めを行う増分を示す。例えば、[[MaximumFractionDigits]]
が 2 で [[RoundingIncrement]] が 5 の場合、数値は最も近い 0.05("nickel rounding")に丸められる。
[[RoundingMode]] は使用する丸めモード を識別する。
[[TrailingZeroDisplay]] は "auto" または "stripIfInteger"
のいずれかの文字列値で、フォーマットされた数値が整数(非ゼロ小数桁を持たない)である場合に末尾ゼロを除去するかどうかを示す。
17.5 PluralRules オブジェクトの抽象演算
17.5.1 PluralRuleSelect ( locale , type , notation , compactDisplay , s )
The implementation-defined abstract operation PluralRuleSelect takes arguments locale (言語タグ ), type ("cardinal" または "ordinal" ), notation (文字列), compactDisplay ("short" または "long" ), and s (10進文字列) and returns "zero" , "one" , "two" , "few" , "many" , または "other" .
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" ) と. It performs the following steps when called:
n が not-a-number ならs を NaN 値を示す ILD 文字列値とする。レコード { [[PluralCategory]] : "other" , [[FormattedString]] : s } を返す。 n が positive-infinity ならs を正の無限大を示す ILD 文字列値とする。レコード { [[PluralCategory]] : "other" , [[FormattedString]] : s } を返す。 n が negative-infinity ならs を負の無限大を示す ILD 文字列値とする。レコード { [[PluralCategory]] : "other" , [[FormattedString]] : s } を返す。 res を FormatNumericToString (pluralRules , n ) とする。s を res .[[FormattedString]] とする。locale を pluralRules .[[Locale]] とする。type を pluralRules .[[Type]] とする。notation を pluralRules .[[Notation]] とする。compactDisplay を pluralRules .[[CompactDisplay]] とする。p を PluralRuleSelect (locale , type , notation , compactDisplay , s ) とする。レコード { [[PluralCategory]] : p , [[FormattedString]] : s } を返す。
17.5.3 PluralRuleSelectRange ( locale , type , notation , compactDisplay , xp , yp )
The implementation-defined abstract operation PluralRuleSelectRange takes arguments locale (言語タグ ), type ("cardinal" または "ordinal" ), notation (文字列), 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" .
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 完了. It performs the following steps when called:
x が not-a-number または y が not-a-number なら、RangeError 例外を投げる。xp を ResolvePlural (pluralRules , x ) とする。yp を ResolvePlural (pluralRules , y ) とする。xp .[[FormattedString]] が yp .[[FormattedString]] ならxp .[[PluralCategory]] を返す。locale を pluralRules .[[Locale]] とする。type を pluralRules .[[Type]] とする。notation を pluralRules .[[Notation]] とする。compactDisplay を pluralRules .[[CompactDisplay]] とする。PluralRuleSelectRange (locale , type , notation , compactDisplay , xp .[[PluralCategory]] ,
yp .[[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]] に設定する。r を optionsResolution .[[ResolvedLocale]] に設定する。locale を r .[[Locale]] に設定する。relativeTimeFormat .[[Locale]] を locale に設定する。relativeTimeFormat .[[LocaleData]] を r .[[LocaleData]] に設定する。relativeTimeFormat .[[NumberingSystem]] を r .[[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"
を連結した追加フィールドが存在する場合がある。これらのフィールドの値は次の2カテゴリのフィールドを含むレコードである:
"future" と "past" フィールドは、locale に関連するすべての複数形カテゴリのフィールドを持つレコードである。それらのフィールドの値は、"{0}"
を含む場合があり、これはフォーマットされた数字で置換されるパターンである。
オプションで、キーが Number の ToString の結果であり、値がテンプレートとして扱われないリテラル文字列である追加フィールドが存在する場合がある。
[[LocaleData]] の任意のロケールフィールドの "nu" フィールドの値のリストには "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
インスタンスオブジェクトの他の内部スロットを持たない。
[[Prototype]] 内部スロットの値は %Object.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
の各行(ヘッダー行を除く)について、テーブル順に次を行うp を現在の行の Property の値とする。v を relativeTimeFormat の内部スロットで、現在の行の Internal Slot 名の値とする。Assert : v は undefined ではない。! CreateDataPropertyOrThrow (options , p , v ) を実行する。 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% プロパティの初期値は文字列値 "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]] は、フォーマットに使用されるロケールの言語タグ を持つ文字列値である。
[[LocaleData]] は、フォーマットに利用可能なデータを表すレコードである。これは [[Locale]] の値またはその接頭辞に関連付けられた
%Intl.RelativeTimeFormat% .[[LocaleData]] のエントリの値である。
[[Style]] は、使用される相対時間フォーマットスタイルを識別する "long" , "short" , "narrow" のいずれかの文字列値である。
[[Numeric]] は、数値による表現が常に使用されるか、より具体的なバージョンがない場合のみ使用されるか(例: "1 day ago" と "yesterday")を識別する "always" または
"auto" のいずれかの文字列値である。
[[NumberFormat]] は、フォーマットに使用される Intl.NumberFormat オブジェクトである。
[[NumberingSystem]] は、フォーマットに使用される Unicode Number System Identifier
を表す文字列値である。
[[PluralRules]] は、フォーマットに使用される Intl.PluralRules オブジェクトである。
18.5 RelativeTimeFormat オブジェクトの抽象演算
18.5.1 SingularRelativeTimeUnit ( unit )
The abstract operation SingularRelativeTimeUnit takes argument unit (a String) and returns 正常完了で文字列を返すか、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 (an Intl.RelativeTimeFormat), value (a Number), and unit (a String) and returns 正常完了で [[Type]] (文字列)、[[Value]] (文字列)、[[Unit]] (文字列または empty )フィールドを持つレコードのリストを返すか、throw 完了を返す. 返されるリストは、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 >]] とする。リスト { [[Type]] : "literal" , [[Value]] : result , [[Unit]] : empty } を返す。 value が -0 𝔽 または value < -0 𝔽 の場合、tl を "past" とする。それ以外の場合、 tl を "future" とする。po を patterns .[[<tl >]] とする。fv を PartitionNumberPattern (relativeTimeFormat .[[NumberFormat]] , ℝ (value )) とする。pr を ResolvePlural (relativeTimeFormat .[[PluralRules]] , value ).[[PluralCategory]] とする。pattern を po .[[<pr >]] とする。MakePartsList (pattern , unit , fv ) を返す。
18.5.3 MakePartsList ( pattern , unit , parts )
The abstract operation MakePartsList takes arguments pattern (a Pattern String), unit (a String), and parts (フォーマットされた数字を表すレコードのリスト) and returns [[Type]] (文字列)、[[Value]] (文字列)、[[Unit]] (文字列または empty )フィールドを持つレコードのリスト. It performs the following steps when called:
patternParts を PartitionPattern (pattern ) とする。result を新しい空リストとする。各 Record { [[Type]] , [[Value]] } patternPart について次を行う patternPart .[[Type]] が "literal" の場合、Record { [[Type]] : "literal" , [[Value]] : patternPart .[[Value]] , [[Unit]] : empty } を result に追加する。それ以外の場合、 Assert : patternPart .[[Type]] は "0" である。各 Record { [[Type]] , [[Value]] } part を parts から取り出し、次を行う Record { [[Type]] : part .[[Type]] , [[Value]] : part .[[Value]] , [[Unit]] : unit } を result に追加する。result を返す。
Note
例:
MakePartsList ("AA{0}BB" , "hour" , « Record { [[Type]] : "integer" , [[Value]] : "15" } ») を返す。
は次のようなレコードのリストを返す
«
{ [[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 (an Intl.RelativeTimeFormat), value (a Number), and unit (a String) and returns 正常完了で文字列を返すか、throw 完了を返す. It performs the following steps when called:
parts を ? PartitionRelativeTimePattern (relativeTimeFormat , value , unit ) とする。result を空文字列とする。各 Record { [[Type]] , [[Value]] , [[Unit]] } part について次を行う result を result と part .[[Value]] の連結文字列に設定する。result を返す。
18.5.5 FormatRelativeTimeToParts ( relativeTimeFormat , value , unit )
The abstract operation FormatRelativeTimeToParts takes arguments relativeTimeFormat (an Intl.RelativeTimeFormat), value (a Number), and unit (a String) and returns 正常完了で配列を返すか、throw 完了を返す. It performs the following steps when called:
parts を ? PartitionRelativeTimePattern (relativeTimeFormat , value , unit ) とする。result を ! ArrayCreate (0) とする。n を 0 とする。各 Record { [[Type]] , [[Value]] , [[Unit]] } part について次を行う O を OrdinaryObjectCreate (%Object.prototype% ) とする。! CreateDataPropertyOrThrow (O , "type" , part .[[Type]] ) を実行する。 ! CreateDataPropertyOrThrow (O , "value" , part .[[Value]] ) を実行する。 part .[[Unit]] が empty でない場合、! CreateDataPropertyOrThrow (O , "unit" , part .[[Unit]] ) を実行する。 ! CreateDataPropertyOrThrow (result , ! ToString (𝔽 (n )), O ) を実行する。 n を 1 増やす。result を返す。
19 セグメンターオブジェクト
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]] に設定する。r を optionsResolution .[[ResolvedLocale]] とする。segmenter .[[Locale]] を r .[[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 インスタンスオブジェクトの内部スロットを持たない。
[[Prototype]] 内部スロットの値は %Object.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 の各行(ヘッダー行を除く)について、テーブル順に次を行う現在の行の Property 値を p とする。 現在の行の Internal Slot 値の名前を持つ segmenter の内部スロットの値を v とする。 v は undefined ではないことをアサートする。! CreateDataPropertyOrThrow (options , p , v ) を実行する。 options を返す。
Table 34: セグメンターインスタンスの解決済みオプション
内部スロット
プロパティ
[[Locale]]
"locale"
[[SegmenterGranularity]]
"granularity"
19.3.3 Intl.Segmenter.prototype.segment ( string )
Intl.Segmenter.prototype.segment メソッドは、Intl.Segmenter インスタンス上で引数 string とともに呼び出され、インスタンスのロケールとオプションを用いて文字列の
Segments インスタンス を作成する。以下の手順が実行される:
segmenter を this 値とする。? RequireInternalSlot (segmenter , [[InitializedSegmenter]] ) を実行する。 string を ? ToString (string ) とする。CreateSegmentsObject (segmenter , string ) を返す。
19.3.4 Intl.Segmenter.prototype [ %Symbol.toStringTag% ]
%Symbol.toStringTag% プロパティの初期値は文字列値 "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]] は、セグメンテーションに使用されるロケールの言語タグ を持つ文字列値である。
[[SegmenterGranularity]] は、テキスト要素の種類を識別する "grapheme" , "word" , "sentence" のいずれかの文字列値である。
19.5 Segments オブジェクト
Segments インスタンス は、特定の文字列のセグメントを表すオブジェクトであり、その構築元の Intl.Segmenter インスタンスのロケールとオプションに従う。
19.5.1 CreateSegmentsObject ( segmenter , string )
The abstract operation CreateSegmentsObject takes arguments segmenter (an Intl.Segmenter) and string (a String) and returns a Segments instance. 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 オブジェクトのプロトタイプである。
通常のオブジェクトである。
[[Prototype]] 内部スロットの値は %Object.prototype% である。
以下のプロパティを持つ:
19.5.2.1 %IntlSegmentsPrototype%.containing ( index )
containing メソッドは Segments インスタンス 上で引数 index とともに呼び出され、指定されたインデックスのコードユニットを含むセグメントを、その Segments インスタンス の構築元の
Intl.Segmenter インスタンスのロケールとオプションに従って記述する Segment Data オブジェクト を返す。以下の手順が実行される:
segments を this 値とする。? RequireInternalSlot (segments , [[SegmentsSegmenter]] ) を実行する。 segmenter を segments .[[SegmentsSegmenter]] とする。string を segments .[[SegmentsString]] とする。len を string の長さとする。n を ? ToIntegerOrInfinity (index ) とする。n < 0 または n ≥ len の場合、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 インスタンス はセグメントを公開する文字列値を参照する [[SegmentsString]] 内部スロットを持つ。
19.6 Segment Iterator オブジェクト
Segment Iterator は特定の文字列のセグメントを反復するオブジェクトである。
19.6.1 CreateSegmentIterator ( segmenter , string )
The abstract operation CreateSegmentIterator takes arguments segmenter (an Intl.Segmenter) and string (a String) and returns a Segment Iterator . 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 インスタンス上で呼び出され、セグメントを一つ進めて新しいセグメントを記述する IteratorResult
オブジェクトを返すか、反復が終了したことを宣言する。以下の手順が実行される:
iterator を this 値とする。? RequireInternalSlot (iterator , [[IteratingSegmenter]] ) を実行する。 segmenter を iterator .[[IteratingSegmenter]] とする。string を iterator .[[IteratedString]] とする。startIndex を iterator .[[IteratedStringNextSegmentCodeUnitIndex]] とする。len を string の長さとする。startIndex ≥ len の場合、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% プロパティの初期値は文字列値 "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]]
反復される文字列値。
[[IteratedStringNextSegmentCodeUnitIndex]]
反復される文字列値の次のセグメント開始コードユニットのインデックス。
19.7 Segment Data オブジェクト
Segment Data オブジェクト は文字列から特定のセグメントを表すオブジェクトである。
19.7.1 CreateSegmentDataObject ( segmenter , string , startIndex , endIndex )
The abstract operation CreateSegmentDataObject takes arguments segmenter (an Intl.Segmenter), string (a String), startIndex (a non-negative integer ), and endIndex (a non-negative integer ) and returns a Segment Data object. It performs the following steps when called:
len を string の長さとする。endIndex ≤ len であることをアサートする。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 を、segment がロケール segmenter .[[Locale]] に従って "word-like" かどうかを示すブール値とする。! CreateDataPropertyOrThrow (result , "isWordLike" , isWordLike ) を実行する。 result を返す。
Note セグメントが "word-like" かどうかは実装依存であり、実装はロケールに応じた調整を使用することが推奨される。一般的に、空白や句読点のみからなるセグメント(ICU の "WORD_NONE"
境界で終了するものなど)は "word-like" とみなされない。
19.8 セグメンターオブジェクトの抽象操作
19.8.1 FindBoundary ( segmenter , string , startIndex , direction )
The abstract operation FindBoundary takes arguments segmenter (an Intl.Segmenter), string (a String), startIndex (a non-negative integer ), and direction (before or after ) and returns a non-negative integer . It performs the following steps when called:
len を string の長さとする。startIndex < len であることをアサートする。locale を segmenter .[[Locale]] とする。granularity を segmenter .[[SegmenterGranularity]] とする。direction が before の場合、string の先頭から最大 startIndex コードユニットまでの範囲で、ロケール locale とテキスト要素の粒度 granularity を用いて最後のセグメンテーション境界を探す。境界が見つかった場合、その境界より前のコードユニット数を返す。 0 を返す。 direction が after であることをアサートする。string の startIndex のコードユニットの後に続く最初のセグメンテーション境界を、ロケール locale とテキスト要素の粒度 granularity を用いて探す。境界が見つかった場合、その境界より前のコードユニット数を返す。 len を返す。
Note 境界の決定は実装依存だが、一般的なデフォルトアルゴリズムは
Unicode Standard Annex #29
に指定されている。実装は
Common Locale Data Repository
のようなロケール依存の調整を使用することが推奨される。
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 で呼び出された場合、以下の手順を実行します:
O を? RequireObjectCoercible (this value)とする。S を? ToString (O )とする。thatValue を? ToString (that )とする。collator を? Construct (%Intl.Collator% , « locales , options »)とする。CompareStrings (collator , S , 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 で記述されている通り、String値をコードポイントの列として解釈します。6.1.4 。以下の手順を実行します:
O を? RequireObjectCoercible (this value)とする。S を? ToString (O )とする。? TransformCase (S , locales , lower )を返す。
Note
toLocaleLowerCase関数は意図的にジェネリックです。this 値がStringオブジェクトであることを要求しません。したがって、他の種類のオブジェクトに転送してメソッドとして使用できます。
20.1.2.1 TransformCase ( S , locales , targetCase )
The abstract operation TransformCase takes arguments S (a String), locales (an ECMAScript language value ), and targetCase (lower or upper ). S をECMA-262 で記述されている通りUTF-16エンコードされたコードポイントの列として解釈し、targetCase へのILD 変換の結果を新しいString値として返します。6.1.4 It performs the following steps when called:
requestedLocales を? CanonicalizeLocaleList (locales )とする。requestedLocales が空リストでない場合、requestedLocale をrequestedLocales [0]とする。それ以外の場合、 requestedLocale をDefaultLocale ()とする。availableLocales を、Unicode Character
Databaseが言語依存のケースマッピングを含む言語タグ を含む利用可能ロケールリストとする。実装が追加のロケール依存ケースマッピングをサポートする場合、それらの対応する言語タグ も含めるべきである。match をLookupMatchingLocaleByPrefix (availableLocales , « requestedLocale »)とする。match がundefined でない場合、locale をmatch .[[locale]] とし、そうでなければlocale を"und" とする。codePoints をStringToCodePoints (S )とする。targetCase がlower の場合、newCodePoints を、locale またはUnicodeデフォルトケース変換アルゴリズムを使用した実装依存アルゴリズムによるcodePoints の小文字変換結果のリストとする。それ以外の場合、 アサート: targetCase はupper である。 newCodePoints を、locale またはUnicodeデフォルトケース変換アルゴリズムを使用した実装依存アルゴリズムによるcodePoints の大文字変換結果のリストとする。CodePointsToString (newCodePoints )を返す。
コードポイントのマッピングは、Unicode標準のデフォルトケース変換アルゴリズムの調整版に従って導出される場合があります。実装は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 で記述されている通り、String値をコードポイントの列として解釈します。6.1.4 。以下の手順を実行します:
O を? RequireObjectCoercible (this value)とする。S を? ToString (O )とする。? TransformCase (S , locales , upper )を返す。
Note
toLocaleUpperCase関数は意図的にジェネリックです。this 値がStringオブジェクトであることを要求しません。したがって、他の種類のオブジェクトに転送してメソッドとして使用できます。
20.2 Numberプロトタイプオブジェクトのプロパティ
以下の定義は、ECMA-262 で定義されている抽象操作thisNumberValueを参照します。21.1.3
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 で定義されている抽象操作thisBigIntValueを参照します。21.2.3
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 で定義されている抽象操作thisTimeValueを参照します。21.4.4
20.4.1 Date.prototype.toLocaleString ( [ locales [ , options ] ] )
この定義はECMA-262 で提供されている定義を上書きします。21.4.4.39
toLocaleStringメソッドがオプション引数locales とoptions で呼び出された場合、以下の手順を実行します:
dateObject をthis 値とする。? RequireInternalSlot (dateObject , [[DateValue]] )を実行する。 x をdateObject .[[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 で呼び出された場合、以下の手順を実行します:
dateObject をthis 値とする。? RequireInternalSlot (dateObject , [[DateValue]] )を実行する。 x をdateObject .[[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 で呼び出された場合、以下の手順を実行します:
dateObject をthis 値とする。? RequireInternalSlot (dateObject , [[DateValue]] )を実行する。 x をdateObject .[[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)とする。len を? LengthOfArrayLike (array )とする。separator を、ホスト環境の現在のロケールに適した実装依存のリスト区切り文字列値(例:", " )とする。R を空文字列とする。k を0とする。k < len の間繰り返す、k > 0の場合、R をR とseparator の文字列連結とする。nextElement を? Get (array , ! ToString (𝔽 (k )))とする。nextElement がundefined またはnull でない場合、S を? ToString (? Invoke (nextElement , "toLocaleString" , « locales , options »))とする。R をR とS の文字列連結とする。k をk + 1とする。R を返す。
Note 1
このアルゴリズムの手順は
Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) で実行される手順と同じですが、
Invoke (
nextElement ,
"toLocaleString" )が
locales と
options を引数として取る点が異なります。
Note 2
配列の要素は各自のtoLocaleStringメソッドで文字列に変換され、その文字列が実装依存のロケール感度な区切り文字列で連結されます。この関数は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.