Draft ECMA-402 / July 10, 2026

ECMAScript® 2027 Internationalization API Specification

이 명세에 기여하기

이 명세는 ECMAScript 커뮤니티의 도움으로 GitHub에서 개발되고 있습니다. 이 명세의 개발에 기여할 수 있는 여러 방법이 있습니다:

이 문서가 어떻게 생성되는지에 대한 자세한 정보는 colophon을 참조하세요.

소개

이 명세의 소스는 https://github.com/tc39/ecma402에서 찾을 수 있습니다.

ECMAScript 2027 국제화 API 명세서 (ECMA-402 14번째 판)는 ECMA-262를 보완하는 주요 언어 민감 기능을 제공합니다. 이 기능들은 유니코드 국제화 컴포넌트(ICU) 라이브러리 (https://unicode-org.github.io/icu-docs/), .NET 프레임워크, Java 플랫폼 등 잘 알려진 국제화 API에서 선택되었습니다.

1번째 판 API는 Nebojša Ćirić와 Jungshik Shin의 제안에 기반하여 2010년 9월 Ecma TC39가 설립한 임시 그룹에 의해 개발되었습니다.

2번째 판 API는 2015년 6월 총회에서 ECMAScript 6번째 판을 보완하는 것으로 채택되었습니다.

3번째 판 API는 Ecma TC39의 새로운 연간 릴리즈 주기와 오픈 개발 프로세스 하에 처음으로 출시되었습니다. ECMA-402 소스 문서에서 평문 소스 문서가 구축되어 GitHub에서 완전히 개발의 기반이 되었습니다. 이 표준의 개발 기간 동안 수십 건의 풀 리퀘스트와 이슈가 제출되어 여러 버그 수정, 편집 수정 및 기타 개선 사항이 반영되었습니다. 또한 Ecmarkup, Ecmarkdown, Grammarkdown 등 다양한 소프트웨어 도구가 개발되어 이 작업을 지원했습니다.

수많은 조직을 대표하는 수십 명의 개인이 Ecma TC39 내에서 이 판과 이전 판의 개발에 매우 중요한 기여를 했습니다. 또한 TC39의 ECMAScript 활동을 지원하는 활발한 커뮤니티가 형성되었습니다. 이 커뮤니티는 수많은 초안 검토, 버그 리포트 제출, 구현 실험, 테스트 스위트 기여, ECMAScript 국제화에 대한 전 세계 개발자 커뮤니티 교육을 수행했습니다. 불행히도 이 작업에 기여한 모든 사람과 조직을 식별하고 인정하는 것은 불가능합니다.

Norbert Lindenberg
ECMA-402, 1번째 판 프로젝트 에디터

Rick Waldron
ECMA-402, 2번째 판 프로젝트 에디터

Caridy Patiño
ECMA-402, 3번째, 4번째, 5번째 판 프로젝트 에디터

Caridy Patiño, Daniel Ehrenberg, Leo Balter
ECMA-402, 6번째 판 프로젝트 에디터

Leo Balter, Valerie Young, Isaac Durazo
ECMA-402, 7번째 판 프로젝트 에디터

Leo Balter, Richard Gibson
ECMA-402, 8번째 판 프로젝트 에디터

Leo Balter, Richard Gibson, Ujjwal Sharma
ECMA-402, 9번째 판 프로젝트 에디터

Richard Gibson, Ujjwal Sharma
ECMA-402, 10번째 판 프로젝트 에디터

Richard Gibson, Ujjwal Sharma
ECMA-402, 11번째 판 프로젝트 에디터

Ben Allen, Richard Gibson, Ujjwal Sharma
ECMA-402, 12번째 판 프로젝트 에디터

Ben Allen, Richard Gibson, Ujjwal Sharma
ECMA-402, 13번째 판 프로젝트 에디터

Ben Allen, Richard Gibson, Ujjwal Sharma
ECMA-402, 14번째 판 프로젝트 에디터

1 범위

이 표준은 다양한 인간 언어와 국가에서 사용되는 언어적 및 문화적 관습에 맞게 프로그램을 조정해야 하는 ECMAScript 객체를 위한 응용 프로그램 프로그래밍 인터페이스를 정의합니다.

2 적합성

이 명세의 적합한 구현은 ECMA-262를 준수해야 하며, 이 명세에서 설명된 모든 객체, 속성, 함수 및 프로그램 의미론을 제공하고 지원해야 합니다. 이 명세의 어떤 내용도 ECMA-262에서 금지된 동작을 허용하도록 의도된 것이 아니며, 그러한 충돌은 ECMA-262의 제약을 무시하는 것이 아니라 편집상의 오류로 간주해야 합니다.

적합한 구현은 이 명세에서 설명된 것 외에도 추가적인 객체, 속성, 함수 등을 제공할 수 있습니다. 특히, 적합한 구현은 이 명세에서 설명되지 않은 속성 및 해당 속성의 값을, 여기서 설명된 객체에 대해 제공할 수 있습니다. 적합한 구현은 이 명세에서 정의된 함수에 선택적 인수를 추가하는 것은 허용되지 않습니다.

적합한 구현은 다음 options 인수의 속성에 대해 추가 값을 허용하고, RangeError를 발생시키는 대신 구현 정의 동작을 할 수 있습니다:

3 규범적 참고문헌

다음에 참조된 문서는 이 문서의 적용에 필요합니다. 날짜가 명시된 참고문헌의 경우, 인용된 판만 적용됩니다. 날짜가 명시되지 않은 참고문헌의 경우, 참조된 문서의 최신 판(모든 개정 포함)이 적용됩니다.

ECMAScript 2027 언어 명세서 (ECMA-262 18번째 판 또는 후속 판).
https://www.ecma-international.org/publications/standards/Ecma-262.htm

Note
이 명세의 섹션들은 이러한 참고문헌에 의존하며, 최신 표준과 일치하도록 최선을 다해 업데이트되지만, 항상 최신 상태를 보장하지는 않습니다.

4 개요

이 섹션은 비규범적입니다.

4.1 국제화, 지역화, 그리고 세계화

소프트웨어의 국제화란 다양한 언어를 사용하는 사용자와 서로 다른 문화적 기대를 가진 사용자의 요구를 지원하거나 쉽게 적응할 수 있도록 설계하는 것을 의미하며, 전 세계 사용자 간의 소통을 가능하게 합니다. 지역화는 특정 언어와 문화에 실제로 적응하는 과정입니다. 소프트웨어의 세계화는 일반적으로 국제화와 지역화의 결합으로 이해됩니다. 세계화는 모든 언어를 지원하는 텍스트 표현을 사용하고, 언어, 국가, 시간대 및 기타 관련 매개변수를 식별하기 위해 표준 식별자를 사용하는 가장 낮은 수준에서 시작합니다. 이후 사용자가 이해할 수 있는 사용자 인터페이스 언어와 데이터 표현을 사용하며, 마지막으로 제품별로 사용자의 언어, 문화, 환경에 맞춘 적응이 필요할 수 있습니다.

ECMA-262는 텍스트 표현에 유니코드를 사용하고 몇 가지 언어 민감 함수들을 제공함으로써 기반을 마련하지만, 이러한 함수들의 동작을 애플리케이션이 제어할 수 있는 방법은 거의 제공하지 않습니다. 이 명세는 커스터마이즈 가능한 언어 민감 기능을 제공함으로써 그 기반 위에 구축됩니다. 이 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를 두 가지 방식으로 사용할 수 있습니다:

  1. 서비스 생성자를 직접 사용하여 객체를 생성하고, 선호하는 언어 목록과 동작을 구성할 옵션을 지정합니다. 객체는 주요 함수(compare, select, format 등)를 제공하며, 반복적으로 호출할 수 있습니다. 또한, 애플리케이션이 객체의 정확한 구성 정보를 확인할 수 있도록 resolvedOptions 함수를 제공합니다.
  2. 위에서 언급한 ECMA-262의 함수들을 간접적으로 사용합니다. 정렬 및 포매팅 함수는 이 명세에서 Collator, NumberFormat, DateTimeFormat 생성자와 동일한 인자를 받아 compare 또는 format 메서드와 동일한 결과를 생성하도록 재정의됩니다. 대소문자 변환 함수는 선호하는 언어 목록을 받아들이도록 재정의됩니다.

Intl 객체는 이 명세에서 정의된 모든 기능을 패키징하여 이름 충돌을 방지합니다.

Note
API에는 다양한 포매터가 포함되어 있지만, 파싱 기능은 제공하지 않습니다. 이는 의도적인 결정이며, 장단점을 충분히 검토한 후 결론에 도달했습니다. 자세한 논의는 이슈 트래커를 참고하세요.

4.3 API 관례

모든 Intl 생성자는 클래스에 의해 정의된 것처럼 동작해야 하며, 함수로 호출될 때(NewTarget 없이) TypeError 예외를 던져야 합니다. 과거 판과의 호환성을 위해 %Intl.Collator%, %Intl.DateTimeFormat%, %Intl.NumberFormat%는 함수로 호출될 때마다 새로운 객체를 생성하여 반환합니다.

Note
ECMA 402 v1에서는 Intl 생성자가 기존 객체를 수신자로 받아 호출될 때 관련 내부 슬롯을 추가하여 해당 객체를 클래스의 인스턴스로 변환하는 동작을 지원했습니다. ECMA 402 v2에서는 기존 객체에 내부 슬롯을 추가하지 않도록 이 기능이 제거되었습니다. ECMA 402 v3에서는 생성자가 호출될 때 모든 객체에 기본 Intl 인스턴스를 체인하는 "규범적 선택적" 모드로 이 기능이 다시 추가되었습니다. 자세한 내용은 이슈 57을 참고하세요.

4.4 구현 종속성

국제화의 특성상, 이 명세는 여러 세부사항을 구현 종속적으로 남겨둬야 합니다:

  • 구현이 충분한 지역화로 지원하는 로케일의 집합: 언어학자들은 수천 개의 인간 언어를 기술했으며, IANA 언어 서브태그 레지스트리에는 로케일 식별자의 기반이 되는 7000개 이상의 주요 언어 서브태그가 포함되어 있습니다. Common Locale Data Repository와 같은 대규모 로케일 데이터 컬렉션도 모든 언어와 그 지역 또는 방언 변형의 극히 일부만을 다룹니다. 리소스가 제한된 장치를 대상으로 하는 구현은 이 집합을 더욱 줄여야 할 수도 있습니다.
  • 포매트 패턴과 같은 지역화의 정확한 형태: 많은 경우 로케일에 따라 달라지는 관습이 표준화되어 있지 않아 여러 형태가 공존하거나 시간이 지나면서 변화합니다. 다양한 국제화 라이브러리들이 서로 다른 형태를 구현했을 수 있으며, 그 중 어느 것도 실제로 잘못된 것은 아닙니다. 이 API가 기존 라이브러리 위에 구현될 수 있도록 이러한 변형을 허용해야 합니다.
  • 유니코드의 부분집합: 정렬과 같은 일부 연산은 전체 유니코드 문자 집합의 문자를 포함하는 문자열에 대해 동작합니다. 그러나 유니코드 표준과 ECMAScript 표준 모두 구현이 유니코드 문자 집합의 부분집합으로 기능을 제한할 수 있도록 허용합니다. 또한, 로케일 관습은 일반적으로 전체 유니코드 문자 집합에 대한 동작을 지정하지 않고, 해당 로케일에 관련된 문자에 대해서만 지정합니다. 유니코드 정렬 알고리즘은 전체 유니코드 문자 집합에 대한 기본 정렬 순서와 로컬 관습에 맞춘 맞춤 기능을 결합하지만, 부분집합과 맞춤은 여전히 동작의 차이를 초래합니다.

브라우저 구현에서는 특정 오리진에 대해 보이는 로케일, 통화, 달력, 숫자 시스템 및 기타 열거 가능한 항목의 초기 집합이 동일한 사용자 에이전트 문자열(엔진 및 플랫폼 버전)을 공유하는 모든 사용자에게 동일해야 합니다. 또한, 이러한 집합의 동적 변경은 사용자가 서로 구별될 수 있도록 해서는 안 됩니다. 이 제약은 국제화에 내재된 지문 채취 위험을 줄이기 위해 부과되었으며, 향후 개정에서 완화될 수 있습니다. 이 제약의 결과로, 브라우저 구현이 온디맨드 로케일 설치를 허용하고 특정 오리진에서 새로운 로케일 설치가 필요할 수 있는 요청을 처음 받을 때, 해당 로케일이 이미 설치되어 있는지 여부를 공개해서는 안 됩니다.

이 명세 전체에서 구현 및 로케일 종속 동작은 ILD로, 구현, 로케일, 숫자 시스템 종속 동작은 ILND로 지칭합니다.

4.4.1 구현 간 호환성

ECMA 402는 함수에서 사용하는 데이터의 스키마를 기술합니다. 내부 데이터는 구현 종속적이며, 시간이 지남에 따라 변경되고 구현마다 다를 수 있습니다. 이러한 변형은 프로그래머에게 보이며, 특정 출력에 의존하는 프로그램을 작성할 수도 있습니다. 그러나 이 명세는 잘 작성된 프로그램이 구현 간에 동작할 수 있도록 합리적인 제약을 기술하려고 합니다. 구현은 언어 데이터의 조화를 계속 노력해야 합니다.

5 표기 규칙

이 표준은 ECMA-262의 표기 규칙의 일부를 사용합니다:

Note
ECMA-262에서 설명한 바와 같이, 알고리즘은 ECMAScript 구성 요소의 요구되는 의미를 정확하게 명세하기 위해 사용되지만, 특정 구현 기술의 사용을 암시하는 것은 아닙니다. 내부 슬롯은 객체 값의 의미를 정의하기 위해 사용되지만 API의 일부가 아닙니다. 순전히 설명 목적으로 정의됩니다. API 구현은 내부 슬롯을 여기서 설명한 방식대로 생성하고 동작하는 것처럼 동작해야 합니다.

Record 명세 타입의 확장으로, “[[<name>]]” 표기는 변수 name이 String 값이어야 하며, 그 이름이 주어진 필드를 나타냅니다. 예를 들어, 변수 s"a" 값을 갖는 경우 [[<s>]]는 필드 [[a]]를 나타냅니다.

이 명세는 Normative Optional로 구분된 블록을 사용하여 ECMA 262의 Annex B의 의미를 나타냅니다. 즉, normative optional 섹션은 ECMAScript 호스트가 웹 브라우저일 때 필수입니다. 섹션의 내용은 규범적이지만 ECMAScript 호스트가 웹 브라우저가 아닌 경우 선택적입니다.

5.1 잘 알려진 내장 객체

다음 표는 Well-Known Intrinsic Objects에서 정의된 잘 알려진 내장 객체 표를 확장합니다.

Table 1: 잘 알려진 내장 객체 (확장)
내장 이름 글로벌 이름 ECMAScript 언어 연관
%Intl% Intl Intl 객체 (8)
%Intl.Collator% Intl.Collator Intl.Collator 생성자 (10.1)
%Intl.DateTimeFormat% Intl.DateTimeFormat Intl.DateTimeFormat 생성자 (11.1)
%Intl.DisplayNames% Intl.DisplayNames Intl.DisplayNames 생성자 (12.1)
%Intl.DurationFormat% Intl.DurationFormat Intl.DurationFormat 생성자 (13.1)
%Intl.ListFormat% Intl.ListFormat Intl.ListFormat 생성자 (14.1)
%Intl.Locale% Intl.Locale Intl.Locale 생성자 (15.1)
%Intl.NumberFormat% Intl.NumberFormat Intl.NumberFormat 생성자 (16.1)
%Intl.PluralRules% Intl.PluralRules Intl.PluralRules 생성자 (17.1)
%Intl.RelativeTimeFormat% Intl.RelativeTimeFormat Intl.RelativeTimeFormat 생성자 (18.1)
%Intl.Segmenter% Intl.Segmenter Intl.Segmenter 생성자 (19.1)
%IntlSegmentIteratorPrototype% Segment Iterator 객체의 프로토타입 (19.6.2)
%IntlSegmentsPrototype% Segments 객체의 프로토타입 (19.5.2)

6 Locale, Currency, Time Zone, Measurement Unit, Numbering System, Collation 및 Calendar의 식별

이 절은 이 명세에서 locale, currency, time zone, measurement unit, numbering system, collation, calendar 및 pattern string을 식별하는 데 사용되는 String 값을 설명한다.

6.1 대소문자 구분 및 대소문자 매핑

locale, currency, script 및 time zone을 식별하는 데 사용되는 String 값은 ASCII-case-insensitive 방식으로 해석되며, code unit 0x0041부터 0x005A까지(Unicode 문자 LATIN CAPITAL LETTER A부터 LATIN CAPITAL LETTER Z까지에 대응)를 대응하는 code unit 0x0061부터 0x007A까지(Unicode 문자 LATIN SMALL LETTER A부터 LATIN SMALL LETTER Z까지에 대응)와 동등하게 취급한다. 두 범위 모두 양끝을 포함한다. 다른 case folding 동등성은 적용되지 않는다.

Note
예를 들어, "ß" (U+00DF)는 "SS" (U+0053, U+0053)와 일치하거나 매핑되어서는 안 된다. "ı" (U+0131)는 "I" (U+0049)와 일치하거나 매핑되어서는 안 된다.

String 값 stringASCII-uppercasestring에서 ASCII lowercase letter code unit(0x0061부터 0x007A까지, 양끝 포함)이 나타날 때마다 대응하는 ASCII uppercase letter code unit(0x0041부터 0x005A까지, 양끝 포함)으로 대체하고, 다른 모든 code unit은 보존하여 string으로부터 도출된 String 값이다.

String 값 stringASCII-lowercasestring에서 ASCII uppercase letter code unit(0x0041부터 0x005A까지, 양끝 포함)이 나타날 때마다 대응하는 ASCII lowercase letter code unit(0x0061부터 0x007A까지, 양끝 포함)으로 대체하고, 다른 모든 code unit은 보존하여 string으로부터 도출된 String 값이다.

String 값 A의 ASCII-uppercase가 B의 ASCII-uppercase와 정확히 같은 code unit 시퀀스이면, String 값 A는 String 값 B에 대한 ASCII-case-insensitive match이다. Unicode code point 시퀀스 ABCodePointsToString(A)에 대한 ASCII-case-insensitive match이면 B에 대한 ASCII-case-insensitive match이다.

6.2 Language Tag

이 명세는 Unicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance에 정의된 Unicode BCP 47 locale identifier를 사용하여 locale을 식별하며, 이 명세의 알고리즘은 Section 3 Unicode Language and Locale Identifiers의 문법에 정의된 Unicode locale nonterminal을 참조한다. 이러한 각 identifier는 language tag라고도 할 수 있으며, 실제로 BCP 47에서 그 용어가 사용되는 의미에서 유효한 language tag이다. Unicode Technical Standard #35 Part 1 Core, Section 3.2.1 Canonical Unicode Locale Identifiers에 명시된 canonical form의 locale identifier를 "Unicode canonicalized locale identifier"라고 한다.

Locale identifier는 "-" (U+002D HYPHEN-MINUS) 문자로 구분되는 case-insensitive Unicode Basic Latin 영숫자 subtag로 구성되며, 단일 문자 subtag는 "singleton subtag"라고 한다. Unicode Technical Standard #35 Part 1 Core, Section 3.6 Unicode BCP 47 U Extension subtag 시퀀스가 광범위하게 사용되며, "Unicode locale extension sequence"라는 용어는 unicode_locale_extensions Unicode locale nonterminal에 의해 매칭될 수 있고 "-x-…" private use subtag sequence의 일부가 아닌 language tag의 가장 긴 substring을 설명한다. 이는 "-u-"로 시작하며, 바로 뒤따르는 singleton subtag가 아닌 모든 subtag와 그 앞의 "-" separator를 포함한다. 예를 들어, "en-US-u-fw-mon-x-u-ex-foobar"Unicode locale extension sequence"-u-fw-mon"이다.

모든 well-formed language tag는 이 명세가 정의하는 API와 함께 사용하기에 적절하지만, 구현은 이를 검증하기 위해 Unicode Common Locale Data Repository(CLDR) 데이터를 사용할 필요는 없다. 구현이 충분한 localization과 함께 지원하는 locale 및 따라서 language tag의 집합은 구현 정의이다. Intl 생성자는 요청된 language tag를 각 구현에서 지원하는 locale로 매핑한다.

6.2.1 IsWellFormedLanguageTag ( locale )

The abstract operation IsWellFormedLanguageTag takes argument locale (String) and returns Boolean. localeunicode_bcp47_locale_id의 well-formedness 제약을 따르는 well-formed language tag인지 여부를 결정한다. 이는 locale이 의미 있는 semantics를 전달하는지 여부를 고려하지 않으며, aliased subtag와 그 preferred replacement subtag를 구분하지 않고, canonical casing이나 subtag ordering을 요구하지도 않는다. It performs the following steps when called:

  1. lowerLocalelocaleASCII-lowercase로 둔다.
  2. lowerLocaleunicode_locale_id Unicode locale nonterminal에 의해 매칭될 수 없으면 false를 반환한다.
  3. lowerLocaleUnicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance에 설명된 backwards compatibility syntax 중 하나를 사용하면 false를 반환한다.
  4. baseNameGetLocaleBaseName(lowerLocale)으로 둔다.
  5. variantsGetLocaleVariants(baseName)로 둔다.
  6. variantsundefined가 아니면,
    1. variants가 중복 subtag를 포함하면 false를 반환한다.
  7. extensionsbaseName 뒤에 오는 lowerLocale의 접미사로 둔다.
  8. NOTE: pu_extensions Unicode locale nonterminal에 의해 매칭되는 "-x-…" private use subtag sequence는 무시되어야 하지만, 뒤따르는 내용이 없는 고립된 마지막 "x" subtag는 아래 검사에 영향을 주지 않는다.
  9. puIndexStringIndexOf(extensions, "-x-", 0)으로 둔다.
  10. puIndexnot-found가 아니면 extensionsextensions의 0부터 puIndex까지의 substring으로 설정한다.
  11. extensions가 빈 String이 아니면,
    1. extensions가 중복 singleton subtag를 포함하면 false를 반환한다.
    2. transformExtensiontransformed_extensions Unicode locale nonterminal에 의해 매칭되는 extensions의 가장 긴 substring으로 둔다. 그러한 substring이 없으면 true를 반환한다.
    3. Assert: transformExtension의 0부터 3까지의 substring"-t-"이다.
    4. tPrefixtransformExtension의 3부터의 substring으로 둔다.
    5. tlangtlang Unicode locale nonterminal에 의해 매칭되는 tPrefix의 가장 긴 prefix로 둔다. 그러한 prefix가 없으면 true를 반환한다.
    6. tlangVariantsGetLocaleVariants(tlang)로 둔다.
    7. tlangVariantsundefined가 아니면,
      1. tlangVariants가 중복 subtag를 포함하면 false를 반환한다.
  12. true를 반환한다.

6.2.2 CanonicalizeUnicodeLocaleId ( locale )

The abstract operation CanonicalizeUnicodeLocaleId takes argument locale (language tag) and returns Unicode canonicalized locale identifier. locale의 canonical하고 case-regularized된 형식을 반환한다. It performs the following steps when called:

  1. localeIdUnicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalization에 따라 locale을 canonical form으로 변환하기 위해 Processing LocaleIds 알고리즘을 수행한 결과인 String 값으로 둔다.
  2. localeIdUnicode locale extension sequencesubstring을 포함하면,
    1. extensionlocaleId 안의 Unicode locale extension sequencesubstring으로 이루어진 String 값으로 둔다.
    2. newExtension"-u"로 둔다.
    3. componentsUnicodeExtensionComponents(extension)로 둔다.
    4. components.[[Attributes]]의 각 요소 attr에 대해, 다음을 수행한다.
      1. newExtensionnewExtension, "-"attr의 문자열 연결로 설정한다.
    5. components.[[Keywords]]의 각 Record { [[Key]], [[Value]] } keyword에 대해, 다음을 수행한다.
      1. newExtensionnewExtension, "-"keyword.[[Key]]의 문자열 연결로 설정한다.
      2. keyword.[[Value]]가 빈 String이 아니면,
        1. newExtensionnewExtension, "-"keyword.[[Value]]의 문자열 연결로 설정한다.
    6. Assert: newExtension"-u"가 아니다.
    7. localeIdsubstring extension의 첫 번째 출현이 newExtension으로 대체된 localeId의 복사본으로 설정한다.
  3. localeId를 반환한다.
Note
단계 2는 반환된 language tagUnicode locale extension sequence가 다음을 포함하도록 보장한다:
  • 입력에서 중복된 attribute의 첫 번째 instance만, 그리고
  • 입력에서 주어진 key에 대한 첫 번째 keyword만.

6.2.3 DefaultLocale ( )

The implementation-defined abstract operation DefaultLocale takes no arguments and returns Unicode canonicalized locale identifier. 반환된 String 값은 host environment의 현재 locale에 대한 well-formed(6.2.1) 및 canonicalized(6.2.2) language tag를 나타낸다. 이는 Unicode locale extension sequence를 포함해서는 안 된다.

Note
반환된 값은 potential fingerprinting vector이다. browser environment에서는 추가적인 distinguishing information을 제공하지 않도록 navigator.language와 일치해야 한다.

6.3 Currency Code

이 명세는 ISO 4217에 정의된 3-letter currency code를 사용하여 currency를 식별한다. 그 canonical form은 uppercase이다.

모든 well-formed 3-letter ISO 4217 currency code가 허용된다. 그러나 localized currency symbol을 사용할 수 있는 currency code와 language tag의 조합 집합은 구현 의존이다. localized currency symbol을 사용할 수 없는 경우 ISO 4217 currency code가 형식화에 사용된다.

6.3.1 IsWellFormedCurrencyCode ( currency )

The abstract operation IsWellFormedCurrencyCode takes argument currency (String) and returns Boolean. currency 인수가 well-formed 3-letter ISO 4217 currency code를 나타내는지 검증한다. It performs the following steps when called:

  1. currency의 길이가 3이 아니면 false를 반환한다.
  2. normalizedcurrencyASCII-uppercase로 둔다.
  3. normalized가 0x0041부터 0x005A까지(Unicode 문자 LATIN CAPITAL LETTER A부터 LATIN CAPITAL LETTER Z까지에 대응) 밖의 code unit을 포함하면 false를 반환한다.
  4. true를 반환한다.

6.4 AvailableCanonicalCurrencies ( )

The implementation-defined abstract operation AvailableCanonicalCurrencies takes no arguments and returns String의 List. 반환된 Listlexicographic code unit order에 따라 정렬되며, Intl.DisplayNames 및 Intl.NumberFormat 객체의 기능을 구현이 제공하는 currency를 식별하는 고유하고, well-formed이며, uppercase canonicalized된 3-letter ISO 4217 currency code를 포함한다.

6.5 IANA Time Zone Database의 사용

이 명세를 채택하는 구현은 time zone aware여야 한다. 즉, 사용 가능한 named time zone identifier와 ECMAScript 계산 및 형식화에 사용되는 데이터를 제공하기 위해 IANA Time Zone Database https://www.iana.org/time-zones/를 사용해야 한다. 이 section은 time zone aware 구현이 IANA Time Zone Database를 어떻게 사용해야 하는지 정의한다. 어떤 String도 IANA Time Zone Database의 Zone name 또는 Link name이 아니면 available named time zone identifier가 될 수 없다. ECMAScript built-in 객체가 반환하는 available named time zone identifier는 IANA Time Zone Database에 있는 casing을 사용해야 한다.

IANA Time Zone Database의 각 Zone은 primary time zone identifier여야 하며, IANA Time Zone Database의 각 Link name은 대응하는 Zone name으로 resolve되는 non-primary time zone identifier여야 한다. 단, AvailableNamedTimeZoneIdentifiers에서 구현되는 다음 예외는 제외한다:

  • 역사적인 이유로, "UTC"primary time zone identifier여야 한다. "Etc/UTC", "Etc/GMT""GMT", 그리고 그중 하나로 resolve되는 모든 Link name은 "UTC"로 resolve되는 non-primary time identifier여야 한다.
  • zone.tab 파일의 “TZ” 열에 존재하는 모든 Link name은 primary time zone identifier여야 한다. 예를 들어, "Europe/Prague""Europe/Bratislava"는 모두 primary time zone identifier여야 한다. 이 요구사항은 각 ISO 3166-1 Alpha-2 country code마다 적어도 하나의 primary time zone identifier를 보장하고, 한 country의 time zone 규칙에 대한 미래 변경이 그 country들의 territorial boundary도 변경되지 않는 한 다른 country의 time zone을 사용하는 ECMAScript 프로그램에 영향을 주지 않도록 보장한다.
  • zone.tab 파일의 “TZ” 열에 나열되지 않고, 하나의 ISO 3166-1 Alpha-2 country code의 territory 안에 완전히 포함된 geographical area를 나타내는 모든 Link name은 같은 country code의 territory 안에 완전히 포함된 geographical area를 나타내는 primary identifier로 resolve되어야 한다. 예를 들어, "Atlantic/Jan_Mayen""Arctic/Longyearbyen"으로 resolve되어야 한다.
Note

IANA Time Zone Database는 어떤 available named time zone identifier가 primary인지에 영향을 주는 build option을 제공한다. 기본 build option은 서로 다른 country의 time zone을 merge한다. 예를 들어 "Atlantic/Reykjavik"은 Zone "Africa/Abidjan"에 대한 Link로 build된다. 지리적으로나 정치적으로 구별되는 location은 IANA Time Zone Database의 향후 버전에서 divergent time zone rule을 도입할 가능성이 있다. 위의 예외는 이러한 future-compatibility issue를 완화하는 역할을 한다.

Unicode Common Locale Data Repository(CLDR)는 어떤 available named time zone identifier가 primary 또는 non-primary인지 결정할 때 위 예외의 대부분을 구현한다. 구현 간 일관성을 위해 CLDR 데이터의 사용이 권장되지만, 필수는 아니다. CLDR 기반이 아닌 구현도 timezone.xml의 CLDR identifier 데이터를 사용할 수 있다. 구현은 IANA Time Zone Database를 직접 build할 수도 있다. 예를 들어 PACKRATDATA=backzone PACKRATLIST=zone.tab와 같은 build option을 사용하고, 위 요구사항을 준수하기 위해 필요한 post-processing을 수행할 수 있다.

IANA Time Zone Database는 일반적으로 1년에 5회에서 10회 사이로 업데이트된다. 이러한 업데이트는 새 Zone 또는 Link name을 추가할 수 있고, Zone을 Link로 변경할 수 있으며, 임의의 Zone과 연결된 UTC offset 및 transition을 변경할 수 있다. 구현은 IANA Time Zone Database 업데이트를 가능한 한 빨리 포함하는 것이 권장된다. 그러한 신속한 조치는 ECMAScript 프로그램이 time-zone-sensitive 계산을 정확히 수행하고, 외부 입력 또는 host environment가 제공하는 새로 추가된 available named time zone identifier를 사용할 수 있도록 보장한다.

IANA Time Zone Database 유지관리자는 안정성을 위해 노력하지만, 드문 경우(평균적으로 1년에 한 번 미만) Zone이 새 Zone으로 대체될 수 있다. 예를 들어, 2022년에 "Europe/Kiev"는 새 "Europe/Kyiv" Zone으로 resolve되는 Link로 deprecated되었다. deprecated Link를 renamed time zone identifier라고 하며, 새로 추가된 Zone을 replacement time zone identifier라고 한다.

이러한 드문 변경으로 인한 disruption을 줄이기 위해, 구현은 각 replacement time zone identifier를 처음에는 기존 renamed time zone identifier로 resolve되는 non-primary time zone identifier로 추가해야 한다. 이는 ECMAScript 프로그램이 두 identifier를 모두 인식할 수 있게 하지만, ECMAScript 프로그램이 아직 이를 인식하지 못하는 다른 시스템으로 replacement time zone identifier를 보낼 가능성도 줄인다. rename waiting period가 지난 후, 구현은 새 Zone을 primary time zone identifier로 승격시키는 동시에 renamed time zone identifier를 non-primary로 강등해야 한다. 다른 시스템이 업데이트될 충분한 시간을 제공하기 위해, 권장되는 rename waiting period는 2년이다. 그러나 이는 정확하거나 dynamic할 필요는 없다. 대신 구현은 time zone data를 업데이트하는 일반적인 release process의 일부로 waiting period 후 replacement time zone identifier를 primary로 만들어야 한다.

waiting period는 새 Zone이 기존 Zone을 대체하기 위해 추가된 경우에만 적용되어야 한다. 기존 Zone과 Link가 swap된 경우에는 renaming이 발생하지 않았으므로 waiting period가 필요하지 않다.

구현이 agent의 lifetime 동안 time zone 정보를 revise한다면, available named time zone identifier의 list, 임의의 available named time zone identifier와 연결된 primary time zone identifier, 그리고 임의의 available named time zone identifier와 연결된 UTC offset 및 transition이 그 agent가 이전에 관찰한 결과와 일관되어야 한다. 이 요구사항을 지원하는 복잡성 때문에, 구현은 각 agent의 lifetime 동안 IANA Time Zone Database의 완전히 일관된 copy를 유지하는 것이 권장된다.

이 section은 21.4.1.19를 보완하지만 대체하지는 않는다.

6.5.1 AvailableNamedTimeZoneIdentifiers ( )

The implementation-defined abstract operation AvailableNamedTimeZoneIdentifiers takes no arguments and returns Time Zone Identifier RecordList. 그 결과는 이 구현의 모든 available named time zone identifier와 각 available named time zone identifier에 대응하는 primary time zone identifier를 설명한다. List는 각 Time Zone Identifier Record[[Identifier]] 필드에 따라 정렬된다.

이 정의는 21.4.1.23에 제공된 정의를 대체한다.

  1. identifiers를 IANA Time Zone Database의 각 Zone 또는 Link name의 String 값을 포함하는 List로 둔다.
  2. Assert: identifiers의 어떤 요소도 다른 요소와 ASCII-case-insensitive match가 아니다.
  3. identifierslexicographic code unit order에 따라 정렬한다.
  4. result를 새 빈 List로 둔다.
  5. identifiers의 각 요소 identifier에 대해, 다음을 수행한다.
    1. primaryidentifier로 둔다.
    2. identifier가 IANA Time Zone Database의 Link name이고 identifier가 IANA Time Zone Database의 zone.tab의 “TZ” 열에 존재하지 않으면,
      1. zone을 IANA Time Zone Database에서 Link name을 resolve하는 규칙에 따라 identifier가 resolve되는 Zone name으로 둔다.
      2. zone"Etc/"로 시작하면,
        1. primaryzone으로 설정한다.
      3. 그렇지 않으면,
        1. identifierCountryCodeidentifier에 대응하는 geographical area를 territory로 포함하는 ISO 3166-1 Alpha-2 country code로 둔다.
        2. zoneCountryCodezone에 대응하는 geographical area를 territory로 포함하는 ISO 3166-1 Alpha-2 country code로 둔다.
        3. identifierCountryCodezoneCountryCode이면,
          1. primaryzone으로 설정한다.
        4. 그렇지 않으면,
          1. countryCodeLineCount를 IANA Time Zone Database의 zone.tab 파일에서 “country-code” 열이 identifierCountryCode인 줄 수로 둔다.
          2. countryCodeLineCount가 1이면,
            1. countryCodeLine을 IANA Time Zone Database의 zone.tab 파일에서 “country-code” 열이 identifierCountryCode인 줄로 둔다.
            2. primarycountryCodeLine의 “TZ” 열 내용으로 설정한다.
          3. 그렇지 않으면,
            1. backzoneundefined로 둔다.
            2. backzoneLinkLines를 IANA Time Zone Database의 backzone 파일에서 "Link " 또는 "#PACKRATLIST zone.tab Link " 중 하나로 시작하는 줄의 List로 둔다.
            3. backzoneLinkLines의 각 요소 line에 대해, 다음을 수행한다.
              1. iStringIndexOf(line, "Link ", 0)으로 둔다.
              2. linelinei + 5부터의 substring으로 설정한다.
              3. backzoneAndLinkStringSplitToList(line, " ")로 둔다.
              4. Assert: backzoneAndLink는 적어도 두 요소를 가지며, backzoneAndLink[0]과 backzoneAndLink[1]은 모두 available named time zone identifier이다.
              5. backzoneAndLink[1]이 identifier이면,
                1. Assert: backzoneundefined이다.
                2. backzonebackzoneAndLink[0]으로 설정한다.
            4. Assert: backzoneundefined가 아니다.
            5. primarybackzone으로 설정한다.
    3. primary"Etc/UTC", "Etc/GMT" 또는 "GMT" 중 하나이면 primary"UTC"로 설정한다.
    4. primaryreplacement time zone identifier이고 그 rename waiting period가 끝나지 않았으면,
      1. renamedIdentifierprimary가 대체한 renamed time zone identifier로 둔다.
      2. primaryrenamedIdentifier로 설정한다.
    5. recordTime Zone Identifier Record { [[Identifier]]: identifier, [[PrimaryIdentifier]]: primary }로 둔다.
    6. recordresult에 append한다.
  6. Assert: resultutcRecord.[[Identifier]]"UTC"이고 utcRecord.[[PrimaryIdentifier]]"UTC"Time Zone Identifier Record utcRecord를 포함한다.
  7. result를 반환한다.
Note 1

위 알고리즘은 Link를 primary time zone identifier로 resolve하기 위한 것으로, International Components for Unicode(ICU)의 icu::TimeZone::getIanaID() 동작 및 Unicode Common Locale Data Repository(CLDR)의 time zone identifier data 유지관리 process에 대응하도록 의도되었다.

이 알고리즘은 IANA Time Zone Database의 zone.tabbackzone 파일의 데이터를 사용하여 ISO 3166-1 Alpha-2 country code의 boundary를 넘지 않고 Link를 primary time zone identifier로 resolve한다. Link의 country code가 zone.tab에 한 줄만 있으면, 그 줄이 primary time zone identifier를 결정한다. 그러나 그 country code가 zone.tab에 여러 줄을 가지면, backzone의 historical mapping을 사용해 올바른 primary time zone identifier를 식별해야 한다.

예를 들어, IANA Time Zone Database의 기본 build option이 "Pacific/Truk"(country code "FM")를 "Pacific/Port_Moresby"(country code "PG")에 대한 Link로 식별하는 경우 이를 resolve하려면, zone.tab의 “country-code” 열에서 "FM"에 대응하는 줄을 확인해야 한다. 그러한 줄이 하나뿐이면, 그 줄의 “TZ” 열이 "Pacific/Truk"와 연결된 primary time zone identifier를 결정한다. 그러나 zone.tab에 여러 "FM" 줄이 있으면, backzone을 검사해야 하며 "Link Pacific/Chuuk Pacific/Truk"와 같은 줄은 "Pacific/Chuuk"를 primary time zone identifier로 사용하게 한다.

zone.tab은 mapping data의 preferred source임에 주의하라. backzone mapping은 드문 경우 ISO 3166-1 Alpha-2 country code의 boundary를 넘을 수 있기 때문이다. 예를 들어, "Atlantic/Jan_Mayen"(country code "SJ")은 backzone에서 "Europe/Oslo"(country code "NO")로 매핑된다. IANA Time Zone Database의 2024a release 기준으로, "Atlantic/Jan_Mayen"이 이러한 일이 발생하는 유일한 경우이다.

Note 2
IANA Time Zone Database의 time zone identifier는 시간이 지남에 따라 변경될 수 있다. 최소한, 구현은 surrounding agent의 lifetime 동안 AvailableNamedTimeZoneIdentifiers의 결과 변경을 GetAvailableNamedTimeZoneIdentifier가 허용하는 변경으로 제한하는 것이 권장된다. 이러한 권장사항을 지원하는 복잡성 때문에, AvailableNamedTimeZoneIdentifiers의 결과는 surrounding agent의 lifetime 동안 동일하게 유지되는 것이 권장된다.

6.5.2 GetAvailableNamedTimeZoneIdentifier ( timeZoneIdentifier )

The abstract operation GetAvailableNamedTimeZoneIdentifier takes argument timeZoneIdentifier (String) and returns Time Zone Identifier Record 또는 empty. timeZoneIdentifieravailable named time zone identifier이면, AvailableNamedTimeZoneIdentifiers가 반환한 ListRecord 중 하나를 반환한다. 그렇지 않으면 empty가 반환된다. It performs the following steps when called:

  1. AvailableNamedTimeZoneIdentifiers()의 각 요소 record에 대해, 다음을 수행한다.
    1. record.[[Identifier]]timeZoneIdentifier에 대한 ASCII-case-insensitive match이면 record를 반환한다.
  2. empty를 반환한다.
Note
임의의 timeZoneIdentifier 또는 이에 대한 ASCII-case-insensitive match인 임의 값에 대해, 결과 Time Zone Identifier Recordsurrounding agent의 lifetime 동안 동일한 field 값을 포함해야 한다. 또한 surrounding agent의 lifetime 동안 time zone identifier가 primary에서 non-primary로 동적으로 변경되지 않아야 한다. 즉, timeZoneIdentifier가 GetAvailableNamedTimeZoneIdentifier의 이전 호출 결과의 [[PrimaryIdentifier]] 필드에 대한 ASCII-case-insensitive match이면, GetAvailableNamedTimeZoneIdentifier(timeZoneIdentifier)는 [[Identifier]][[PrimaryIdentifier]]Time Zone Identifier Record를 반환해야 한다. 이러한 요구사항을 지원하는 복잡성 때문에, AvailableNamedTimeZoneIdentifiers의 결과(따라서 GetAvailableNamedTimeZoneIdentifier도)는 surrounding agent의 lifetime 동안 동일하게 유지되는 것이 권장된다.

6.5.3 AvailablePrimaryTimeZoneIdentifiers ( )

The abstract operation AvailablePrimaryTimeZoneIdentifiers takes no arguments and returns String의 List. 반환된 List는 IANA Time Zone Database에서 지원되는 Zone 및 Link name의 정렬된 List이다. It performs the following steps when called:

  1. recordsAvailableNamedTimeZoneIdentifiers()로 둔다.
  2. result를 새 빈 List로 둔다.
  3. records의 각 요소 timeZoneIdentifierRecord에 대해, 다음을 수행한다.
    1. timeZoneIdentifierRecord.[[Identifier]]timeZoneIdentifierRecord.[[PrimaryIdentifier]]이면,
      1. timeZoneIdentifierRecord.[[Identifier]]result에 append한다.
  4. result를 반환한다.

6.5.4 StringSplitToList ( string, separator )

The abstract operation StringSplitToList takes arguments string (String) and separator (String) and returns String의 List. 반환된 Listseparator를 포함하지 않지만 separator의 occurrence가 바로 앞 및/또는 바로 뒤에 있는 string의 서로소 substring을 모두 포함한다. 그러한 각 substringseparator의 인접한 occurrence 사이, string의 맨 처음에 있는 separator 앞, 또는 string의 맨 끝에 있는 separator 뒤에서는 빈 String이 되지만, 그 외에는 비어 있지 않다. It performs the following steps when called:

  1. Assert: string은 빈 String이 아니다.
  2. Assert: separator는 빈 String이 아니다.
  3. separatorLengthseparator의 길이로 둔다.
  4. substrings를 새 빈 List로 둔다.
  5. i를 0으로 둔다.
  6. jStringIndexOf(string, separator, 0)으로 둔다.
  7. jnot-found가 아닌 동안 반복한다.
    1. substringstringi부터 j까지의 substring으로 둔다.
    2. substringsubstrings에 append한다.
    3. ij + separatorLength로 설정한다.
    4. jStringIndexOf(string, separator, i)로 설정한다.
  8. substringstringi부터의 substring으로 둔다.
  9. substringsubstrings에 append한다.
  10. substrings를 반환한다.

6.6 Measurement Unit Identifier

이 명세는 Unicode Technical Standard #35 Part 2 General, Section 6.2 Unit Identifiers에 정의된 core unit identifier(또는 동등하게 core unit ID)를 사용하여 measurement unit을 식별한다. 그 canonical form은 Unicode Basic Latin lowercase letter(U+0061 LATIN SMALL LETTER A부터 U+007A LATIN SMALL LETTER Z까지)만 포함하고, zero or more medial hyphen(U+002D HYPHEN-MINUS)을 포함하는 string이다.

제한된 core unit identifier 집합만 허용된다. 허용되지 않은 core unit identifier를 사용하려고 하면 RangeError가 발생한다.

6.6.1 IsWellFormedUnitIdentifier ( unitIdentifier )

The abstract operation IsWellFormedUnitIdentifier takes argument unitIdentifier (String) and returns Boolean. unitIdentifier 인수가 허용된 single unit이거나 두 허용된 single unit의 나눗셈으로 형성된 complex unit인 well-formed core unit identifier를 나타내는지 검증한다. It performs the following steps when called:

  1. IsSanctionedSingleUnitIdentifier(unitIdentifier)가 true이면,
    1. true를 반환한다.
  2. numeratorAndDenominatorStringSplitToList(unitIdentifier, "-per-")로 둔다.
  3. numeratorAndDenominator가 정확히 2개의 요소를 가지지 않으면 false를 반환한다.
  4. IsSanctionedSingleUnitIdentifier(numeratorAndDenominator[0])가 false이면 false를 반환한다.
  5. IsSanctionedSingleUnitIdentifier(numeratorAndDenominator[1])가 false이면 false를 반환한다.
  6. true를 반환한다.

6.6.2 IsSanctionedSingleUnitIdentifier ( unitIdentifier )

The abstract operation IsSanctionedSingleUnitIdentifier takes argument unitIdentifier (String) and returns Boolean. unitIdentifier 인수가 이 명세의 현재 버전에서 허용된 single unit identifier 중 하나인지 검증한다. 이는 Common Locale Data Repository release 38 unit validity data의 부분 집합이며, list는 시간이 지남에 따라 늘어날 수 있다. Unicode Technical Standard #35 Part 2 General, Section 6.2 Unit Identifiers에서 논의된 것처럼, single unit identifier는 다른 unit identifier의 곱셈 또는 나눗셈으로 구성되지 않은 core unit identifier이다. It performs the following steps when called:

  1. unitIdentifier가 아래 Table 2에 나열되어 있으면 true를 반환한다.
  2. 그렇지 않으면 false를 반환한다.
Table 2: ECMAScript에서 사용이 허용된 single unit
Single Unit Identifier
acre
bit
byte
celsius
centimeter
day
degree
fahrenheit
fluid-ounce
foot
gallon
gigabit
gigabyte
gram
hectare
hour
inch
kilobit
kilobyte
kilogram
kilometer
liter
megabit
megabyte
meter
microsecond
mile
mile-scandinavian
milliliter
millimeter
millisecond
minute
month
nanosecond
ounce
percent
petabyte
pound
second
stone
terabit
terabyte
week
yard
year

6.6.3 AvailableCanonicalUnits ( )

The abstract operation AvailableCanonicalUnits takes no arguments and returns String의 List. 반환된 Listlexicographic code unit order에 따라 정렬되며, 헤더 행을 제외하고 Table 2의 모든 행에 나열된 simple unit identifier의 고유 값으로 구성된다.

6.7 Numbering System Identifier

이 명세는 Unicode Technical Standard #35 Part 3 Numbers, Section 1 Numbering Systems가 참조하는 이름에 대응하는 numbering system identifier를 사용하여 numbering system을 식별한다. 그 canonical form은 Unicode Basic Latin lowercase letter(U+0061 LATIN SMALL LETTER A부터 U+007A LATIN SMALL LETTER Z까지)만 포함하는 string이다.

6.7.1 AvailableCanonicalNumberingSystems ( )

The implementation-defined abstract operation AvailableCanonicalNumberingSystems takes no arguments and returns String의 List. 반환된 Listlexicographic code unit order에 따라 정렬되며, Intl.DateTimeFormat, Intl.NumberFormat 및 Intl.RelativeTimeFormat 객체의 기능을 구현이 제공하는 numbering system을 식별하는 고유한 canonical numbering systems identifier를 포함한다. 이 List는 헤더 행을 제외하고 Table 30의 모든 행의 Numbering System 값을 포함해야 한다.

6.8 Collation Type

이 명세는 Unicode Technical Standard #35 Part 5 Collation, Section 3.1 Collation Types에 정의된 collation type을 사용하여 collation을 식별한다. 그 canonical form은 Unicode Basic Latin lowercase letter(U+0061 LATIN SMALL LETTER A부터 U+007A LATIN SMALL LETTER Z까지)만 포함하고 zero or more medial hyphen(U+002D HYPHEN-MINUS)을 포함하는 string이다.

6.8.1 AvailableCanonicalCollations ( )

The implementation-defined abstract operation AvailableCanonicalCollations takes no arguments and returns String의 List. 반환된 Listlexicographic code unit order에 따라 정렬되며, Intl.Collator 객체의 기능을 구현이 제공하는 collation을 식별하는 고유한 canonical collation type을 포함한다.

6.9 Calendar Type

이 명세는 Unicode Technical Standard #35 Part 4 Dates, Section 2 Calendar Elements에 정의된 calendar type을 사용하여 calendar를 식별한다. 그 canonical form은 Unicode Basic Latin lowercase letter(U+0061 LATIN SMALL LETTER A부터 U+007A LATIN SMALL LETTER Z까지)만 포함하고 zero or more medial hyphen(U+002D HYPHEN-MINUS)을 포함하는 string이다.

6.9.1 AvailableCalendars ( )

The implementation-defined abstract operation AvailableCalendars takes no arguments and returns String의 List. 반환된 Listlexicographic code unit order에 따라 정렬되며, Intl.DateTimeFormat 객체의 기능을 구현이 제공하는 calendar를 식별하는 canonical form(6.9)의 고유한 calendar type을 포함한다. 여기에는 그 alias도 포함된다(예: "islamicc""islamic-civil"을 둘 다 포함하거나 둘 다 포함하지 않음). List"iso8601"을 포함해야 한다.

6.10 Pattern String Type

Pattern String"{key}" 형식의 substring을 0개 이상 포함하는 String 값이며, 여기서 key는 ASCII word character의 요소로만 구성된 임의의 non-empty sequence일 수 있다. 추상 pattern string의 syntax는 구현 세부사항이며 ECMA-402 사용자에게 노출되지 않는다.

7 표준 내장 ECMAScript 객체에 대한 요구 사항

이 문서에서 달리 명시되지 않는 한, 이 표준에서 설명된 객체, 함수 및 생성자는 ECMAScript Standard Built-in Objects에 표준 내장 ECMAScript 객체에 대해 지정된 일반적인 요구 사항 및 제한 사항의 적용을 받습니다.

8 Intl 객체

Intl 객체는:

8.1 Intl 객체의 값 속성

8.1.1 Intl [ %Symbol.toStringTag% ]

%Symbol.toStringTag% 속성의 초기값은 String 값 "Intl"이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } 속성을 가진다.

8.2 Intl 객체의 생성자 속성

Intl.Locale을 제외하고, 다음 각 생성자는 locale-sensitive 서비스를 제공하는 객체를 생성하는 서비스 생성자이다.

8.2.1 Intl.Collator ( . . . )

10를 보라.

8.2.2 Intl.DateTimeFormat ( . . . )

11를 보라.

8.2.3 Intl.DisplayNames ( . . . )

12를 보라.

8.2.4 Intl.DurationFormat ( . . . )

13를 보라.

8.2.5 Intl.ListFormat ( . . . )

14를 보라.

8.2.6 Intl.Locale ( . . . )

15를 보라.

8.2.7 Intl.NumberFormat ( . . . )

16를 보라.

8.2.8 Intl.PluralRules ( . . . )

17를 보라.

8.2.9 Intl.RelativeTimeFormat ( . . . )

18를 보라.

8.2.10 Intl.Segmenter ( . . . )

19를 보라.

8.3 Intl 객체의 함수 속성

8.3.1 Intl.getCanonicalLocales ( locales )

getCanonicalLocales 메서드가 인수 locales와 함께 호출되면 다음 단계가 수행된다:

  1. localeList를 ? CanonicalizeLocaleList(locales)로 둔다.
  2. CreateArrayFromList(localeList)를 반환한다.

8.3.2 Intl.supportedValuesOf ( key )

supportedValuesOf 메서드가 인수 key와 함께 호출되면 다음 단계가 수행된다:

  1. key를 ? ToString(key)으로 설정한다.
  2. key"calendar"이면,
    1. list를 새 빈 List로 둔다.
    2. AvailableCalendars()의 각 요소 identifier에 대해, 다음을 수행한다.
      1. canonicalCanonicalizeUValue("ca", identifier)로 둔다.
      2. identifiercanonical이면,
        1. identifierlist에 추가한다.
  3. 그렇지 않고 key"collation"이면,
    1. listAvailableCanonicalCollations( )로 둔다.
  4. 그렇지 않고 key"currency"이면,
    1. listAvailableCanonicalCurrencies( )로 둔다.
  5. 그렇지 않고 key"numberingSystem"이면,
    1. listAvailableCanonicalNumberingSystems( )로 둔다.
  6. 그렇지 않고 key"timeZone"이면,
    1. listAvailablePrimaryTimeZoneIdentifiers( )로 둔다.
  7. 그렇지 않고 key"unit"이면,
    1. listAvailableCanonicalUnits( )로 둔다.
  8. 그렇지 않으면,
    1. RangeError 예외를 던진다.
  9. CreateArrayFromList( list )를 반환한다.

9 Locale 및 Parameter Negotiation

서비스 생성자localesoptions 인수가 나타내는 요청을 구현의 실제 기능과 조정하기 위해 공통 pattern을 사용한다. 그 공통 동작은 기능을 설명하는 내부 슬롯, 이 내부 슬롯을 사용하는 추상 연산, 그리고 아래에 정의된 특수 데이터 유형의 관점에서 여기 설명된다.

Available Locales List는 임의 순서의 중복 없는 language tagList이며, 각 language tagwell-formed이고, canonicalized되어 있으며, Unicode locale extension sequence를 가지지 않는다. 이는 구현이 특정 context 안에서 기능을 제공하는 모든 locale을 나타낸다.

Language Priority List는 내림차순 우선순위의 locale preference 시퀀스를 나타내는 well-formedcanonicalized language tagList이다. 이는 BCP 47RFC 4647 section 2.3에 정의된 같은 이름의 용어에 대응하지만, "*" 요소를 금지하고 canonicalized된 내용만 포함한다.

Resolution Option Descriptor[[Key]](string, 보통 [[RelevantExtensionKeys]] List의 요소)와 [[Property]](string) 필드를 가진 Record이며, 선택적으로 [[Type]](boolean 또는 string)과 [[Values]](empty 또는 ECMAScript 언어 값의 List) 중 하나 또는 둘 모두를 추가로 가질 수 있다. 이는 객체 생성 중 locale resolution과 관련된 options를 읽는 방법을 설명한다.

9.1 Service Constructor의 내부 슬롯

각 service constructor는 다음 내부 슬롯을 가진다:

  • [[AvailableLocales]]Available Locales List이다. 이는 DefaultLocale이 반환하는 값을 반드시 포함해야 한다. 또한 하나보다 많은 subtag를 가진 각 요소에 대해, ResolveLocale에서 잠재적 fallback으로 작동하도록 같은 language subtag와 뒤따르는 같은 subtag의 strict subset(즉, 하나 이상을 생략)을 가진 덜 좁은 language tag도 포함해야 한다. 특히 language subtag, script subtag 및 region subtag를 가진 각 요소에는 같은 language subtag와 region subtag만으로 구성되지만 script subtag가 빠진 다른 요소가 함께 있어야 한다. 예:
    • [[AvailableLocales]]"de-DE"를 포함하면, "de"도 포함해야 한다(이는 "de-AT""de-CH" 같은 요청 locale을 만족시키기 위해 선택될 수 있다).
    • [[AvailableLocales]]"az-Latn-AZ"를 포함하면, "az-AZ"도 포함해야 한다(이는 "az-Cyrl"이 사용할 수 없는 경우 "az-Cyrl-AZ" 같은 요청 locale을 만족시키기 위해 선택될 수 있다).
  • [[RelevantExtensionKeys]]는 생성된 객체의 기능과 관련된, Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions에 정의된 Unicode locale extension sequence key의 List이다.
  • [[ResolutionOptionDescriptors]]는 객체 생성 중 options를 읽는 데 사용되는 Resolution Option DescriptorList이다.
  • [[SortLocaleData]][[SearchLocaleData]](Intl.Collator용)와 [[LocaleData]](그 밖의 모든 service constructor용)는 Record이다. service constructor에 특정한 필드 외에도, 이러한 각 Record[[AvailableLocales]]에 포함된 각 locale에 대한 필드를 가진다. 그러한 각 locale 이름 필드의 값은 Record이며, 그 안에서 [[RelevantExtensionKeys]]의 각 요소는 해당 Unicode locale extension sequence key에 대해 관련 locale에서 구현이 지원하는 type value를 나타내는 비어 있지 않은 String List 값을 가진 필드의 이름을 식별하고, 첫 번째 요소는 그 locale에서 해당 key의 기본값을 제공한다.
Note
예를 들어, DateTimeFormat 구현은 [[AvailableLocales]] 내부 슬롯에 language tag "fa-IR"을 포함할 수 있으며, (11.2.3에 따라) [[RelevantExtensionKeys]] 내부 슬롯에 key "ca", "hc""nu"를 포함해야 한다. 그 locale의 기본 calendar는 보통 "persian"이지만, 구현은 "gregory", "islamic""islamic-civil"도 지원할 수 있다. 따라서 DateTimeFormat [[LocaleData]] 내부 슬롯의 Record는 값이 { [[ca]]: « "persian", "gregory", "islamic", "islamic-civil" », [[hc]]: « … », [[nu]]: « … » }와 같은 Record인 [[fa-IR]] 필드를 포함하고, 같은 값 형태를 가지지만 List의 요소가 다른 locale 이름 필드들도 함께 포함한다.

9.2 추상 연산

9.2.1 CanonicalizeLocaleList ( locales )

The abstract operation CanonicalizeLocaleList takes argument locales (ECMAScript 언어 값) and returns Language Priority List를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. localesundefined이면,
    1. 새 빈 List를 반환한다.
  2. seen을 새 빈 List로 둔다.
  3. locales가 String이거나 locales가 Object이고 locales[[InitializedLocale]] 내부 슬롯을 가지면,
    1. localesObjCreateArrayFromListlocales »)로 둔다.
  4. 그렇지 않으면,
    1. localesObj를 ? ToObject(locales)로 둔다.
  5. length를 ? LengthOfArrayLike(localesObj)로 둔다.
  6. k를 0으로 둔다.
  7. k < length인 동안 반복한다.
    1. propertyKey를 ! ToString(𝔽(k))로 둔다.
    2. exists를 ? HasProperty(localesObj, propertyKey)로 둔다.
    3. existstrue이면,
      1. element를 ? Get(localesObj, propertyKey)로 둔다.
      2. element가 String도 아니고 Object도 아니면 TypeError 예외를 던진다.
      3. element가 Object이고 element[[InitializedLocale]] 내부 슬롯을 가지면,
        1. tagelement.[[Locale]]로 둔다.
      4. 그렇지 않으면,
        1. tag를 ? ToString(element)로 둔다.
      5. IsWellFormedLanguageTag(tag)가 false이면 RangeError 예외를 던진다.
      6. canonicalizedTagCanonicalizeUnicodeLocaleId(tag)로 둔다.
      7. seencanonicalizedTag를 포함하지 않으면 canonicalizedTagseen에 append한다.
    4. kk + 1로 설정한다.
  8. seen을 반환한다.
Note 1
비규범적 요약: 이 추상 연산은 locales 인수를 array로 해석하고, 그 요소를 List에 복사하면서 요소가 well-formed language tag인지 검증하고 canonicalize하며, 중복을 생략한다.
Note 2
element가 String 또는 Object일 것을 요구한다는 것은 Number 값 NaN이 Min Nan Chinese를 의미하는 language tag "nan"으로 해석되지 않는다는 뜻이다.

9.2.2 CanonicalizeUValue ( ukey, uvalue )

The abstract operation CanonicalizeUValue takes arguments ukey (Unicode Technical Standard #35 Part 1 Core Section 3.6.1 Key and Type Definitions에 정의된 Unicode locale extension sequence key) and uvalue (String) and returns String. 반환된 String은 ukey의 값으로서 uvalue의 canonical하고 case-regularized된 형식이다. It performs the following steps when called:

  1. lowerValueuvalueASCII-lowercase로 둔다.
  2. canonicalizedUnicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalization Section 5 Canonicalizing Syntax, Processing LocaleIds에 따라 lowerValue를 key ukey의 값으로 canonicalize한 결과인 String 값으로 둔다.
  3. NOTE: 구현은 Common Locale Data Repository(https://cldr.unicode.org/에서 이용 가능)가 제공하는 common/bcp47의 'u' extension data를 사용하는 것이 권장된다.
  4. canonicalized를 반환한다.

9.2.3 LookupMatchingLocaleByPrefix ( availableLocales, requestedLocales )

The abstract operation LookupMatchingLocaleByPrefix takes arguments availableLocales (Available Locales List) and requestedLocales (Language Priority List) and returns [[locale]](Unicode canonicalized locale identifier) 및 [[extension]](Unicode locale extension sequence 또는 empty) 필드를 가진 Record 또는 undefined. Unicode locale extension sequence를 무시하고, BCP 47RFC 4647 section 3.4에 정의된 lookup 알고리즘을 사용하여 requestedLocales를 만족시키는 availableLocales의 최선의 요소를 결정한다. 기본값이 아닌 match가 발견되면, availableLocales에서 matching language tag를 포함하는 [[locale]] 필드와 requestedLocales의 대응하는 요소의 Unicode locale extension sequence(또는 requested language tag에 그러한 sequence가 없으면 empty)를 포함하는 [[extension]] 필드를 가진 Record를 반환한다. It performs the following steps when called:

  1. requestedLocales의 각 요소 locale에 대해, 다음을 수행한다.
    1. extensionempty로 둔다.
    2. localeUnicode locale extension sequence를 포함하면,
      1. extensionlocaleUnicode locale extension sequence로 설정한다.
      2. localeUnicode locale extension sequence가 제거된 locale인 String 값으로 설정한다.
    3. prefixlocale로 둔다.
    4. prefix가 빈 String이 아닌 동안 반복한다.
      1. availableLocalesprefix를 포함하면 Record { [[locale]]: prefix, [[extension]]: extension }를 반환한다.
      2. prefix"-" (code unit 0x002D HYPHEN-MINUS)를 포함하면 posprefix 안의 마지막 "-" occurrence의 index로 두고, 그렇지 않으면 pos를 0으로 둔다.
      3. pos ≥ 2이고 prefixpos - 2부터 pos - 1까지의 substring"-"인 동안 반복한다.
        1. pospos - 2로 설정한다.
      4. prefixprefix의 0부터 pos까지의 substring으로 설정한다.
  2. undefined를 반환한다.
Note
requested locale이 Unicode Technical Standard #35 Part 1 Core BCP 47 T Extension subtag sequence를 포함하는 경우, 이 알고리즘의 truncation은 일시적으로 유효하지 않은 language tag를 생성할 수 있다. 그러나 availableLocales는 유효한 language tag만 포함하므로 그중 어느 것도 반환되지 않는다.

9.2.4 LookupMatchingLocaleByBestFit ( availableLocales, requestedLocales )

The implementation-defined abstract operation LookupMatchingLocaleByBestFit takes arguments availableLocales (Available Locales List) and requestedLocales (Language Priority List) and returns [[locale]](Unicode canonicalized locale identifier) 및 [[extension]](Unicode locale extension sequence 또는 empty) 필드를 가진 Record, 또는 undefined. Unicode locale extension sequence를 무시하고, requestedLocales를 만족시키는 availableLocales의 최선의 요소를 결정한다. 알고리즘은 구현 의존이지만, requested locale의 일반적 사용자가 LookupMatchingLocaleByPrefix 알고리즘이 생성한 결과만큼은 좋다고 여길 결과를 생성해야 한다. 기본값이 아닌 match가 발견되면, availableLocales에서 matching language tag를 포함하는 [[locale]] 필드와 requestedLocales의 대응하는 요소의 Unicode locale extension sequence(또는 requested language tag에 그러한 sequence가 없으면 empty)를 포함하는 [[extension]] 필드를 가진 Record를 반환한다.

9.2.5 UnicodeExtensionComponents ( extension )

The abstract operation UnicodeExtensionComponents takes argument extension (Unicode locale extension sequence) and returns [[Attributes]][[Keywords]] 필드를 가진 Record. extension을 고유한 attribute의 List와 고유한 key를 가진 keywordList로 분해한다. attribute 또는 keyword key가 처음 이후 반복해서 나타나는 경우는 무시된다. It performs the following steps when called:

  1. 단언: extension의 ASCII 소문자화 결과는 extension이다.
  2. 단언: extension의 0부터 3까지의 부분 문자열은 "-u-"이다.
  3. attributes를 새 빈 List로 둔다.
  4. keywords를 새 빈 List로 둔다.
  5. keywordundefined로 둔다.
  6. sizeextension의 길이로 둔다.
  7. k를 3으로 둔다.
  8. k < size인 동안 반복한다.
    1. eStringIndexOf(extension, "-", k)로 둔다.
    2. enot-found이면 lengthsize - k로 두고, 그렇지 않으면 lengthe - k로 둔다.
    3. subtagextension에서 k부터 k + length까지의 부분 문자열로 둔다.
    4. 참고: 키워드는 첫 번째가 길이 2의 key이고, 이후의 것들(존재하는 경우)은 길이가 3부터 8까지의 포괄 구간에 있으며, 중간의 "-" 구분자와 함께 값을 구성하는 하위 태그들의 시퀀스이다. attribute는 모든 키워드보다 앞서는, 길이가 3부터 8까지의 포괄 구간에 있는 단일 하위 태그이다.
    5. 단언: length ≥ 2.
    6. keywordundefined이고 length ≠ 2이면,
      1. subtagattributes의 요소가 아니면, subtagattributes에 추가한다.
    7. 그렇지 않고 length = 2이면,
      1. keywordRecord { [[Key]]: subtag, [[Value]]: 빈 String }으로 설정한다.
      2. keywords[[Key]]keyword.[[Key]]인 요소를 포함하지 않으면, keywordkeywords에 추가한다.
    8. 그렇지 않고 keyword.[[Value]]가 빈 String이면,
      1. keyword.[[Value]]subtag로 설정한다.
    9. 그렇지 않으면,
      1. keyword.[[Value]]keyword.[[Value]], "-", 그리고 subtag의 문자열 연결로 설정한다.
    10. kk + length + 1로 설정한다.
  9. Record { [[Attributes]]: attributes, [[Keywords]]: keywords }를 반환한다.

9.2.6 InsertUnicodeExtensionAndCanonicalize ( locale, attributes, keywords )

The abstract operation InsertUnicodeExtensionAndCanonicalize takes arguments locale (language tag), attributes (String의 List), and keywords (RecordList) and returns Unicode canonicalized locale identifier. attributeskeywordsUnicode locale extension sequencelocale에 통합하고 canonicalized된 결과를 반환한다. It performs the following steps when called:

  1. Assert: localeUnicode locale extension sequence를 포함하지 않는다.
  2. extension"-u"로 둔다.
  3. attributes의 각 요소 attr에 대해, 다음을 수행한다.
    1. extensionextension, "-"attr의 문자열 연결로 설정한다.
  4. keywords의 각 Record { [[Key]], [[Value]] } keyword에 대해, 다음을 수행한다.
    1. extensionextension, "-"keyword.[[Key]]의 문자열 연결로 설정한다.
    2. keyword.[[Value]]가 빈 String이 아니면 extensionextension, "-"keyword.[[Value]]의 문자열 연결로 설정한다.
  5. extension"-u"이면 CanonicalizeUnicodeLocaleId(locale)를 반환한다.
  6. privateIndexStringIndexOf(locale, "-x-", 0)으로 둔다.
  7. privateIndexnot-found이면,
    1. newLocalelocaleextension의 문자열 연결로 둔다.
  8. 그렇지 않으면,
    1. preExtensionlocale의 0부터 privateIndex까지의 substring으로 둔다.
    2. postExtensionlocaleprivateIndex부터의 substring으로 둔다.
    3. newLocalepreExtension, extensionpostExtension의 문자열 연결로 둔다.
  9. Assert: IsWellFormedLanguageTag(newLocale)는 true이다.
  10. CanonicalizeUnicodeLocaleId(newLocale)를 반환한다.

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

The abstract operation ResolveLocale takes arguments availableLocales (Available Locales List), requestedLocales (Language Priority List), options (Record), relevantExtensionKeys (String의 List), and localeData (Record) and returns Record. BCP 47RFC 4647 section 3에 정의된 "lookup"을 수행하며, Unicode locale extension sequence를 무시하고 options.[[localeMatcher]]에 의해 지정된 LookupMatchingLocaleByBestFit 알고리즘 또는 LookupMatchingLocaleByPrefix 알고리즘을 사용하여 requestedLocales를 만족시키는 availableLocales의 최선의 요소를 결정한다. 그리고 localeData의 대응하는 data와 relevantExtensionKeys의 각 요소에 대한 resolved value(기본적으로 matched locale의 data에서 오며, requested Unicode locale extension sequence가 존재하면 그 data로 대체되고, 이어서 options가 존재하면 그 data로 대체됨)를 함께 포함하는 match의 표현을 반환한다. requestedLocales에서 매칭된 요소가 Unicode locale extension sequence를 포함하면, 반환된 Record[[Locale]] 필드에 있는 language tag로 복사되되, relevantExtensionKeys 안에 포함되지 않은 key 값을 가진 keyword Unicode locale nonterminal 또는 options의 다른 값에 의해 대체된 type 값은 생략된다. It performs the following steps when called:

  1. matcheroptions.[[localeMatcher]]로 둔다.
  2. matcher"lookup"이면,
    1. matchLookupMatchingLocaleByPrefix(availableLocales, requestedLocales)로 둔다.
  3. 그렇지 않으면,
    1. matchLookupMatchingLocaleByBestFit(availableLocales, requestedLocales)로 둔다.
  4. matchundefined이면, matchRecord { [[locale]]: DefaultLocale(), [[extension]]: empty }로 설정한다.
  5. foundLocalematch.[[locale]]로 둔다.
  6. foundLocaleDatalocaleData.[[<foundLocale>]]로 둔다.
  7. 단언: foundLocaleDataRecord이다.
  8. result를 새 Record로 둔다.
  9. result.[[LocaleData]]foundLocaleData로 설정한다.
  10. match.[[extension]]empty가 아니면,
    1. componentsUnicodeExtensionComponents(match.[[extension]])로 둔다.
    2. keywordscomponents.[[Keywords]]로 둔다.
  11. 그렇지 않으면,
    1. keywords를 새 빈 List로 둔다.
  12. supportedKeywords를 새 빈 List로 둔다.
  13. relevantExtensionKeys의 각 요소 key에 대해, 다음을 수행한다.
    1. keyLocaleDatafoundLocaleData.[[<key>]]로 둔다.
    2. 단언: keyLocaleDataList이다.
    3. valuekeyLocaleData[0]로 둔다.
    4. 단언: value는 String이거나 valuenull이다.
    5. supportedKeywordempty로 둔다.
    6. keywords[[Key]]key인 요소를 포함하면,
      1. entry[[Key]]keykeywords의 요소로 둔다.
      2. requestedValueentry.[[Value]]로 둔다.
      3. requestedValue가 빈 String이 아니면,
        1. keyLocaleDatarequestedValue를 포함하면,
          1. valuerequestedValue로 설정한다.
          2. supportedKeywordRecord { [[Key]]: key, [[Value]]: value }로 설정한다.
      4. 그렇지 않고 keyLocaleData"true"를 포함하면,
        1. value"true"로 설정한다.
        2. supportedKeywordRecord { [[Key]]: key, [[Value]]: 빈 String }으로 설정한다.
    7. 단언: options는 [[<key>]] 필드를 가진다.
    8. optionsValueoptions.[[<key>]]로 둔다.
    9. 단언: optionsValue는 String이거나, optionsValueundefined 또는 null 중 하나이다.
    10. optionsValue가 String이면,
      1. ukeykey의 ASCII 소문자화 결과로 둔다.
      2. optionsValueCanonicalizeUValue(ukey, optionsValue)로 설정한다.
      3. optionsValue가 빈 String이면,
        1. optionsValue"true"로 설정한다.
    11. SameValue(optionsValue, value)가 false이고 keyLocaleDataoptionsValue를 포함하면,
      1. valueoptionsValue로 설정한다.
      2. supportedKeywordempty로 설정한다.
    12. supportedKeywordempty가 아니면, supportedKeywordsupportedKeywords에 추가한다.
    13. result.[[<key>]]를 value로 설정한다.
  14. supportedKeywords가 비어 있지 않으면,
    1. supportedAttributes를 새 빈 List로 둔다.
    2. foundLocaleInsertUnicodeExtensionAndCanonicalize(foundLocale, supportedAttributes, supportedKeywords)로 설정한다.
  15. result.[[Locale]]foundLocale로 설정한다.
  16. result를 반환한다.

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

The abstract operation ResolveOptions takes arguments ctor (service constructor), localeData (Record), locales (ECMAScript 언어 값), and options (ECMAScript 언어 값) and optional arguments specialBehaviours (enumList) and modifyResolutionOptions (하나의 parameter를 가진 Abstract Closure) and returns [[Options]](Object), [[ResolvedLocale]](Record), [[ResolutionOptions]](Record) 필드를 가진 Record를 포함하는 정상 완료 또는 throw 완료. ctor의 입력을 읽고 이를 locale로 resolve한다. It performs the following steps when called:

  1. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  2. specialBehaviours가 존재하고 require-options를 포함하며 optionsundefined이면 TypeError 예외를 던진다.
  3. specialBehaviours가 존재하고 coerce-options를 포함하면 options를 ? CoerceOptionsToObject(options)로 설정한다. 그렇지 않으면 options를 ? GetOptionsObject(options)로 설정한다.
  4. matcher를 ? GetOption(options, "localeMatcher", string, « "lookup", "best fit" », "best fit")로 둔다.
  5. optRecord { [[localeMatcher]]: matcher }로 둔다.
  6. ctor.[[ResolutionOptionDescriptors]]의 각 Resolution Option Descriptor desc에 대해, 다음을 수행한다.
    1. desc[[Type]] 필드를 가지면 typedesc.[[Type]]으로 둔다. 그렇지 않으면 typestring으로 둔다.
    2. desc[[Values]] 필드를 가지면 valuesdesc.[[Values]]로 둔다. 그렇지 않으면 valuesempty로 둔다.
    3. value를 ? GetOption(options, desc.[[Property]], type, values, undefined)로 둔다.
    4. valueundefined가 아니면,
      1. value를 ! ToString(value)로 설정한다.
      2. valuetype Unicode locale nonterminal에 의해 매칭될 수 없으면 RangeError 예외를 던진다.
    5. keydesc.[[Key]]로 둔다.
    6. opt.[[<key>]]를 value로 설정한다.
  7. modifyResolutionOptions가 존재하면 ! modifyResolutionOptions(opt)를 수행한다.
  8. resolutionResolveLocale(ctor.[[AvailableLocales]], requestedLocales, opt, ctor.[[RelevantExtensionKeys]], localeData)로 둔다.
  9. Record { [[Options]]: options, [[ResolvedLocale]]: resolution, [[ResolutionOptions]]: opt }를 반환한다.

9.2.9 FilterLocales ( availableLocales, requestedLocales, options )

The abstract operation FilterLocales takes arguments availableLocales (Available Locales List), requestedLocales (Language Priority List), and options (ECMAScript 언어 값) and returns Unicode canonicalized locale identifierList를 포함하는 정상 완료 또는 throw 완료. BCP 47RFC 4647 section 3에 정의된 "filtering"을 수행하여, options에 지정된 LookupMatchingLocaleByBestFit 알고리즘 또는 LookupMatchingLocaleByPrefix 알고리즘 중 하나를 사용할 때 availableLocales가 matching locale을 포함하는 requestedLocales의 요소들을 반환하고, 그 상대 순서를 보존한다. It performs the following steps when called:

  1. options를 ? CoerceOptionsToObject(options)로 설정한다.
  2. matcher를 ? GetOption(options, "localeMatcher", string, « "lookup", "best fit" », "best fit")로 둔다.
  3. subset을 새 빈 List로 둔다.
  4. requestedLocales의 각 요소 locale에 대해, 다음을 수행한다.
    1. matcher"lookup"이면,
      1. matchLookupMatchingLocaleByPrefix(availableLocales, « locale »)로 둔다.
    2. 그렇지 않으면,
      1. matchLookupMatchingLocaleByBestFit(availableLocales, « locale »)로 둔다.
    3. matchundefined가 아니면 localesubset에 append한다.
  5. CreateArrayFromList(subset)를 반환한다.

9.2.10 CoerceOptionsToObject ( options )

The abstract operation CoerceOptionsToObject takes argument options (ECMAScript 언어 값) and returns Object를 포함하는 정상 완료 또는 throw 완료. optionsGetOption과 함께 사용하기에 적합한 Object로 coerce하고, 기본값은 빈 Object로 한다. 이 연산은 null이 아닌 primitive 값을 object로 coerce하므로, 새 기능에서는 GetOptionsObject를 선호하여 사용하지 않는 것이 권장된다. It performs the following steps when called:

  1. optionsundefined이면,
    1. OrdinaryObjectCreate(null)를 반환한다.
  2. ToObject(options)를 반환한다.

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

The abstract operation GetOption takes arguments options (Object), propertyKey (property key), type (boolean 또는 string), values (empty 또는 ECMAScript 언어 값의 List), and default (required 또는 ECMAScript 언어 값) and returns ECMAScript 언어 값을 포함하는 정상 완료 또는 throw 완료. options의 지정된 property 값을 추출하고, 필요한 type으로 변환하며, valuesempty가 아니면 그 값이 values에 의해 허용되는지 확인하고, 값이 undefined이면 default로 대체한다. It performs the following steps when called:

  1. value를 ? Get(options, propertyKey)로 둔다.
  2. valueundefined이면,
    1. defaultrequired이면 TypeError 예외를 던진다.
    2. default를 반환한다.
  3. typeboolean이면,
    1. valueToBoolean(value)로 설정한다.
  4. 그렇지 않으면,
    1. Assert: typestring이다.
    2. value를 ? ToString(value)로 설정한다.
  5. valuesempty가 아니고 valuesvalue를 포함하지 않으면 RangeError 예외를 던진다.
  6. value를 반환한다.

9.2.12 GetBooleanOrStringNumberFormatOption ( options, propertyKey, stringValues, fallback )

The abstract operation GetBooleanOrStringNumberFormatOption takes arguments options (Object), propertyKey (property key), stringValues (String의 List), and fallback (ECMAScript 언어 값) and returns Boolean, String 또는 fallback 중 하나를 포함하는 정상 완료 또는 throw 완료. 제공된 options 객체에서 propertyKey라는 이름의 property 값을 추출한다. 그 값이 undefined이면 fallback을 반환하고, 그 값이 true이면 true를 반환하며, 그 값이 false로 coerce되면 false를 반환하고, 그렇지 않으면 이를 String으로 coerce한 뒤 stringValues에 의해 허용되면 그 결과를 반환한다. It performs the following steps when called:

  1. value를 ? Get(options, propertyKey)로 둔다.
  2. valueundefined이면 fallback을 반환한다.
  3. valuetrue이면 true를 반환한다.
  4. ToBoolean(value)가 false이면 false를 반환한다.
  5. value를 ? ToString(value)로 설정한다.
  6. stringValuesvalue를 포함하지 않으면 RangeError 예외를 던진다.
  7. value를 반환한다.

9.2.13 DefaultNumberOption ( value, minimum, maximum, fallback )

The abstract operation DefaultNumberOption takes arguments value (ECMAScript 언어 값), minimum (정수), maximum (정수), and fallback (정수 또는 undefined) and returns 정수 또는 undefined 중 하나를 포함하는 정상 완료 또는 throw 완료. value를 정수로 변환하고, 허용 범위 안에 있는지 확인하며, 필요하면 fallback 값을 채운다. It performs the following steps when called:

  1. valueundefined이면 fallback을 반환한다.
  2. value를 ? ToNumber(value)로 설정한다.
  3. valuefinite가 아니거나 (value) < minimum이거나 (value) > maximum이면 RangeError 예외를 던진다.
  4. floor((value))를 반환한다.

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

The abstract operation GetNumberOption takes arguments options (Object), propertyKey (String), minimum (정수), maximum (정수), and fallback (정수 또는 undefined) and returns 정수 또는 undefined 중 하나를 포함하는 정상 완료 또는 throw 완료. 제공된 options 객체에서 propertyKey라는 이름의 property 값을 추출하고, 이를 정수로 변환하며, 허용 범위 안에 있는지 확인하고, 필요하면 fallback 값을 채운다. It performs the following steps when called:

  1. value를 ? Get(options, propertyKey)로 둔다.
  2. DefaultNumberOption(value, minimum, maximum, fallback)을 반환한다.

9.2.15 PartitionPattern ( pattern )

The abstract operation PartitionPattern takes argument pattern (Pattern String) and returns [[Type]](String) 및 [[Value]](String 또는 undefined) 필드를 가진 RecordList. [[Type]]"literal"이면 [[Value]] 필드는 String 값이 되고, 그렇지 않으면 undefined가 된다. It performs the following steps when called:

  1. result를 새 빈 List로 둔다.
  2. placeholderEnd를 -1로 둔다.
  3. placeholderStartStringIndexOf(pattern, "{", 0)으로 둔다.
  4. placeholderStartnot-found가 아닌 동안 반복한다.
    1. literalpatternplaceholderEnd + 1부터 placeholderStart까지의 substring으로 둔다.
    2. literal이 빈 String이 아니면,
      1. Record { [[Type]]: "literal", [[Value]]: literal }를 result에 append한다.
    3. placeholderEndStringIndexOf(pattern, "}", placeholderStart)로 설정한다.
    4. Assert: placeholderEndnot-found가 아니며 placeholderStart < placeholderEnd이다.
    5. placeholderNamepatternplaceholderStart + 1부터 placeholderEnd까지의 substring으로 둔다.
    6. Record { [[Type]]: placeholderName, [[Value]]: undefined }를 result에 append한다.
    7. placeholderStartStringIndexOf(pattern, "{", placeholderEnd)로 설정한다.
  5. tailpatternplaceholderEnd + 1부터의 substring으로 둔다.
  6. tail이 빈 String이 아니면,
    1. Record { [[Type]]: "literal", [[Value]]: tail }를 result에 append한다.
  7. result를 반환한다.

10 Collator 객체

10.1 Intl.Collator 생성자

Intl.Collator 생성자:

  • %Intl.Collator%이다.
  • Intl 객체"Collator" 속성의 초기값이다.

Intl 객체의 모든 서비스 생성자 속성에 공통된 동작은 9.1에서 명시된다.

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

Intl.Collator 함수가 선택적 인수 localesoptions와 함께 호출될 때, 다음 단계가 수행된다:

  1. NewTarget이 undefined이면, newTarget을 활성 함수 객체로 한다. 그렇지 않으면 newTarget을 NewTarget으로 한다.
  2. internalSlotsList를 « [[InitializedCollator]], [[Locale]], [[Usage]], [[Collation]], [[Numeric]], [[CaseFirst]], [[Sensitivity]], [[IgnorePunctuation]], [[BoundCompare]] »로 한다.
  3. collator를 ? OrdinaryCreateFromConstructor(newTarget, "%Intl.Collator.prototype%", internalSlotsList)로 한다.
  4. NOTE: locale 데이터의 소스는 ResolveOptions"usage" 속성에 따라 달라지지만, 다음 두 단계는 그 조회보다 앞서 관찰 가능하게 실행되어야 하며(ResolveOptions 내부에서 반복되어서는 안 됨).
  5. requestedLocales를 ? CanonicalizeLocaleList(locales)로 한다.
  6. options를 ? CoerceOptionsToObject(options)로 한다.
  7. usage를 ? GetOption(options, "usage", string, « "sort", "search" », "sort")로 한다.
  8. collator.[[Usage]]usage를 설정한다.
  9. usage"sort"이면
  10. localeData%Intl.Collator%.[[SortLocaleData]]로 한다.
  11. 그렇지 않으면,
  12. localeData%Intl.Collator%.[[SearchLocaleData]]로 한다.
  13. optionsResolution을 ? ResolveOptions(%Intl.Collator%, localeData, CreateArrayFromList(requestedLocales), options)로 한다.
  14. resolvedLocaleoptionsResolution.[[ResolvedLocale]]로 한다.
  15. collator.[[Locale]]resolvedLocale .[[Locale]]를 설정한다.
  16. resolvedLocale .[[co]]null이면, collation"default"로 한다. 그렇지 않으면 collationresolvedLocale .[[co]]로 한다.
  17. collator.[[Collation]]collation을 설정한다.
  18. collator.[[Numeric]]SameValue(resolvedLocale .[[kn]], "true")를 설정한다.
  19. collator.[[CaseFirst]]resolvedLocale .[[kf]]를 설정한다.
  20. resolvedLocaleDataresolvedLocale .[[LocaleData]]로 한다.
  21. usage"sort"이면, defaultSensitivity"variant"로 한다. 그렇지 않으면 defaultSensitivityresolvedLocaleData.[[sensitivity]]로 한다.
  22. collator.[[Sensitivity]]에 ? GetOption(options, "sensitivity", string, « "base", "accent", "case", "variant" », defaultSensitivity)를 설정한다.
  23. defaultIgnorePunctuationresolvedLocaleData.[[ignorePunctuation]]로 한다.
  24. collator.[[IgnorePunctuation]]에 ? GetOption(options, "ignorePunctuation", boolean, empty, defaultIgnorePunctuation)를 설정한다.
  25. collator를 반환한다.
Note
"search" 값의 "usage" 옵션에 연관된 collation은 문자열을 찾는 데만 사용해야 하며, 이 collation은 특정 순서가 보장되지 않는다. 이 동작은 Unicode Technical Standard #35 Part 1 Core, Unicode Collation IdentifierUnicode Technical Standard #10 Unicode Collation Algorithm, Searching and Matching에서 설명된다.

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 메서드가 localesoptions 인수로 호출될 때, 다음 단계가 수행된다:

  1. availableLocales%Intl.Collator%.[[AvailableLocales]]로 한다.
  2. requestedLocales를 ? CanonicalizeLocaleList(locales)로 한다.
  3. FilterLocales(availableLocales, requestedLocales, options)를 반환한다.

10.2.3 내부 슬롯

[[AvailableLocales]] 내부 슬롯의 값은 9.1에서 설명된 제약 내에서 구현에 따라 정의된다. [[RelevantExtensionKeys]] 내부 슬롯의 값은 "co" 요소를 반드시 포함하고, "kf""kn" 요소를 임의로 포함할 수 있으며, 다른 요소는 포함하지 않아야 한다.

Note
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions에서는 collation에 관련된 10개의 locale 확장 키를 설명한다: "co"는 collator 사용 및 특화, "ka"는 대체 처리, "kb"는 두 번째 수준 가중치의 역방향, "kc"는 대소문자 수준, "kf"는 대소문자 우선, "kh"는 히라가나 4차, "kk"는 정규화, "kn"는 숫자, "kr"는 재정렬, "ks"는 collation 강도, 그리고 "vt"는 variable top. 그러나 Collator는 사용을 options 객체의 "usage" 속성으로, 대체 처리를 "ignorePunctuation" 속성으로, 대소문자 수준과 강도를 "sensitivity" 속성으로 지정해야 한다. 언어 태그의 "co" 키는 collator 특화에만 지원되며, "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 값 locale에 대해:

  • [[SortLocaleData]].[[<locale>]].[[co]][[SearchLocaleData]].[[<locale>]].[[co]]의 첫 번째 요소는 반드시 null이어야 한다.
  • "standard""search" 값은 어떤 [[SortLocaleData]].[[<locale>]].[[co]][[SearchLocaleData]].[[<locale>]].[[co]] List의 요소로 사용되어서는 안 된다.
  • [[SearchLocaleData]].[[<locale>]]에는 "base", "accent", "case", "variant" 중 하나의 String 값인 [[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 ( )

이 함수는 객체 초기화 시 계산된 locale과 옵션에 접근할 수 있게 한다.

  1. collatorthis 값으로 한다.
  2. RequireInternalSlot(collator, [[InitializedCollator]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 한다.
  4. Table 3의 각 행(헤더 행 제외)을 테이블 순서대로 반복한다:
  5. 현재 행의 Property 값을 propertyKey로 한다.
  6. 현재 행의 Internal Slot 값에 해당하는 collator의 내부 슬롯 값을 value로 한다.
  7. 현재 행에 Extension Key 값이 있으면,
  8. extensionKey를 현재 행의 Extension Key 값으로 한다.
  9. %Intl.Collator%.[[RelevantExtensionKeys]]extensionKey가 포함되지 않으면,
  10. valueundefined로 설정한다.
  11. valueundefined가 아니면,
  12. CreateDataPropertyOrThrow(options, propertyKey, value)를 수행한다.
  13. options를 반환한다.
Table 3: Collator 인스턴스의 Resolved Options
Internal Slot Property Extension Key
[[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 객체의 정렬 순서에 따라 두 문자열을 비교하는 함수를 반환한다.

Intl.Collator.prototype.compare는 접근자 속성으로, set 접근자 함수는 undefined이고, get 접근자 함수는 다음 단계를 수행한다:

  1. collatorthis 값으로 한다.
  2. RequireInternalSlot(collator, [[InitializedCollator]])를 수행한다.
  3. collator.[[BoundCompare]]undefined이면,
  4. func10.3.3.1에서 정의된 새로운 내장 함수 객체로 한다.
  5. func.[[Collator]]collator를 설정한다.
  6. collator.[[BoundCompare]]func를 설정한다.
  7. collator.[[BoundCompare]]를 반환한다.
Note
반환된 함수는 collator에 바인딩되어 있으므로 Array.prototype.sort나 다른 함수에 직접 전달할 수 있다.

10.3.3.1 Collator 비교 함수

Collator 비교 함수는 [[Collator]] 내부 슬롯을 가진 익명 내장 함수이다.

Collator 비교 함수 func가 인수 xy로 호출될 때, 다음 단계가 수행된다:

  1. collatorfunc.[[Collator]]로 한다.
  2. collator가 객체이며 [[InitializedCollator]] 내부 슬롯을 가지고 있음을 단언한다.
  3. x가 제공되지 않으면, xundefined로 한다.
  4. y가 제공되지 않으면, yundefined로 한다.
  5. xString를 ? ToString(x)로 한다.
  6. yString를 ? ToString(y)로 한다.
  7. CompareStrings(collator, xString, yString)를 반환한다.

Collator 비교 함수의 "length" 속성은 2𝔽이다.

10.3.3.2 CompareStrings ( collator, x, y )

The implementation-defined abstract operation CompareStrings takes arguments collator (an Intl.Collator), x (a String), and y (a String) and returns a Number, but not NaN. 반환된 Number는 xy의 구현에 따라 정의된 locale 민감한 문자열 비교 결과를 나타낸다. 결과는 collator의 유효 locale 및 collation 옵션에 따라 문자열 값의 정렬 순서에 대응하도록 의도되며, xy보다 앞서면 음수, xy보다 뒤면 양수, 그 외에는 0(상대적 순서 없음)을 반환한다. 문자열 값은 ECMA-262, 6.1.4에서 설명된 대로 UTF-16 코드 유닛 시퀀스로 해석되어야 하며, 문자열 내 서러게이트 페어(0xD800~0xDBFF 범위의 코드 유닛 뒤에 0xDC00~0xDFFF 범위의 코드 유닛)는 해당 코드 포인트로 해석되어야 한다.

아래에서 설명된 동작은 문자열의 "base letter" 시퀀스의 locale 민감한 식별에 따라 달라지며, 서로 다른 base letter는 항상 다르게 비교된다(이를 포함하는 문자열도 다르게 비교됨). 같은 base letter의 변형을 대소문자, 발음 구별 부호 등으로 비교하는 결과는 collator.[[Sensitivity]]에 따라 달라진다:

Table 4: Collator Sensitivity의 효과
[[Sensitivity]] 설명 "a" vs. "á" "a" vs. "A"
"base" 같은 base letter는 대소문자나 발음 구별 부호의 차이와 관계없이 다르게 비교되지 않는다. 동등 동등
"accent" 같은 base letter는 발음 구별 부호 등으로만 다르게 비교되며, 대소문자 차이는 무시된다. 다름 동등
"case" 같은 base letter는 대소문자 차이로만 다르게 비교되며, 발음 구별 부호 등은 무시된다. 동등 다름
"variant" 같은 base letter는 대소문자, 발음 구별 부호, 기타 차이로 다르게 비교된다. 다름 다름
Note 1
입력 코드 포인트에서 base letter로의 매핑에는 임의의 수축, 확장, 충돌이 포함될 수 있으며, 발음 구별 부호가 있는 특정 문자에 특별 처리를 적용할 수 있다. 예를 들어, 스웨덴어에서 "ö"는 "o"와 다른 base letter이고, "v"와 "w"는 같은 base letter로 간주된다. 슬로바키아어에서는 "ch"가 하나의 base letter이고, 영어에서는 "æ"가 "a"와 "e"로 시작하는 base letter 시퀀스이다.

collator.[[IgnorePunctuation]]true이면, 구두점은 무시된다(예: 구두점만 다른 문자열은 동등하게 비교됨).

locale 확장 키로 설정 가능한 옵션의 해석은 Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions를 참조한다.

실제 반환 값은 추가 정보를 인코딩할 수 있도록 구현에 따라 정의되지만, 특정 collator에 대해 xy의 함수로서 전체 문자열 집합에 대해 일관된 비교자를 정의하는 총 정렬이어야 한다. 또한 Unicode 표준에 따라 정규 등가를 인식하고, 구별 가능한 문자열이 정규 등가일 때 +0𝔽를 반환해야 한다.

Note 2
CompareStrings 추상 연산은 Unicode Technical Standard #10: Unicode Collation Algorithm을 따라 구현하는 것이 권장되며, collator의 유효 locale 및 collation 옵션에 맞게 tailoring을 적용해야 한다. 구현에서는 Common Locale Data Repository(https://cldr.unicode.org/)에서 제공하는 tailoring을 사용하는 것이 권장된다.
Note 3
같은 resolved options를 가진 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]]는 collation에 사용되는 locale의 언어 태그를 가진 문자열 값이다.
  • [[Usage]]"sort" 또는 "search" 중 하나의 문자열 값으로, collator 사용을 식별한다.
  • [[Sensitivity]]"base", "accent", "case", "variant" 중 하나의 문자열 값으로, collator의 민감도를 식별한다.
  • [[IgnorePunctuation]]는 Boolean 값으로, 비교 시 구두점을 무시할지 지정한다.
  • [[Collation]]은 collation에 사용되는 Unicode Collation Identifier를 나타내는 문자열 값이며, "standard""search" 값은 허용되지 않고, "default" 값은 허용된다.

Intl.Collator 인스턴스는 Table 3에서 내부 슬롯 이름에 해당하는 키가 Intl.Collator의 [[RelevantExtensionKeys]] 내부 슬롯에 포함된 경우 다음 내부 슬롯도 가진다:

  • [[Numeric]]는 Boolean 값으로, 숫자 정렬 사용 여부를 지정한다.
  • [[CaseFirst]]"upper", "lower", "false" 중 하나의 문자열 값이다.

마지막으로, Intl.Collator 인스턴스는 compare 접근자(10.3.3)에서 반환된 함수를 캐시하는 [[BoundCompare]] 내부 슬롯을 가진다.

11 DateTimeFormat 객체

11.1 Intl.DateTimeFormat 생성자

Intl.DateTimeFormat 생성자는:

  • %Intl.DateTimeFormat%이다.
  • Intl 객체"DateTimeFormat" 속성의 초기값이다.

Intl 객체의 모든 서비스 생성자 속성에 공통되는 동작은 9.1에 명시되어 있다.

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

Intl.DateTimeFormat 함수가 선택적 인수 localesoptions로 호출되면, 다음 단계가 수행된다:

  1. NewTarget이 undefined이면 newTarget을 활성 함수 객체로 두고, 그렇지 않으면 newTarget을 NewTarget으로 둔다.
  2. dateTimeFormat을 ? CreateDateTimeFormat(newTarget, locales, options, any, date)로 둔다.
  3. 구현이 4.3 Note 1의 규범적 선택 생성자 모드를 지원하면,
    1. thisthis 값으로 둔다.
    2. ChainDateTimeFormat(dateTimeFormat, NewTarget, this)를 반환한다.
  4. dateTimeFormat을 반환한다.

11.1.1.1 ChainDateTimeFormat ( dateTimeFormat, newTarget, this )

The abstract operation ChainDateTimeFormat takes arguments dateTimeFormat (Intl.DateTimeFormat), newTarget (ECMAScript 언어 값), and this (ECMAScript 언어 값) and returns Object를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. newTargetundefined이고 ? OrdinaryHasInstance(%Intl.DateTimeFormat%, this)가 true이면,
    1. DefinePropertyOrThrow(this, %Intl%.[[FallbackSymbol]], PropertyDescriptor { [[Value]]: dateTimeFormat, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false })를 수행한다.
    2. this를 반환한다.
  2. dateTimeFormat을 반환한다.

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

The abstract operation CreateDateTimeFormat takes arguments newTarget (생성자), locales (ECMAScript 언어 값), options (ECMAScript 언어 값), required (date, time, 또는 any), and defaults (date, time, 또는 all) and returns DateTimeFormat 객체를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. dateTimeFormat을 ? OrdinaryCreateFromConstructor(newTarget, "%Intl.DateTimeFormat.prototype%", « [[InitializedDateTimeFormat]], [[Locale]], [[Calendar]], [[NumberingSystem]], [[TimeZone]], [[HourCycle]], [[DateStyle]], [[TimeStyle]], [[DateTimeFormat]], [[BoundFormat]] »)로 둔다.
  2. specialOptionsRecord { [[Hour12]]: undefined }로 둔다.
  3. modifyResolutionOptionsspecialOptions를 캡처하고 호출될 때 다음 단계를 수행하는, 매개변수 (options)를 가진 새 Abstract Closure로 둔다:
    1. specialOptions.[[Hour12]]options.[[hour12]]로 설정한다.
    2. options에서 [[hour12]] 필드를 제거한다.
    3. specialOptions.[[Hour12]]undefined가 아니면, options.[[hc]]null로 설정한다.
  4. optionsResolution을 ? ResolveOptions(%Intl.DateTimeFormat%, %Intl.DateTimeFormat%.[[LocaleData]], locales, options, « coerce-options », modifyResolutionOptions)로 둔다.
  5. hour12specialOptions.[[Hour12]]로 둔다.
  6. optionsoptionsResolution.[[Options]]로 설정한다.
  7. resolvedLocaleoptionsResolution.[[ResolvedLocale]]로 둔다.
  8. dateTimeFormat.[[Locale]]resolvedLocale.[[Locale]]로 설정한다.
  9. resolvedCalendarresolvedLocale.[[ca]]로 둔다.
  10. dateTimeFormat.[[Calendar]]resolvedCalendar로 설정한다.
  11. dateTimeFormat.[[NumberingSystem]]resolvedLocale.[[nu]]로 설정한다.
  12. resolvedLocaleDataresolvedLocale.[[LocaleData]]로 둔다.
  13. hour12true이면,
    1. hcresolvedLocaleData.[[hourCycle12]]로 둔다.
  14. 그렇지 않고 hour12false이면,
    1. hcresolvedLocaleData.[[hourCycle24]]로 둔다.
  15. 그렇지 않으면,
    1. 단언: hour12undefined이다.
    2. hcresolvedLocale.[[hc]]로 둔다.
    3. hcnull이면, hcresolvedLocaleData.[[hourCycle]]로 설정한다.
  16. timeZone을 ? Get(options, "timeZone")로 둔다.
  17. timeZoneundefined이면,
    1. timeZoneSystemTimeZoneIdentifier()로 설정한다.
  18. 그렇지 않으면,
    1. timeZone을 ? ToString(timeZone)으로 설정한다.
  19. IsTimeZoneOffsetString(timeZone)이 true이면,
    1. parseResultParseText(StringToCodePoints(timeZone), UTCOffset)로 둔다.
    2. 단언: parseResultParse Node이다.
    3. parseResult가 둘 이상의 MinuteSecond Parse Node를 포함하면, RangeError 예외를 던진다.
    4. offsetNanosecondsParseTimeZoneOffsetString(timeZone)으로 둔다.
    5. offsetMinutesoffsetNanoseconds / (6 × 1010)로 둔다.
    6. 단언: offsetMinutes는 정수이다.
    7. timeZoneFormatOffsetTimeZoneIdentifier(offsetMinutes)로 설정한다.
  20. 그렇지 않으면,
    1. timeZoneIdentifierRecordGetAvailableNamedTimeZoneIdentifier(timeZone)로 둔다.
    2. timeZoneIdentifierRecordempty이면, RangeError 예외를 던진다.
    3. timeZonetimeZoneIdentifierRecord.[[PrimaryIdentifier]]로 설정한다.
  21. dateTimeFormat.[[TimeZone]]timeZone으로 설정한다.
  22. formatOptions를 새 Record로 둔다.
  23. formatOptions.[[hourCycle]]hc로 설정한다.
  24. hasExplicitFormatComponentsfalse로 둔다.
  25. Table 16의 각 행에 대해, 헤더 행은 제외하고 표 순서대로, 다음을 수행한다.
    1. propertyKey를 현재 행의 Property 열에 주어진 이름으로 둔다.
    2. propertyKey"fractionalSecondDigits"이면,
      1. value를 ? GetNumberOption(options, "fractionalSecondDigits", 1, 3, undefined)로 둔다.
    3. 그렇지 않으면,
      1. values를 현재 행의 Values 열에 주어진 문자열들을 요소로 하는 List로 둔다.
      2. value를 ? GetOption(options, propertyKey, string, values, undefined)로 둔다.
    4. formatOptions.[[<propertyKey>]]를 value로 설정한다.
    5. valueundefined가 아니면,
      1. hasExplicitFormatComponentstrue로 설정한다.
  26. formatMatcher를 ? GetOption(options, "formatMatcher", string, « "basic", "best fit" », "best fit")로 둔다.
  27. dateStyle을 ? GetOption(options, "dateStyle", string, « "full", "long", "medium", "short" », undefined)로 둔다.
  28. dateTimeFormat.[[DateStyle]]dateStyle로 설정한다.
  29. timeStyle을 ? GetOption(options, "timeStyle", string, « "full", "long", "medium", "short" », undefined)로 둔다.
  30. dateTimeFormat.[[TimeStyle]]timeStyle로 설정한다.
  31. dateStyleundefined가 아니거나 timeStyleundefined가 아니면,
    1. hasExplicitFormatComponentstrue이면,
      1. TypeError 예외를 던진다.
    2. requireddate이고 timeStyleundefined가 아니면,
      1. TypeError 예외를 던진다.
    3. requiredtime이고 dateStyleundefined가 아니면,
      1. TypeError 예외를 던진다.
    4. stylesresolvedLocaleData.[[styles]].[[<resolvedCalendar>]]로 둔다.
    5. bestFormatDateTimeStyleFormat(dateStyle, timeStyle, styles)로 둔다.
  32. 그렇지 않으면,
    1. needDefaultstrue로 둔다.
    2. requireddate 또는 any이면,
      1. « "weekday", "year", "month", "day" »의 각 속성 이름 propertyKey에 대해, 다음을 수행한다.
        1. valueformatOptions.[[<propertyKey>]]로 둔다.
        2. valueundefined가 아니면 needDefaultsfalse로 설정한다.
    3. requiredtime 또는 any이면,
      1. « "dayPeriod", "hour", "minute", "second", "fractionalSecondDigits" »의 각 속성 이름 propertyKey에 대해, 다음을 수행한다.
        1. valueformatOptions.[[<propertyKey>]]로 둔다.
        2. valueundefined가 아니면 needDefaultsfalse로 설정한다.
    4. needDefaultstrue이고 defaultsdate 또는 all 중 하나이면,
      1. « "year", "month", "day" »의 각 속성 이름 propertyKey에 대해, 다음을 수행한다.
        1. formatOptions.[[<propertyKey>]]를 "numeric"으로 설정한다.
    5. needDefaultstrue이고 defaultstime 또는 all 중 하나이면,
      1. « "hour", "minute", "second" »의 각 속성 이름 propertyKey에 대해, 다음을 수행한다.
        1. formatOptions.[[<propertyKey>]]를 "numeric"으로 설정한다.
    6. formatsresolvedLocaleData.[[formats]].[[<resolvedCalendar>]]로 둔다.
    7. formatMatcher"basic"이면,
      1. bestFormatBasicFormatMatcher(formatOptions, formats)로 둔다.
    8. 그렇지 않으면,
      1. bestFormatBestFitFormatMatcher(formatOptions, formats)로 둔다.
  33. dateTimeFormat.[[DateTimeFormat]]bestFormat으로 설정한다.
  34. bestFormat[[hour]] 필드가 있으면,
    1. dateTimeFormat.[[HourCycle]]hc로 설정한다.
  35. dateTimeFormat을 반환한다.

11.1.3 FormatOffsetTimeZoneIdentifier ( offsetMinutes )

The abstract operation FormatOffsetTimeZoneIdentifier takes argument offsetMinutes (정수) and returns String. It performs the following steps when called:

  1. offsetMinutes ≥ 0이면 sign을 코드 단위 0x002B (PLUS SIGN)로 두고, 그렇지 않으면 sign을 코드 단위 0x002D (HYPHEN-MINUS)로 둔다.
  2. absoluteMinutesabs(offsetMinutes)로 둔다.
  3. hoursfloor(absoluteMinutes / 60)으로 둔다.
  4. minutesabsoluteMinutes modulo 60으로 둔다.
  5. sign, ToZeroPaddedDecimalString(hours, 2), 코드 단위 0x003A (COLON), 그리고 ToZeroPaddedDecimalString(minutes, 2)의 문자열 연결을 반환한다.

11.2 Intl.DateTimeFormat 생성자의 속성

Intl.DateTimeFormat 생성자는:

  • 값이 %Function.prototype%[[Prototype]] 내부 슬롯을 가진다.
  • 다음 속성을 가진다:

11.2.1 Intl.DateTimeFormat.prototype

Intl.DateTimeFormat.prototype의 값은 %Intl.DateTimeFormat.prototype%이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } 특성을 가진다.

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

supportedLocalesOf 메서드가 인수 localesoptions로 호출되면, 다음 단계가 수행된다:

  1. availableLocales%Intl.DateTimeFormat%.[[AvailableLocales]]로 둔다.
  2. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  3. FilterLocales(availableLocales, requestedLocales, options)를 반환한다.

11.2.3 내부 슬롯

[[AvailableLocales]] 내부 슬롯의 값은 9.1에 설명된 제약 조건 내에서 구현 정의이다.

[[RelevantExtensionKeys]] 내부 슬롯의 값은 « "ca", "hc", "nu" »이다.

Note 1
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions는 날짜 및 시간 형식 지정과 관련된 네 개의 locale 확장 키를 설명한다: calendar에 대한 "ca", hour cycle에 대한 "hc", numbering system(형식화된 숫자의)에 대한 "nu", 그리고 time zone에 대한 "tz". 그러나 DateTimeFormat은 time zone이 options 객체의 "timeZone" 속성을 통해 지정될 것을 요구한다.

[[ResolutionOptionDescriptors]] 내부 슬롯의 값은 « { [[Key]]: "ca", [[Property]]: "calendar" }, { [[Key]]: "nu", [[Property]]: "numberingSystem" }, { [[Key]]: "hour12", [[Property]]: "hour12", [[Type]]: boolean }, { [[Key]]: "hc", [[Property]]: "hourCycle", [[Values]]: « "h11", "h12", "h23", "h24" » } »이다.

[[LocaleData]] 내부 슬롯의 값은 9.1에 설명된 제약 조건 및 다음 추가 제약 조건 내에서, 모든 locale 값 locale에 대해 구현 정의이다:

  • [[LocaleData]].[[<locale>]].[[nu]]"native", "traditio", 또는 "finance" 값을 포함하지 않는 List여야 한다.
  • [[LocaleData]].[[<locale>]].[[hc]]는 « null, "h11", "h12", "h23", "h24" »여야 한다.
  • [[LocaleData]].[[<locale>]].[[hourCycle]]는 String "h11", "h12", "h23", 또는 "h24" 중 하나여야 한다.
  • [[LocaleData]].[[<locale>]].[[hourCycle12]]는 String "h11" 또는 "h12" 중 하나여야 한다.
  • [[LocaleData]].[[<locale>]].[[hourCycle24]]는 String "h23" 또는 "h24" 중 하나여야 한다.
  • [[LocaleData]].[[<locale>]]는 [[formats]] 필드를 가져야 한다. 이 [[formats]] 필드의 값은 각 calendar 값 calendar에 대한 [[<calendar>]] 필드를 가진 Record여야 한다. 각 [[<calendar>]] 필드의 값은 DateTime Format RecordsList여야 한다. 그러한 List의 여러 Record는, 대응하는 값이 적어도 하나의 필드에서 다른 한, 동일한 필드 부분집합을 사용할 수 있다. 각 locale에 대해 다음 부분집합들이 사용 가능해야 한다:
    • 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>]] 필드를 가진 Record여야 한다. 각 [[<calendar>]] 필드의 값은 DateTime Styles Record여야 한다.

11.2.3.1 DateTime Format Records

DateTime Format RecordTable 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]] Pattern String 레코드의 각 날짜 및 시간 형식 구성 요소 필드에 대해, "{"로 시작하고, 뒤이어 필드 이름이 오며, 뒤이어 "}"가 오는 부분 문자열을 포함한다. 레코드에 [[year]] 필드가 있으면, 문자열은 부분 문자열 "{yearName}""{relatedYear}"를 포함할 수 있다.
[[pattern12]] Pattern String 선택적 필드. [[hour]] 필드가 있으면 존재한다. [[pattern]] 필드의 부분 문자열들에 더해, 부분 문자열 "{ampm}" 또는 "{dayPeriod}" 중 적어도 하나를 포함한다.
[[rangePatterns]] DateTime Range Pattern Record 이 필드의 pattern 문자열들은 [[pattern]]과 유사하다.
[[rangePatterns12]] DateTime Range Pattern Record 선택적 필드. [[hour]] 필드가 있으면 존재한다. 이 필드의 pattern 문자열들은 [[pattern12]]와 유사하다.

11.2.3.2 DateTime Range Pattern Records

DateTime Range Pattern RecordTable 6에 정의된 필드를 가진다.

Table 6: DateTime Range Pattern Record
필드 이름 값 유형 설명
[[Default]] DateTime Range Pattern Format Record 더 구체적인 range pattern을 사용할 수 없을 때 사용되는 기본 range pattern을 포함한다.
[[Era]] DateTime Range Pattern Format Record 선택적 필드. era가 시작 날짜와 종료 날짜 사이에서 다른 가장 큰 calendar 요소일 때 사용된다.
[[Year]] DateTime Range Pattern Format Record 선택적 필드. year가 시작 날짜와 종료 날짜 사이에서 다른 가장 큰 calendar 요소일 때 사용된다.
[[Month]] DateTime Range Pattern Format Record 선택적 필드. month가 시작 날짜와 종료 날짜 사이에서 다른 가장 큰 calendar 요소일 때 사용된다.
[[Day]] DateTime Range Pattern Format Record 선택적 필드. day가 시작 날짜와 종료 날짜 사이에서 다른 가장 큰 calendar 요소일 때 사용된다.
[[AmPm]] DateTime Range Pattern Format Record 선택적 필드. ante 또는 post meridiem이 시작 날짜와 종료 날짜 사이에서 다른 가장 큰 calendar 요소일 때 사용된다.
[[DayPeriod]] DateTime Range Pattern Format Record 선택적 필드. day period가 시작 날짜와 종료 날짜 사이에서 다른 가장 큰 calendar 요소일 때 사용된다.
[[Hour]] DateTime Range Pattern Format Record 선택적 필드. hour가 시작 날짜와 종료 날짜 사이에서 다른 가장 큰 calendar 요소일 때 사용된다.
[[Minute]] DateTime Range Pattern Format Record 선택적 필드. minute가 시작 날짜와 종료 날짜 사이에서 다른 가장 큰 calendar 요소일 때 사용된다.
[[Second]] DateTime Range Pattern Format Record 선택적 필드. second가 시작 날짜와 종료 날짜 사이에서 다른 가장 큰 calendar 요소일 때 사용된다.
[[FractionalSecondDigits]] DateTime Range Pattern Format Record 선택적 필드. fractional seconds가 시작 날짜와 종료 날짜 사이에서 다른 가장 큰 calendar 요소일 때 사용된다.

11.2.3.3 DateTime Range Pattern Format Records

DateTime Range Pattern Format RecordTable 7에 정의된 필드를 가진다.

Table 7: DateTime Range Pattern Format Record
필드 이름 값 유형 설명
[[weekday]] Table 16의 Values 열에 있는 [[Weekday]] 선택적 필드. [[PatternParts]]Pattern String이 부분 문자열 "{weekday}"를 포함하면 존재한다.
[[era]] Table 16의 Values 열에 있는 [[Era]] 선택적 필드. [[PatternParts]]Pattern String이 부분 문자열 "{era}"를 포함하면 존재한다.
[[year]] Table 16의 Values 열에 있는 [[Year]] 선택적 필드. [[PatternParts]]Pattern String이 부분 문자열 "{year}", "{yearName}", 또는 "{relatedYear}" 중 적어도 하나를 포함하면 존재한다.
[[month]] Table 16의 Values 열에 있는 [[Month]] 선택적 필드. [[PatternParts]]Pattern String이 부분 문자열 "{month}"를 포함하면 존재한다.
[[day]] Table 16의 Values 열에 있는 [[Day]] 선택적 필드. [[PatternParts]]Pattern String이 부분 문자열 "{day}"를 포함하면 존재한다.
[[dayPeriod]] Table 16의 Values 열에 있는 [[DayPeriod]] 선택적 필드. [[PatternParts]]Pattern String이 부분 문자열 "{dayPeriod}"를 포함하면 존재한다.
[[hour]] Table 16의 Values 열에 있는 [[Hour]] 선택적 필드. [[PatternParts]]Pattern String이 부분 문자열 "{hour}"를 포함하면 존재한다.
[[minute]] Table 16의 Values 열에 있는 [[Minute]] 선택적 필드. [[PatternParts]]Pattern String이 부분 문자열 "{minute}"를 포함하면 존재한다.
[[second]] Table 16의 Values 열에 있는 [[Second]] 선택적 필드. [[PatternParts]]Pattern String이 부분 문자열 "{second}"를 포함하면 존재한다.
[[fractionalSecondDigits]] Table 16의 Values 열에 있는 [[FractionalSecondDigits]] 선택적 필드. [[PatternParts]]Pattern String이 부분 문자열 "{fractionalSecondDigits}"를 포함하면 존재한다.
[[timeZoneName]] Table 16의 Values 열에 있는 [[TimeZoneName]] 선택적 필드. [[PatternParts]]Pattern String이 부분 문자열 "{timeZoneName}"를 포함하면 존재한다.
[[PatternParts]] DateTime Range Pattern Part RecordsList 각 record는 range pattern의 한 부분을 나타낸다.

11.2.3.4 DateTime Range Pattern Part Records

DateTime Range Pattern Part RecordTable 8에 정의된 필드를 가진다.

Table 8: DateTime Range Pattern Part Record
필드 이름 값 유형 설명
[[Source]] "shared", "startRange", 또는 "endRange" 이는 range의 날짜들 중 어느 것을 [[Pattern]] 필드의 값을 사용하여 형식화해야 하는지를 나타낸다.
[[Pattern]] Pattern String 일반 날짜 pattern String과 같은 형식의 String.

11.2.3.5 DateTime Styles Records

DateTime Styles RecordTable 9에 정의된 필드를 가진다.

Table 9: DateTime Styles Record
필드 이름 값 유형
[[Date]] DateTime Style Record
[[Time]] DateTime Style Record
[[Connector]] DateTime Connector Record
[[DateTimeRangeFormat]] DateTime Date Range Record

11.2.3.6 DateTime Style Records

DateTime Style RecordTable 10에 정의된 필드를 가진다.

Table 10: DateTime Style Record
필드 이름 값 유형 설명
[[full]] DateTime Format Record "full" style에 대한 format record.
[[long]] DateTime Format Record "long" style에 대한 format record.
[[medium]] DateTime Format Record "medium" style에 대한 format record.
[[short]] DateTime Format Record "short" style에 대한 format record.

11.2.3.7 DateTime Connector Records

DateTime Connector RecordTable 11에 정의된 필드를 가진다. 모든 connector pattern 문자열은 문자열 "{0}""{1}"를 포함해야 한다.

Table 11: DateTime Connector Record
필드 이름 값 유형 설명
[[full]] Pattern String date style이 "full"일 때의 connector pattern.
[[long]] Pattern String date style이 "long"일 때의 connector pattern.
[[medium]] Pattern String date style이 "medium"일 때의 connector pattern.
[[short]] Pattern String date style이 "short"일 때의 connector pattern.

11.2.3.8 DateTime Date Range Records

DateTime Date Range RecordTable 12에 정의된 필드를 가진다.

Table 12: DateTime Date Range Record
필드 이름 값 유형 설명
[[full]] DateTime Time Range Record date style이 "full"일 때 사용된다.
[[long]] DateTime Time Range Record date style이 "long"일 때 사용된다.
[[medium]] DateTime Time Range Record date style이 "medium"일 때 사용된다.
[[short]] DateTime Time Range Record date style이 "short"일 때 사용된다.

11.2.3.9 DateTime Time Range Records

DateTime Time Range RecordTable 13에 정의된 필드를 가진다.

Table 13: DateTime Time Range Record
필드 이름 값 유형 설명
[[full]] DateTime Style Range Record time style이 "full"일 때 사용된다.
[[long]] DateTime Style Range Record time style이 "long"일 때 사용된다.
[[medium]] DateTime Style Range Record time style이 "medium"일 때 사용된다.
[[short]] DateTime Style Range Record time style이 "short"일 때 사용된다.

11.2.3.10 DateTime Style Range Records

DateTime Style Range RecordTable 14에 정의된 필드를 가진다.

Table 14: DateTime Style Range Record
필드 이름 값 유형 설명
[[rangePatterns]] DateTime Range Pattern Record 날짜 및 시간 style을 결합하기 위한 range pattern.
[[rangePatterns12]] DateTime Range Pattern Record 선택적 필드. 12시간 형식에 대해 날짜 및 시간 style을 결합하기 위한 range pattern.
Note 2
예를 들어, 구현은 영어 locale data의 일부로 다음 Record를 포함할 수 있다:
  • [[hour]]: "numeric"
  • [[minute]]: "numeric"
  • [[pattern]]: "{hour}:{minute}"
  • [[pattern12]]: "{hour}:{minute} {ampm}"
  • [[rangePatterns]]:
    • [[Hour]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
    • [[Minute]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
    • [[Default]]:
      • [[year]]: "2-digit"
      • [[month]]: "numeric"
      • [[day]]: "numeric"
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute}"}
  • [[rangePatterns12]]:
    • [[Hour]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " {ampm}"}
    • [[Minute]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " {ampm}"}
    • [[Default]]:
      • [[year]]: "2-digit"
      • [[month]]: "numeric"
      • [[day]]: "numeric"
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute} {ampm}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute} {ampm}"}
Note 3
구현은 Common Locale Data Repository(https://cldr.unicode.org/에서 이용 가능)가 제공하는 locale data를 사용하는 것이 권장된다.

11.3 Intl.DateTimeFormat 프로토타입 객체의 속성

Intl.DateTimeFormat 프로토타입 객체는:

  • %Intl.DateTimeFormat.prototype%이다.
  • 일반 객체이다.
  • Intl.DateTimeFormat 인스턴스가 아니며 [[InitializedDateTimeFormat]] 내부 슬롯이나 Intl.DateTimeFormat 인스턴스 객체의 다른 내부 슬롯을 가지지 않는다.
  • 값이 %Object.prototype%[[Prototype]] 내부 슬롯을 가진다.

11.3.1 Intl.DateTimeFormat.prototype.constructor

Intl.DateTimeFormat.prototype.constructor의 초기값은 %Intl.DateTimeFormat%이다.

11.3.2 Intl.DateTimeFormat.prototype.resolvedOptions ( )

이 함수는 객체의 초기화 중에 계산된 locale 및 option에 대한 접근을 제공한다.

  1. dtfthis 값으로 둔다.
  2. 구현이 4.3 Note 1의 규범적 선택 생성자 모드를 지원하면,
    1. dtf를 ? UnwrapDateTimeFormat(dtf)로 설정한다.
  3. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]])를 수행한다.
  4. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  5. Table 15의 각 행에 대해, 헤더 행은 제외하고 표 순서대로, 다음을 수행한다.
    1. propertyKey를 현재 행의 Property 값으로 둔다.
    2. 현재 행에 Internal Slot 값이 있으면,
      1. value를, 그 이름이 현재 행의 Internal Slot 값인 dtf의 내부 슬롯 값으로 둔다.
    3. 그렇지 않으면,
      1. formatdtf.[[DateTimeFormat]]으로 둔다.
      2. format이 [[<propertyKey>]] 필드를 가지고 dtf.[[DateStyle]]undefined이며 dtf.[[TimeStyle]]undefined이면,
        1. valueformat.[[<propertyKey>]]로 둔다.
      3. 그렇지 않으면,
        1. valueundefined로 둔다.
    4. valueundefined가 아니면,
      1. 현재 행에 Conversion 값이 있으면,
        1. conversion을 현재 행의 Conversion 값으로 둔다.
        2. conversionhour12이면,
          1. value"h11" 또는 "h12"이면 valuetrue로 설정한다. 그렇지 않으면 valuefalse로 설정한다.
        3. 그렇지 않으면,
          1. 단언: conversionnumber이다.
          2. value𝔽(value)로 설정한다.
      2. CreateDataPropertyOrThrow(options, propertyKey, value)를 수행한다.
  6. options를 반환한다.
Table 15: DateTimeFormat 인스턴스의 Resolved Options
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 버전에서, Intl.DateTimeFormat 생성자에 제공된 options 객체에 "timeZone" 속성이 제공되지 않은 경우 "timeZone" 속성은 호스트 환경의 time zone 식별자가 된다. 초판에서는 이 경우 "timeZone" 속성이 undefined로 남아 있었다.
Note 2
다섯 번째 판 이전 버전과의 호환성을 위해, "hour12" 속성은 "hourCycle" 속성에 더해 설정된다.

11.3.3 get Intl.DateTimeFormat.prototype.format

Intl.DateTimeFormat.prototype.format은 set 접근자 함수가 undefined인 접근자 속성이다. 그 get 접근자 함수는 다음 단계를 수행한다:

  1. dtfthis 값으로 둔다.
  2. 구현이 4.3 Note 1의 규범적 선택 생성자 모드를 지원하면,
    1. dtf를 ? UnwrapDateTimeFormat(dtf)로 설정한다.
  3. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]])를 수행한다.
  4. dtf.[[BoundFormat]]undefined이면,
    1. func를 DateTime Format Functions(11.5.4)에 정의된 새 built-in 함수 객체로 둔다.
    2. func.[[DateTimeFormat]]dtf로 설정한다.
    3. dtf.[[BoundFormat]]func로 설정한다.
  5. dtf.[[BoundFormat]]을 반환한다.
Note
반환된 함수는 dtf에 바인딩되므로 Array.prototype.map 또는 다른 함수에 직접 전달될 수 있다. 이는 더 이상 새 기능에 따르지 않는 관례의 일부였던 역사적 산물로 간주되지만, 기존 프로그램과의 호환성을 유지하기 위해 보존된다.

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

formatRange 메서드가 인수 startDateendDate로 호출되면, 다음 단계가 수행된다:

  1. dtfthis 값으로 둔다.
  2. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]])를 수행한다.
  3. startDateundefined이거나 endDateundefined이면, TypeError 예외를 던진다.
  4. x를 ? ToNumber(startDate)로 둔다.
  5. y를 ? ToNumber(endDate)로 둔다.
  6. FormatDateTimeRange(dtf, x, y)를 반환한다.

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

formatRangeToParts 메서드가 인수 startDateendDate로 호출되면, 다음 단계가 수행된다:

  1. dtfthis 값으로 둔다.
  2. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]])를 수행한다.
  3. startDateundefined이거나 endDateundefined이면, TypeError 예외를 던진다.
  4. x를 ? ToNumber(startDate)로 둔다.
  5. y를 ? ToNumber(endDate)로 둔다.
  6. FormatDateTimeRangeToParts(dtf, x, y)를 반환한다.

11.3.6 Intl.DateTimeFormat.prototype.formatToParts ( date )

formatToParts 메서드가 인수 date로 호출되면, 다음 단계가 수행된다:

  1. dtfthis 값으로 둔다.
  2. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]])를 수행한다.
  3. dateundefined이면,
    1. x를 ! Call(%Date.now%, undefined)로 둔다.
  4. 그렇지 않으면,
    1. x를 ? ToNumber(date)로 둔다.
  5. FormatDateTimeToParts(dtf, x)를 반환한다.

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

%Symbol.toStringTag% 속성의 초기값은 String "Intl.DateTimeFormat"이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } 특성을 가진다.

11.4 Intl.DateTimeFormat 인스턴스의 속성

Intl.DateTimeFormat 인스턴스는 %Intl.DateTimeFormat.prototype%에서 속성을 상속하는 일반 객체이다.

Intl.DateTimeFormat 인스턴스는 [[InitializedDateTimeFormat]] 내부 슬롯을 가진다.

Intl.DateTimeFormat 인스턴스는 또한 Intl.DateTimeFormat 생성자에 의해 계산되는 여러 내부 슬롯을 가진다:

  • [[Locale]]은 형식 지정에 사용되는 현지화의 locale에 대한 language tag를 나타내는 String이다.
  • [[Calendar]]는 형식 지정에 사용되는 Unicode Calendar Identifier를 나타내는 String이다.
  • [[NumberingSystem]]은 형식 지정에 사용되는 Unicode Number System Identifier를 나타내는 String이다.
  • [[TimeZone]]은 형식 지정에 사용되는 String으로, 사용 가능한 named time zone 식별자 또는 offset time zone 식별자 중 하나이다.
  • [[HourCycle]]은 12시간 형식("h11", "h12") 또는 24시간 형식("h23", "h24") 중 어느 것을 사용해야 하는지를 나타내는 String이다. "h11""h23"은 각각 hour 0에서 시작하여 11 및 23까지 간다. "h12""h24"는 각각 hour 1에서 시작하여 12 및 24까지 간다. [[HourCycle]][[DateTimeFormat]][[hour]] 필드가 있을 때에만 사용된다.
  • [[DateStyle]], [[TimeStyle]]은 각각 undefined, "full", "long", "medium", 또는 "short" 중 하나이다.
  • [[DateTimeFormat]]DateTime Format Record이다.

마지막으로, Intl.DateTimeFormat 인스턴스는 format 접근자(11.3.3)가 반환하는 함수를 캐시하는 [[BoundFormat]] 내부 슬롯을 가진다.

11.5 DateTimeFormat 객체를 위한 추상 연산

여러 DateTimeFormat 알고리즘은 다음 표의 값을 사용하며, 이 표는 날짜 및 시간 형식의 구성 요소에 대한 내부 슬롯, 속성 이름 및 허용 값을 제공한다:

Table 16: 날짜 및 시간 형식의 구성 요소
필드 이름 속성
[[Weekday]] "weekday" "narrow", "short", "long"
[[Era]] "era" "narrow", "short", "long"
[[Year]] "year" "2-digit", "numeric"
[[Month]] "month" "2-digit", "numeric", "narrow", "short", "long"
[[Day]] "day" "2-digit", "numeric"
[[DayPeriod]] "dayPeriod" "narrow", "short", "long"
[[Hour]] "hour" "2-digit", "numeric"
[[Minute]] "minute" "2-digit", "numeric"
[[Second]] "second" "2-digit", "numeric"
[[FractionalSecondDigits]] "fractionalSecondDigits" 1, 2, 3
[[TimeZoneName]] "timeZoneName" "short", "long", "shortOffset", "longOffset", "shortGeneric", "longGeneric"

11.5.1 DateTimeStyleFormat ( dateStyle, timeStyle, styles )

The abstract operation DateTimeStyleFormat takes arguments dateStyle ("full", "long", "medium", "short", 또는 undefined), timeStyle ("full", "long", "medium", "short", 또는 undefined), and styles (DateTime Styles Record) and returns DateTime Format Record. It performs the following steps when called:

#### ECMARKDOWN PARSE FAILED ####
        1. 단언: _dateStyle_은 *undefined*가 아니거나 _timeStyle_은 *undefined*가 아니다.
        1. _timeStyle_이 *undefined*가 아니면,
          1. 단언: _timeStyle_은 *"full"*, *"long"*, *"medium"*, 또는 *"short"* 중 하나이다.
          1. _timeFormat_을 _styles_.[[Time]].[[<_timeStyle_>]]로 둔다.
        1. _dateStyle_이 *undefined*가 아니면,
          1. 단언: _dateStyle_은 *"full"*, *"long"*, *"medium"*, 또는 *"short"* 중 하나이다.
          1. _dateFormat_을 _styles_.[[Date]].[[<_dateStyle_>]]로 둔다.
        1. _dateStyle_이 *undefined*가 아니고 _timeStyle_이 *undefined*가 아니면,
          1. _format_을 새 DateTime Format Record로 둔다.
          1. [[pattern]] 및 [[rangePatterns]]를 제외한 _dateFormat_의 모든 필드를 _format_에 추가한다.
          1. [[pattern]], [[rangePatterns]], 그리고 존재한다면 [[pattern12]] 및 [[rangePatterns12]]를 제외한 _timeFormat_의 모든 필드를 _format_에 추가한다.
          1. _connector_를 _styles_.[[Connector]].[[<_dateStyle_>]]로 둔다.
          1. _pattern_을 _connector_ 문자열에서 부분 문자열 *"{0}"*을 _timeFormat_.[[pattern]]으로, 부분 문자열 *"{1}"*을 _dateFormat_.[[pattern]]으로 교체한 것으로 둔다.
          1. _format_.[[pattern]]을 _pattern_으로 설정한다.
          1. _timeFormat_에 [[pattern12]] 필드가 있으면,
            1. _pattern12_를 _connector_ 문자열에서 부분 문자열 *"{0}"*을 _timeFormat_.[[pattern12]]로, 부분 문자열 *"{1}"*을 _dateFormat_.[[pattern]]으로 교체한 것으로 둔다.
            1. _format_.[[pattern12]]를 _pattern12_로 설정한다.
          1. _dateTimeRangeFormat_을 _styles_.[[DateTimeRangeFormat]].[[<_dateStyle_>]].[[<_timeStyle_>]]로 둔다.
          1. _format_.[[rangePatterns]]를 _dateTimeRangeFormat_.[[rangePatterns]]로 설정한다.
          1. _dateTimeRangeFormat_에 [[rangePatterns12]] 필드가 있으면,
            1. _format_.[[rangePatterns12]]를 _dateTimeRangeFormat_.[[rangePatterns12]]로 설정한다.
          1. _format_을 반환한다.
        1. _timeStyle_이 *undefined*가 아니면,
          1. _timeFormat_을 반환한다.
        1. 단언: _dateStyle_은 *undefined*가 아니다.
        1. _dateFormat_을 반환한다.
      

11.5.2 BasicFormatMatcher ( options, formats )

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

  1. removalPenalty를 120으로 둔다.
  2. additionPenalty를 20으로 둔다.
  3. longLessPenalty를 8로 둔다.
  4. longMorePenalty를 6으로 둔다.
  5. shortLessPenalty를 6으로 둔다.
  6. shortMorePenalty를 3으로 둔다.
  7. offsetPenalty를 1로 둔다.
  8. bestScore를 -∞로 둔다.
  9. bestFormatundefined로 둔다.
  10. formats의 각 요소 format에 대해, 다음을 수행한다.
    1. score를 0으로 둔다.
    2. Table 16의 각 행에 대해, 헤더 행은 제외하고 표 순서대로, 다음을 수행한다.
      1. property를 현재 행의 Property 열에 주어진 이름으로 둔다.
      2. options에 [[<property>]] 필드가 있으면 optionsPropoptions.[[<property>]]로 두고, 그렇지 않으면 optionsPropundefined로 둔다.
      3. format에 [[<property>]] 필드가 있으면 formatPropformat.[[<property>]]로 두고, 그렇지 않으면 formatPropundefined로 둔다.
      4. optionsPropundefined이고 formatPropundefined가 아니면,
        1. scorescore - additionPenalty로 설정한다.
      5. 그렇지 않고 optionsPropundefined가 아니며 formatPropundefined이면,
        1. scorescore - removalPenalty로 설정한다.
      6. 그렇지 않고 property"timeZoneName"이면,
        1. optionsProp"short" 또는 "shortGeneric"이면,
          1. formatProp"shortOffset"이면, scorescore - offsetPenalty로 설정한다.
          2. 그렇지 않고 formatProp"longOffset"이면, scorescore - (offsetPenalty + shortMorePenalty)로 설정한다.
          3. 그렇지 않고 optionsProp"short"이고 formatProp"long"이면, scorescore - shortMorePenalty로 설정한다.
          4. 그렇지 않고 optionsProp"shortGeneric"이고 formatProp"longGeneric"이면, scorescore - shortMorePenalty로 설정한다.
          5. 그렇지 않고 optionsPropformatProp이면, scorescore - removalPenalty로 설정한다.
        2. 그렇지 않고 optionsProp"shortOffset"이고 formatProp"longOffset"이면,
          1. scorescore - shortMorePenalty로 설정한다.
        3. 그렇지 않고 optionsProp"long" 또는 "longGeneric"이면,
          1. formatProp"longOffset"이면, scorescore - offsetPenalty로 설정한다.
          2. 그렇지 않고 formatProp"shortOffset"이면, scorescore - (offsetPenalty + longLessPenalty)로 설정한다.
          3. 그렇지 않고 optionsProp"long"이고 formatProp"short"이면, scorescore - longLessPenalty로 설정한다.
          4. 그렇지 않고 optionsProp"longGeneric"이고 formatProp"shortGeneric"이면, scorescore - longLessPenalty로 설정한다.
          5. 그렇지 않고 optionsPropformatProp이면, scorescore - removalPenalty로 설정한다.
        4. 그렇지 않고 optionsProp"longOffset"이고 formatProp"shortOffset"이면,
          1. scorescore - longLessPenalty로 설정한다.
        5. 그렇지 않고 optionsPropformatProp이면,
          1. scorescore - removalPenalty로 설정한다.
      7. 그렇지 않고 optionsPropformatProp이면,
        1. property"fractionalSecondDigits"이면,
          1. values를 « 1, 2, 3 »으로 둔다.
        2. 그렇지 않으면,
          1. values를 « "2-digit", "numeric", "narrow", "short", "long" »으로 둔다.
        3. optionsPropIndexvalues 내에서 optionsProp의 인덱스로 둔다.
        4. formatPropIndexvalues 내에서 formatProp의 인덱스로 둔다.
        5. deltamax(min(formatPropIndex - optionsPropIndex, 2), -2)로 둔다.
        6. delta = 2이면, scorescore - longMorePenalty로 설정한다.
        7. 그렇지 않고 delta = 1이면, scorescore - shortMorePenalty로 설정한다.
        8. 그렇지 않고 delta = -1이면, scorescore - shortLessPenalty로 설정한다.
        9. 그렇지 않고 delta = -2이면, scorescore - longLessPenalty로 설정한다.
    3. score > bestScore이면,
      1. bestScorescore로 설정한다.
      2. bestFormatformat으로 설정한다.
  11. bestFormat을 반환한다.

11.5.3 BestFitFormatMatcher ( options, formats )

The implementation-defined abstract operation BestFitFormatMatcher takes arguments options (Record) and formats (DateTime Format RecordsList) and returns DateTime Format Record.

11.5.4 DateTime Format Functions

DateTime format function은 [[DateTimeFormat]] 내부 슬롯을 가진 익명 built-in 함수이다.

DateTime format function func가 선택적 인수 date로 호출되면, 다음 단계가 수행된다:

  1. dtffunc.[[DateTimeFormat]]으로 둔다.
  2. 단언: dtf는 Object이고 [[InitializedDateTimeFormat]] 내부 슬롯을 가진다.
  3. date가 제공되지 않았거나 undefined이면,
    1. x를 ! Call(%Date.now%, undefined)로 둔다.
  4. 그렇지 않으면,
    1. x를 ? ToNumber(date)로 둔다.
  5. FormatDateTime(dtf, x)를 반환한다.

DateTime format function의 "length" 속성은 1𝔽이다.

11.5.5 FormatDateTimePattern ( dateTimeFormat, format, pattern, epochNanoseconds )

The abstract operation FormatDateTimePattern takes arguments dateTimeFormat (Intl.DateTimeFormat), format (DateTime Format Record 또는 DateTime Range Pattern Format Record), pattern (Pattern String), and epochNanoseconds (BigInt) and returns [[Type]](String) 및 [[Value]](String) 필드를 가진 RecordsList. It performs the following steps when called:

  1. localedateTimeFormat.[[Locale]]로 둔다.
  2. nfOptionsOrdinaryObjectCreate(null)로 둔다.
  3. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", dateTimeFormat.[[NumberingSystem]])를 수행한다.
  4. CreateDataPropertyOrThrow(nfOptions, "useGrouping", false)를 수행한다.
  5. nf를 ! Construct(%Intl.NumberFormat%, « locale, nfOptions »)로 둔다.
  6. nf2OptionsOrdinaryObjectCreate(null)로 둔다.
  7. CreateDataPropertyOrThrow(nf2Options, "minimumIntegerDigits", 2𝔽)를 수행한다.
  8. CreateDataPropertyOrThrow(nf2Options, "numberingSystem", dateTimeFormat.[[NumberingSystem]])를 수행한다.
  9. CreateDataPropertyOrThrow(nf2Options, "useGrouping", false)를 수행한다.
  10. nf2를 ! Construct(%Intl.NumberFormat%, « locale, nf2Options »)로 둔다.
  11. format[[fractionalSecondDigits]] 필드가 있으면,
    1. fractionalSecondDigitsformat.[[fractionalSecondDigits]]로 둔다.
    2. nf3OptionsOrdinaryObjectCreate(null)로 둔다.
    3. CreateDataPropertyOrThrow(nf3Options, "minimumIntegerDigits", 𝔽(fractionalSecondDigits))를 수행한다.
    4. CreateDataPropertyOrThrow(nf3Options, "numberingSystem", dateTimeFormat.[[NumberingSystem]])를 수행한다.
    5. CreateDataPropertyOrThrow(nf3Options, "useGrouping", false)를 수행한다.
    6. nf3를 ! Construct(%Intl.NumberFormat%, « locale, nf3Options »)로 둔다.
  12. localTimeToLocalTime(epochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]])로 둔다.
  13. patternPartsPartitionPattern(pattern)으로 둔다.
  14. result를 새 빈 List로 둔다.
  15. patternParts의 각 Record { [[Type]], [[Value]] } patternPart에 대해, 다음을 수행한다.
    1. partTypepatternPart.[[Type]]로 둔다.
    2. partType"literal"이면,
      1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }를 result에 추가한다.
    3. 그렇지 않고 partType"fractionalSecondDigits"이면,
      1. 단언: format[[fractionalSecondDigits]] 필드를 가진다.
      2. valuelocalTime.[[Millisecond]]로 둔다.
      3. valuefloor(value × 10( fractionalSecondDigits - 3 ))로 설정한다.
      4. formattedValueFormatNumeric(nf3, value)로 둔다.
      5. Record { [[Type]]: "fractionalSecond", [[Value]]: formattedValue }를 result에 추가한다.
    4. 그렇지 않고 partType"dayPeriod"이면,
      1. 단언: format[[dayPeriod]] 필드를 가진다.
      2. fieldFormatformat.[[dayPeriod]]로 둔다.
      3. formattedValuefieldFormat이 주는 형식으로 localTime의 day period를 나타내는 ILD String으로 둔다.
      4. Record { [[Type]]: partType, [[Value]]: formattedValue }를 result에 추가한다.
    5. 그렇지 않고 partType"timeZoneName"이면,
      1. 단언: format[[timeZoneName]] 필드를 가진다.
      2. fieldFormatformat.[[timeZoneName]]로 둔다.
      3. valuedateTimeFormat.[[TimeZone]]으로 둔다.
      4. formattedValuefieldFormat이 주는 형식으로 value를 나타내는 ILD String으로 둔다. fieldFormat"short", "long", "shortOffset", 또는 "longOffset"이면 그 값은 localTime[[InDST]] 필드 값에 의존할 수 있다. 구현이 fieldFormat의 그러한 현지화된 표현을 가지지 않는 경우, value 자체를 사용한다.
      5. Record { [[Type]]: partType, [[Value]]: formattedValue }를 result에 추가한다.
    6. 그렇지 않고 partTypeTable 16 행의 Property 열과 일치하면,
      1. 단언: format은 [[<partType>]] 필드를 가진다.
      2. fieldFormatformat.[[<partType>]]로 둔다.
      3. value를, 그 이름이 일치하는 행의 Internal Slot 열인 localTime의 필드 값으로 둔다.
      4. partType"year"이고 value ≤ 0이면, value를 1 - value로 설정한다.
      5. partType"month"이면, valuevalue + 1로 설정한다.
      6. partType"hour"이고 dateTimeFormat.[[HourCycle]]"h11" 또는 "h12"이면,
        1. valuevalue modulo 12로 설정한다.
        2. value = 0이고 dateTimeFormat.[[HourCycle]]"h12"이면, value를 12로 설정한다.
      7. partType"hour"이고 dateTimeFormat.[[HourCycle]]"h24"이면,
        1. value = 0이면, value를 24로 설정한다.
      8. fieldFormat"numeric"이면,
        1. formattedValueFormatNumeric(nf, value)로 둔다.
      9. 그렇지 않고 fieldFormat"2-digit"이면,
        1. formattedValueFormatNumeric(nf2, value)로 둔다.
        2. codePointsStringToCodePoints(formattedValue)로 둔다.
        3. countcodePoints의 요소 수로 둔다.
        4. count > 2이면,
          1. tenscodePoints[count - 2]로 둔다.
          2. onescodePoints[count - 1]로 둔다.
          3. formattedValueCodePointsToStringtens, ones »)으로 설정한다.
      10. 그렇지 않고 fieldFormat"narrow", "short", 또는 "long"이면,
        1. formattedValuefieldFormat이 주는 형식으로 value를 나타내는 ILD String으로 둔다. partType"month"이면, 그 값은 format[[day]] 필드가 있는지 여부에 의존할 수 있다. 구현이 fieldFormat의 현지화된 표현을 가지지 않는 경우, value 자체를 사용한다.
      11. Record { [[Type]]: partType, [[Value]]: formattedValue }를 result에 추가한다.
    7. 그렇지 않고 partType"ampm"이면,
      1. valuelocalTime.[[Hour]]로 둔다.
      2. value > 11이면 formattedValue"post meridiem"을 나타내는 ILD String으로 두고, 그렇지 않으면 formattedValue"ante meridiem"을 나타내는 ILD String으로 둔다.
      3. Record { [[Type]]: "dayPeriod", [[Value]]: formattedValue }를 result에 추가한다.
    8. 그렇지 않고 partType"relatedYear"이면,
      1. valuelocalTime.[[RelatedYear]]로 둔다.
      2. formattedValueFormatNumeric(nf, value)로 둔다.
      3. Record { [[Type]]: "relatedYear", [[Value]]: formattedValue }를 result에 추가한다.
    9. 그렇지 않고 partType"yearName"이면,
      1. valuelocalTime.[[YearName]]로 둔다.
      2. formattedValuevalue를 나타내는 ILD String으로 둔다.
      3. Record { [[Type]]: "yearName", [[Value]]: formattedValue }를 result에 추가한다.
    10. 그렇지 않으면,
      1. unknownepochNanosecondspartType에 기반한 ILND String으로 둔다.
      2. Record { [[Type]]: "unknown", [[Value]]: unknown }를 result에 추가한다.
  16. result를 반환한다.
Note
구현은 Common Locale Data Repository(https://cldr.unicode.org/에서 이용 가능)가 제공하는 locale 및 calendar 의존 문자열을 사용하고, DateTimeFormat "short" 문자열에는 CLDR "abbreviated" 문자열을, DateTimeFormat "long" 문자열에는 CLDR "wide" 문자열을 사용하는 것이 권장된다.

11.5.6 PartitionDateTimePattern ( dateTimeFormat, x )

The abstract operation PartitionDateTimePattern takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (Number) and returns [[Type]](String) 및 [[Value]](String) 필드를 가진 RecordsList를 포함하는 정상 완료, 또는 throw 완료. It performs the following steps when called:

  1. xTimeClip(x)로 설정한다.
  2. xNaN이면, RangeError 예외를 던진다.
  3. epochNanoseconds((x) × 106)로 둔다.
  4. formatdateTimeFormat.[[DateTimeFormat]]으로 둔다.
  5. dateTimeFormat.[[HourCycle]]"h11" 또는 "h12"이면,
    1. patternformat.[[pattern12]]로 둔다.
  6. 그렇지 않으면,
    1. patternformat.[[pattern]]으로 둔다.
  7. resultFormatDateTimePattern(dateTimeFormat, format, pattern, epochNanoseconds)로 둔다.
  8. result를 반환한다.

11.5.7 FormatDateTime ( dateTimeFormat, x )

The abstract operation FormatDateTime takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (Number) and returns String을 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. parts를 ? PartitionDateTimePattern(dateTimeFormat, x)로 둔다.
  2. result를 빈 String으로 둔다.
  3. parts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
    1. resultresultpart.[[Value]]의 문자열 연결로 설정한다.
  4. result를 반환한다.

11.5.8 FormatDateTimeToParts ( dateTimeFormat, x )

The abstract operation FormatDateTimeToParts takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (Number) and returns Array를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. parts를 ? PartitionDateTimePattern(dateTimeFormat, x)로 둔다.
  2. result를 ! ArrayCreate(0)으로 둔다.
  3. n을 0으로 둔다.
  4. parts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
    1. partObjOrdinaryObjectCreate(%Object.prototype%)로 둔다.
    2. CreateDataPropertyOrThrow(partObj, "type", part.[[Type]])를 수행한다.
    3. CreateDataPropertyOrThrow(partObj, "value", part.[[Value]])를 수행한다.
    4. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), partObj)를 수행한다.
    5. nn + 1로 설정한다.
  5. result를 반환한다.

11.5.9 PartitionDateTimeRangePattern ( dateTimeFormat, x, y )

The abstract operation PartitionDateTimeRangePattern takes arguments dateTimeFormat (Intl.DateTimeFormat), x (Number), and y (Number) and returns [[Type]](String), [[Value]](String), 그리고 [[Source]](String) 필드를 가진 RecordsList를 포함하는 정상 완료, 또는 throw 완료. It performs the following steps when called:

  1. xTimeClip(x)로 설정한다.
  2. xNaN이면, RangeError 예외를 던진다.
  3. yTimeClip(y)로 설정한다.
  4. yNaN이면, RangeError 예외를 던진다.
  5. xEpochNanoseconds((x) × 106)로 둔다.
  6. yEpochNanoseconds((y) × 106)로 둔다.
  7. localTime1ToLocalTime(xEpochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]])로 둔다.
  8. localTime2ToLocalTime(yEpochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]])로 둔다.
  9. formatdateTimeFormat.[[DateTimeFormat]]으로 둔다.
  10. dateTimeFormat.[[HourCycle]]"h11" 또는 "h12"이면,
    1. patternformat.[[pattern12]]로 둔다.
    2. rangePatternsformat.[[rangePatterns12]]로 둔다.
  11. 그렇지 않으면,
    1. patternformat.[[pattern]]으로 둔다.
    2. rangePatternsformat.[[rangePatterns]]로 둔다.
  12. selectedRangePatternundefined로 둔다.
  13. relevantFieldsEqualtrue로 둔다.
  14. checkMoreFieldstrue로 둔다.
  15. Table 6의 각 행에 대해, 헤더 행은 제외하고 표 순서대로, 다음을 수행한다.
    1. fieldName을 그 행의 Field Name 열에 주어진 이름으로 둔다.
    2. rangePatterns에 그 이름이 fieldName인 필드가 있으면 rangePatternrangePatterns의 그 필드로 두고, 그렇지 않으면 rangePatternundefined로 둔다.
    3. selectedRangePatternundefined가 아니고 rangePatternundefined이면,
      1. 참고: 이 필드 또는 그 아래의 차이에 대한 range pattern이 없으므로, 더 이상의 검사는 수행되지 않는다.
      2. checkMoreFieldsfalse로 설정한다.
    4. fieldName[[Default]]와 같지 않고 relevantFieldsEqualtrue이며 checkMoreFieldstrue이면,
      1. selectedRangePatternrangePattern으로 설정한다.
      2. fieldName[[AmPm]]이면,
        1. localTime1.[[Hour]]가 12보다 작으면 v1"am"으로 두고, 그렇지 않으면 v1"pm"으로 둔다.
        2. localTime2.[[Hour]]가 12보다 작으면 v2"am"으로 두고, 그렇지 않으면 v2"pm"으로 둔다.
      3. 그렇지 않고 fieldName[[DayPeriod]]이면,
        1. v1localTime1의 day period를 나타내는 ILD String으로 둔다.
        2. v2localTime2의 day period를 나타내는 ILD String으로 둔다.
      4. 그렇지 않고 fieldName[[FractionalSecondDigits]]이면,
        1. format[[fractionalSecondDigits]] 필드가 있으면,
          1. fractionalSecondDigitsformat.[[fractionalSecondDigits]]로 둔다.
        2. 그렇지 않으면,
          1. fractionalSecondDigits를 3으로 둔다.
        3. expfractionalSecondDigits - 3으로 둔다.
        4. v1floor(localTime1.[[Millisecond]] × 10exp)로 둔다.
        5. v2floor(localTime2.[[Millisecond]] × 10exp)로 둔다.
      5. 그렇지 않으면,
        1. v1을 그 이름이 fieldNamelocalTime1의 필드로 둔다.
        2. v2를 그 이름이 fieldNamelocalTime2의 필드로 둔다.
      6. v1v2와 같지 않으면,
        1. relevantFieldsEqualfalse로 설정한다.
  16. relevantFieldsEqualtrue이면,
    1. collapsedResult를 새 빈 List로 둔다.
    2. resultPartsFormatDateTimePattern(dateTimeFormat, format, pattern, xEpochNanoseconds)로 둔다.
    3. resultParts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
      1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Source]]: "shared" }를 collapsedResult에 추가한다.
    4. collapsedResult를 반환한다.
  17. rangeResult를 새 빈 List로 둔다.
  18. selectedRangePatternundefined이면,
    1. selectedRangePatternrangePatterns.[[Default]]로 설정한다.
  19. selectedRangePattern.[[PatternParts]]의 각 Record { [[Pattern]], [[Source]] } rangePatternPart에 대해, 다음을 수행한다.
    1. patternrangePatternPart.[[Pattern]]으로 둔다.
    2. sourcerangePatternPart.[[Source]]로 둔다.
    3. source"startRange" 또는 "shared"이면,
      1. zxEpochNanoseconds로 둔다.
    4. 그렇지 않으면,
      1. zyEpochNanoseconds로 둔다.
    5. resultPartsFormatDateTimePattern(dateTimeFormat, selectedRangePattern, pattern, z)로 둔다.
    6. resultParts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
      1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Source]]: source }를 rangeResult에 추가한다.
  20. rangeResult를 반환한다.

11.5.10 FormatDateTimeRange ( dateTimeFormat, x, y )

The abstract operation FormatDateTimeRange takes arguments dateTimeFormat (Intl.DateTimeFormat), x (Number), and y (Number) and returns String을 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. parts를 ? PartitionDateTimeRangePattern(dateTimeFormat, x, y)로 둔다.
  2. result를 빈 String으로 둔다.
  3. parts의 각 Record { [[Type]], [[Value]], [[Source]] } part에 대해, 다음을 수행한다.
    1. resultresultpart.[[Value]]의 문자열 연결로 설정한다.
  4. result를 반환한다.

11.5.11 FormatDateTimeRangeToParts ( dateTimeFormat, x, y )

The abstract operation FormatDateTimeRangeToParts takes arguments dateTimeFormat (Intl.DateTimeFormat), x (Number), and y (Number) and returns Array를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. parts를 ? PartitionDateTimeRangePattern(dateTimeFormat, x, y)로 둔다.
  2. result를 ! ArrayCreate(0)으로 둔다.
  3. n을 0으로 둔다.
  4. parts의 각 Record { [[Type]], [[Value]], [[Source]] } part에 대해, 다음을 수행한다.
    1. partObjOrdinaryObjectCreate(%Object.prototype%)로 둔다.
    2. CreateDataPropertyOrThrow(partObj, "type", part.[[Type]])를 수행한다.
    3. CreateDataPropertyOrThrow(partObj, "value", part.[[Value]])를 수행한다.
    4. CreateDataPropertyOrThrow(partObj, "source", part.[[Source]])를 수행한다.
    5. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), partObj)를 수행한다.
    6. nn + 1로 설정한다.
  5. result를 반환한다.

11.5.12 ToLocalTime ( epochNs, calendar, timeZoneIdentifier )

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

  1. IsTimeZoneOffsetString(timeZoneIdentifier)이 true이면,
    1. offsetNsParseTimeZoneOffsetString(timeZoneIdentifier)로 둔다.
  2. 그렇지 않으면,
    1. 단언: GetAvailableNamedTimeZoneIdentifier(timeZoneIdentifier)는 empty가 아니다.
    2. offsetNsGetNamedTimeZoneOffsetNanoseconds(timeZoneIdentifier, epochNs)로 둔다.
  3. tz(epochNs) + offsetNs로 둔다.
  4. calendar"gregory"이면,
    1. Table 17에 따라 tz로부터 계산된 필드를 가진 ToLocalTime Record를 반환한다.
  5. 그렇지 않으면,
    1. 주어진 calendar에 대해 tz로부터 계산된 필드를 가진 ToLocalTime Record를 반환한다. 계산에는 지정된 calendar에 관해 이용 가능한 최선의 정보를 사용해야 한다.

11.5.13 ToLocalTime Records

ToLocalTime RecordTable 17에 정의된 필드를 가진다.

Table 17: ToLocalTime이 반환하는 Record
필드 이름 값 유형 Gregorian Calendar에 대한 값 계산
[[Weekday]] 정수 (WeekDay(𝔽(floor(tz / 106))))
[[Era]] String yearYearFromTime(𝔽(floor(tz / 106)))로 둔다. year < 1𝔽이면 "BC"를 반환하고, 그렇지 않으면 "AD"를 반환한다.
[[Year]] 정수 (YearFromTime(𝔽(floor(tz / 106))))
[[RelatedYear]] 정수 또는 undefined undefined
[[YearName]] String 또는 undefined undefined
[[Month]] 정수 (MonthFromTime(𝔽(floor(tz / 106))))
[[Day]] 정수 (DateFromTime(𝔽(floor(tz / 106))))
[[Hour]] 정수 (HourFromTime(𝔽(floor(tz / 106))))
[[Minute]] 정수 (MinFromTime(𝔽(floor(tz / 106))))
[[Second]] 정수 (SecFromTime(𝔽(floor(tz / 106))))
[[Millisecond]] 정수 (msFromTime(𝔽(floor(tz / 106))))
[[InDST]] Boolean UTC로부터의 time zone offset 및 daylight saving time 규칙에 관한 IANA Time Zone Database의 현재 및 역사적 정보를 포함하여, 지정된 calendartimeZoneIdentifier에 관해 이용 가능한 최선의 정보를 사용해 true 또는 false를 계산한다.

11.5.14 UnwrapDateTimeFormat ( dtf )

The abstract operation UnwrapDateTimeFormat takes argument dtf (ECMAScript 언어 값) and returns ECMAScript 언어 값을 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. dtf가 Object가 아니면, TypeError 예외를 던진다.
  2. dtf[[InitializedDateTimeFormat]] 내부 슬롯을 가지지 않고 ? OrdinaryHasInstance(%Intl.DateTimeFormat%, dtf)가 true이면,
    1. Get(dtf, %Intl%.[[FallbackSymbol]])를 반환한다.
  3. dtf를 반환한다.

12 DisplayNames 객체

12.1 Intl.DisplayNames 생성자

Intl.DisplayNames 생성자는:

  • %Intl.DisplayNames%이다.
  • Intl 객체"DisplayNames" 속성의 초기값이다.

Intl 객체의 모든 서비스 생성자 속성에 공통인 동작은 9.1에 명시되어 있다.

12.1.1 Intl.DisplayNames ( locales, options )

Intl.DisplayNames 함수가 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. NewTarget이 undefined이면 TypeError 예외를 던진다.
  2. displayNames를 ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.DisplayNames.prototype%", « [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[LanguageDisplay]], [[Fields]] »)로 둔다.
  3. optionsResolution을 ? ResolveOptions(%Intl.DisplayNames%, %Intl.DisplayNames%.[[LocaleData]], locales, options, « require-options »)로 둔다.
  4. optionsoptionsResolution.[[Options]]로 설정한다.
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]]로 둔다.
  6. style을 ? GetOption(options, "style", string, « "narrow", "short", "long" », "long")로 둔다.
  7. displayNames.[[Style]]style로 설정한다.
  8. type을 ? GetOption(options, "type", string, « "language", "region", "script", "currency", "calendar", "dateTimeField" », required)로 둔다.
  9. displayNames.[[Type]]type으로 설정한다.
  10. fallback을 ? GetOption(options, "fallback", string, « "code", "none" », "code")로 둔다.
  11. displayNames.[[Fallback]]fallback으로 설정한다.
  12. displayNames.[[Locale]]resolvedLocale.[[Locale]]로 설정한다.
  13. resolvedLocaleDataresolvedLocale.[[LocaleData]]로 둔다.
  14. typesresolvedLocaleData.[[types]]로 둔다.
  15. Assert: typesRecord이다(12.2.3 참조).
  16. languageDisplay를 ? GetOption(options, "languageDisplay", string, « "dialect", "standard" », "dialect")로 둔다.
  17. typeFieldstypes.[[<type>]]로 둔다.
  18. Assert: typeFieldsRecord이다(12.2.3 참조).
  19. type"language"이면,
    1. displayNames.[[LanguageDisplay]]languageDisplay로 설정한다.
    2. typeFieldstypeFields.[[<languageDisplay>]]로 설정한다.
    3. Assert: typeFieldsRecord이다(12.2.3 참조).
  20. styleFieldstypeFields.[[<style>]]로 둔다.
  21. Assert: styleFieldsRecord이다(12.2.3 참조).
  22. displayNames.[[Fields]]styleFields로 설정한다.
  23. displayNames를 반환한다.

12.2 Intl.DisplayNames 생성자의 속성

Intl.DisplayNames 생성자는:

  • 값이 %Function.prototype%[[Prototype]] 내부 슬롯을 가진다.
  • 다음 속성을 가진다:

12.2.1 Intl.DisplayNames.prototype

Intl.DisplayNames.prototype의 값은 %Intl.DisplayNames.prototype%이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } 속성을 가진다.

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

supportedLocalesOf 메서드가 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. availableLocales%Intl.DisplayNames%.[[AvailableLocales]]로 둔다.
  2. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  3. FilterLocales(availableLocales, requestedLocales, options)를 반환한다.

12.2.3 내부 슬롯

[[AvailableLocales]] 내부 슬롯의 값은 9.1에 설명된 제약 안에서 구현 정의이다.

[[RelevantExtensionKeys]] 내부 슬롯의 값은 « »이다.

[[ResolutionOptionDescriptors]] 내부 슬롯의 값은 « »이다.

[[LocaleData]] 내부 슬롯의 값은 9.1에 설명된 제약 및 다음 추가 제약 안에서 구현 정의이다:

  • [[LocaleData]].[[<locale>]]는 모든 locale 값 locale에 대해 [[types]] 필드를 가져야 한다. 이 필드의 값은 Record여야 하며, 모든 display name type의 이름을 가진 필드를 가져야 한다: "language", "region", "script", "currency", "calendar""dateTimeField".
  • 필드 "language"의 값은 Record여야 하며, 유효한 language display 중 하나의 이름을 가진 필드를 가져야 한다: "dialect""standard".
  • display name type "language" 아래의 language display 필드는 유효한 display name style 중 하나의 이름을 가진 필드를 가져야 하는 Record를 포함해야 한다: "narrow", "short""long".
  • 필드 "region", "script", "currency", "calendar""dateTimeField"의 값은 Record여야 하며, 모든 display name style의 이름을 가진 필드를 가져야 한다: "narrow", "short""long".
  • display name type "language" 아래의 display name style 필드는 unicode_language_id Unicode locale nonterminal에 의해 매칭될 수 있는 language code에 대응하는 key를 가진 Record를 포함해야 한다. 이 필드들의 값은 string 값이어야 한다.
  • display name type "region" 아래의 display name style 필드는 region code에 대응하는 key를 가진 Record를 포함해야 한다. 이 필드들의 값은 string 값이어야 한다.
  • display name type "script" 아래의 display name style 필드는 script code에 대응하는 key를 가진 Record를 포함해야 한다. 이 필드들의 값은 string 값이어야 한다.
  • display name type "currency" 아래의 display name style 필드는 currency code에 대응하는 key를 가진 Record를 포함해야 한다. 이 필드들의 값은 string 값이어야 한다.
  • display name type "calendar" 아래의 display name style 필드는 type Unicode locale nonterminal에 의해 매칭될 수 있는 calendar identifier에 대응하는 key를 가진 Record를 포함해야 한다. 이 필드들의 값은 string 값이어야 한다.
  • display name type "dateTimeField" 아래의 display name style 필드는 Table 19에 나열된 code에 대응하는 key를 가진 Record를 포함해야 한다. 이 필드들의 값은 string 값이어야 한다.
Note
구현은 Common Locale Data Repository(https://cldr.unicode.org/에서 이용 가능)가 제공하는 locale 데이터를 사용하는 것이 권장된다.

12.3 Intl.DisplayNames Prototype 객체의 속성

Intl.DisplayNames prototype 객체는:

  • %Intl.DisplayNames.prototype%이다.
  • ordinary 객체이다.
  • Intl.DisplayNames 인스턴스가 아니며 [[InitializedDisplayNames]] 내부 슬롯 또는 Intl.DisplayNames 인스턴스 객체의 다른 내부 슬롯을 가지지 않는다.
  • 값이 %Object.prototype%[[Prototype]] 내부 슬롯을 가진다.

12.3.1 Intl.DisplayNames.prototype.constructor

Intl.DisplayNames.prototype.constructor의 초기값은 %Intl.DisplayNames%이다.

12.3.2 Intl.DisplayNames.prototype.resolvedOptions ( )

이 함수는 객체 초기화 중 계산된 locale 및 options에 대한 접근을 제공한다.

  1. displayNamesthis 값으로 둔다.
  2. RequireInternalSlot(displayNames, [[InitializedDisplayNames]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  4. Table 18의 각 행에 대해, 헤더 행을 제외하고 표 순서대로, 다음을 수행한다.
    1. propertyKey를 현재 행의 Property 값으로 둔다.
    2. value를 현재 행의 Internal Slot 값이 이름인 displayNames의 내부 슬롯 값으로 둔다.
    3. valueundefined가 아니면,
      1. CreateDataPropertyOrThrow(options, propertyKey, value)를 수행한다.
  5. options를 반환한다.
Table 18: DisplayNames 인스턴스의 Resolved Options
Internal Slot Property
[[Locale]] "locale"
[[Style]] "style"
[[Type]] "type"
[[Fallback]] "fallback"
[[LanguageDisplay]] "languageDisplay"

12.3.3 Intl.DisplayNames.prototype.of ( code )

Intl.DisplayNames.prototype.of가 인수 code와 함께 호출되면 다음 단계가 수행된다:

  1. displayNamesthis 값으로 둔다.
  2. RequireInternalSlot(displayNames, [[InitializedDisplayNames]])를 수행한다.
  3. code를 ? ToString(code)로 설정한다.
  4. code를 ? CanonicalCodeForDisplayNames(displayNames.[[Type]], code)로 설정한다.
  5. fieldsdisplayNames.[[Fields]]로 둔다.
  6. fields가 [[<code>]] 필드를 가지면 fields.[[<code>]]를 반환한다.
  7. displayNames.[[Fallback]]"code"이면 code를 반환한다.
  8. undefined를 반환한다.

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

%Symbol.toStringTag% 속성의 초기값은 String 값 "Intl.DisplayNames"이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } 속성을 가진다.

12.4 Intl.DisplayNames 인스턴스의 속성

Intl.DisplayNames 인스턴스는 %Intl.DisplayNames.prototype%에서 속성을 상속하는 ordinary 객체이다.

Intl.DisplayNames 인스턴스는 [[InitializedDisplayNames]] 내부 슬롯을 가진다.

Intl.DisplayNames 인스턴스는 또한 Intl.DisplayNames 생성자에 의해 계산되는 여러 내부 슬롯을 가진다:

  • [[Locale]]은 형식화에 사용되는 localization의 locale 언어 태그를 가진 String 값이다.
  • [[Style]]은 사용되는 display name style을 식별하는 String 값 "narrow", "short" 또는 "long" 중 하나이다.
  • [[Type]]은 요청된 display name의 type을 식별하는 String 값 "language", "region", "script", "currency", "calendar" 또는 "dateTimeField" 중 하나이다.
  • [[Fallback]]은 시스템이 요청된 display name을 가지지 않을 때의 fallback 반환을 식별하는 String 값 "code" 또는 "none" 중 하나이다.
  • [[LanguageDisplay]]는 language display kind를 식별하는 String 값 "dialect" 또는 "standard" 중 하나이다. 이는 [[Type]]이 값 "language"를 가질 때만 사용된다.
  • [[Fields]]Record(12.2.3 참조)이며, [[Style]], [[Type]][[LanguageDisplay]]에 따른 code에 대응하는 key를 가진 필드를 가져야 한다.

12.5 DisplayNames 객체를 위한 추상 연산

12.5.1 CanonicalCodeForDisplayNames ( type, code )

The abstract operation CanonicalCodeForDisplayNames takes arguments type (String) and code (String) and returns String을 포함하는 정상 완료 또는 throw 완료. codetype에 따라 well-formed code를 나타내는지 검증하고, code의 대소문자가 정규화된 형식을 반환한다. It performs the following steps when called:

  1. type"language"이면,
    1. codeunicode_language_id Unicode locale nonterminal에 의해 매칭될 수 없으면 RangeError 예외를 던진다.
    2. IsWellFormedLanguageTag(code)가 false이면 RangeError 예외를 던진다.
    3. CanonicalizeUnicodeLocaleId(code)를 반환한다.
  2. type"region"이면,
    1. codeunicode_region_subtag Unicode locale nonterminal에 의해 매칭될 수 없으면 RangeError 예외를 던진다.
    2. codeASCII-uppercase를 반환한다.
  3. type"script"이면,
    1. codeunicode_script_subtag Unicode locale nonterminal에 의해 매칭될 수 없으면 RangeError 예외를 던진다.
    2. Assert: code의 길이는 4이고, code의 모든 code unit은 ASCII 문자(0x0041부터 0x005A 및 0x0061부터 0x007A까지, 양끝 포함)를 나타낸다.
    3. firstcode의 0부터 1까지 부분 문자열의 ASCII-uppercase로 둔다.
    4. restcode의 1부터의 부분 문자열의 ASCII-lowercase로 둔다.
    5. firstrest의 문자열 연결을 반환한다.
  4. type"calendar"이면,
    1. codetype Unicode locale nonterminal에 의해 매칭될 수 없으면 RangeError 예외를 던진다.
    2. codeUnicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance에 설명된 하위 호환성 구문 중 하나를 사용하면 RangeError 예외를 던진다.
    3. codeASCII-lowercase를 반환한다.
  5. type"dateTimeField"이면,
    1. IsValidDateTimeFieldCode(code)의 결과가 false이면 RangeError 예외를 던진다.
    2. code를 반환한다.
  6. Assert: type"currency"이다.
  7. IsWellFormedCurrencyCode(code)가 false이면 RangeError 예외를 던진다.
  8. codeASCII-uppercase를 반환한다.

12.5.2 IsValidDateTimeFieldCode ( field )

The abstract operation IsValidDateTimeFieldCode takes argument field (String) and returns Boolean. field 인수가 유효한 date time field code를 나타내는지 검증한다. It performs the following steps when called:

  1. fieldTable 19의 Code 열에 나열되어 있으면 true를 반환한다.
  2. false를 반환한다.
Table 19: DisplayNames의 Date Time Field에 대한 Code
Code 설명
"era" era를 나타내는 필드. 예: Gregorian 또는 Julian calendar의 AD 또는 BC.
"year" year(era 내)를 나타내는 필드.
"quarter" quarter를 나타내는 필드. 예: Q2, 2nd quarter 등.
"month" month를 나타내는 필드. 예: Sep, September 등.
"weekOfYear" year 내의 week number를 나타내는 필드.
"weekday" day of week를 나타내는 필드. 예: Tue, Tuesday 등.
"day" month 안의 day를 나타내는 필드.
"dayPeriod" day period를 나타내는 필드. am, pm 등 또는 noon, evening 등.
"hour" hour를 나타내는 필드.
"minute" minute를 나타내는 필드.
"second" second를 나타내는 필드.
"timeZoneName" time zone name을 나타내는 필드. 예: 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 함수가 선택적 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. NewTarget이 undefined이면 TypeError 예외를 던진다.
  2. durationFormat을 ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.DurationFormatPrototype%", « [[InitializedDurationFormat]], [[Locale]], [[NumberingSystem]], [[Style]], [[YearsOptions]], [[MonthsOptions]], [[WeeksOptions]], [[DaysOptions]], [[HoursOptions]], [[MinutesOptions]], [[SecondsOptions]], [[MillisecondsOptions]], [[MicrosecondsOptions]], [[NanosecondsOptions]], [[HourMinuteSeparator]], [[MinuteSecondSeparator]], [[FractionalDigits]] »)로 둔다.
  3. optionsResolution을 ? ResolveOptions(%Intl.DurationFormat%, %Intl.DurationFormat%.[[LocaleData]], locales, options)로 둔다.
  4. optionsoptionsResolution.[[Options]]로 설정한다.
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]]로 둔다.
  6. durationFormat.[[Locale]]resolvedLocale.[[Locale]]로 설정한다.
  7. resolvedLocaleDataresolvedLocale.[[LocaleData]]로 둔다.
  8. digitalFormatresolvedLocaleData.[[DigitalFormat]]로 둔다.
  9. durationFormat.[[HourMinuteSeparator]]digitalFormat.[[HourMinuteSeparator]]로 설정한다.
  10. durationFormat.[[MinuteSecondSeparator]]digitalFormat.[[MinuteSecondSeparator]]로 설정한다.
  11. durationFormat.[[NumberingSystem]]resolvedLocale.[[nu]]로 설정한다.
  12. style을 ? GetOption(options, "style", string, « "long", "short", "narrow", "digital" », "short")로 둔다.
  13. durationFormat.[[Style]]style로 설정한다.
  14. prevStyle을 빈 String으로 둔다.
  15. Table 20의 각 행에 대해, 헤더 행을 제외하고 표 순서대로, 다음을 수행한다.
    1. slot을 현재 행의 Internal Slot 값으로 둔다.
    2. unit을 현재 행의 Unit 값으로 둔다.
    3. styles를 현재 행의 Styles 값으로 둔다.
    4. digitalBase를 현재 행의 Digital Default 값으로 둔다.
    5. unitOptions를 ? GetDurationUnitOptions(unit, options, style, styles, digitalBase, prevStyle, digitalFormat.[[TwoDigitHours]])로 둔다.
    6. durationFormat의, 이름이 slot인 내부 슬롯 값을 unitOptions로 설정한다.
    7. unit"hours", "minutes", "seconds", "milliseconds" 또는 "microseconds" 중 하나이면,
      1. prevStyleunitOptions.[[Style]]로 설정한다.
  16. durationFormat.[[FractionalDigits]]를 ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined)로 설정한다.
  17. durationFormat을 반환한다.
Table 20: DurationFormat 인스턴스의 내부 슬롯 및 속성 이름
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 생성자는:

  • 값이 %Function.prototype%[[Prototype]] 내부 슬롯을 가진다.
  • 다음 속성을 가진다:

13.2.1 Intl.DurationFormat.prototype

Intl.DurationFormat.prototype의 값은 %Intl.DurationFormat.prototype%이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } 속성을 가진다.

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

supportedLocalesOf 메서드가 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. availableLocales%Intl.DurationFormat%.[[AvailableLocales]]로 둔다.
  2. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  3. FilterLocales(availableLocales, requestedLocales, options)를 반환한다.

13.2.3 내부 슬롯

[[AvailableLocales]] 내부 슬롯의 값은 9.1에 설명된 제약 안에서 구현 정의이다.

[[RelevantExtensionKeys]] 내부 슬롯의 값은 « "nu" »이다.

[[ResolutionOptionDescriptors]] 내부 슬롯의 값은 « { [[Key]]: "nu", [[Property]]: "numberingSystem" } »이다.

[[LocaleData]] 내부 슬롯의 값은 9.1에 설명된 제약 및 다음 추가 제약 안에서, 모든 locale 값 locale에 대해 구현 정의이다:

  • [[LocaleData]].[[<locale>]]는 [[nu]][[DigitalFormat]] 필드를 가진 Record여야 한다.
  • [[LocaleData]].[[<locale>]].[[nu]]16.2.3에 명시된 List여야 하며, "native", "traditio" 또는 "finance" 값을 포함해서는 안 된다.
  • [[LocaleData]].[[<locale>]].[[DigitalFormat]]locale에 대해 사용할 수 있는 각 numbering system에 대응하는 key를 가진 Record여야 한다. 그러한 key 중 하나와 연결된 각 값은 다음 필드를 포함하는 Record여야 한다:
    • [[HourMinuteSeparator]]는 style "numeric" 또는 "2-digit"을 사용할 때 locale과 numbering system의 그 조합에 대해 hours와 minutes 사이의 적절한 구분자인 String 값이어야 한다.
    • [[MinuteSecondSeparator]]는 style "numeric" 또는 "2-digit"을 사용할 때 locale과 numbering system의 그 조합에 대해 minutes와 seconds 사이의 적절한 구분자인 String 값이어야 한다.
    • [[TwoDigitHours]]는 style "numeric"을 사용할 때 hours가 항상 두 자리로 표시되는지를 나타내는 Boolean 값이어야 한다.
Note
구현은 Common Locale Data Repository(http://cldr.unicode.org/에서 이용 가능)가 제공하는 locale 데이터를 사용하는 것이 권장된다.

13.3 Intl.DurationFormat Prototype 객체의 속성

Intl.DurationFormat prototype 객체는:

  • %Intl.DurationFormat.prototype%이다.
  • ordinary 객체이다.
  • Intl.DurationFormat 인스턴스가 아니며 [[InitializedDurationFormat]] 내부 슬롯 또는 Intl.DurationFormat 인스턴스 객체의 다른 내부 슬롯을 가지지 않는다.
  • 값이 %Object.prototype%[[Prototype]] 내부 슬롯을 가진다.

13.3.1 Intl.DurationFormat.prototype.constructor

Intl.DurationFormat.prototype.constructor의 초기값은 내재 객체 %Intl.DurationFormat%이다.

13.3.2 Intl.DurationFormat.prototype.resolvedOptions ( )

이 함수는 객체 초기화 중 계산된 locale 및 options에 대한 접근을 제공한다.

  1. dfthis 값으로 둔다.
  2. RequireInternalSlot(df, [[InitializedDurationFormat]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  4. Table 21의 각 행에 대해, 헤더 행을 제외하고 표 순서대로, 다음을 수행한다.
    1. propertyKey를 현재 행의 Property 값으로 둔다.
    2. value를 현재 행의 Internal Slot 값이 이름인 df의 내부 슬롯 값으로 둔다.
    3. valueundefined가 아니면,
      1. 현재 행에 Conversion 값이 있으면 conversion을 그 값으로 두고, 그렇지 않으면 conversionempty로 둔다.
      2. conversionnumber이면,
        1. value𝔽(value)로 설정한다.
      3. 그렇지 않고 conversionempty가 아니면,
        1. Assert: conversionstyle+display이고 valueDuration Unit Options Record이다.
        2. NOTE: value.[[Style]]propertyKey(복수 Temporal unit)라는 이름의 속성으로 표현되고, 이어서 value.[[Display]]propertyKey"Display"를 접미사로 붙인 이름의 속성으로 표현된다.
        3. stylevalue.[[Style]]로 둔다.
        4. style"fractional"이면,
          1. Assert: IsFractionalSecondUnitName(propertyKey)는 true이다.
          2. style"numeric"으로 설정한다.
        5. CreateDataPropertyOrThrow(options, propertyKey, style)를 수행한다.
        6. propertyKeypropertyKey"Display"의 문자열 연결로 설정한다.
        7. valuevalue.[[Display]]로 설정한다.
      4. CreateDataPropertyOrThrow(options, propertyKey, value)를 수행한다.
  5. options를 반환한다.
Table 21: DurationFormat 인스턴스의 Resolved Options
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과 함께 호출되면 다음 단계가 수행된다:

  1. dfthis 값으로 둔다.
  2. RequireInternalSlot(df, [[InitializedDurationFormat]])를 수행한다.
  3. record를 ? ToDurationRecord(duration)로 둔다.
  4. partsPartitionDurationFormatPattern(df, record)로 둔다.
  5. result를 빈 String으로 둔다.
  6. parts의 각 Record { [[Type]], [[Value]], [[Unit]] } part에 대해, 다음을 수행한다.
    1. resultresultpart.[[Value]]의 문자열 연결로 설정한다.
  7. result를 반환한다.

13.3.4 Intl.DurationFormat.prototype.formatToParts ( duration )

formatToParts 메서드가 인수 duration과 함께 호출되면 다음 단계가 수행된다:

  1. dfthis 값으로 둔다.
  2. RequireInternalSlot(df, [[InitializedDurationFormat]])를 수행한다.
  3. record를 ? ToDurationRecord(duration)로 둔다.
  4. partsPartitionDurationFormatPattern(df, record)로 둔다.
  5. result를 ! ArrayCreate(0)으로 둔다.
  6. n을 0으로 둔다.
  7. parts의 각 Record { [[Type]], [[Value]], [[Unit]] } part에 대해, 다음을 수행한다.
    1. objOrdinaryObjectCreate(%Object.prototype%)로 둔다.
    2. CreateDataPropertyOrThrow(obj, "type", part.[[Type]])를 수행한다.
    3. CreateDataPropertyOrThrow(obj, "value", part.[[Value]])를 수행한다.
    4. part.[[Unit]]empty가 아니면, ! CreateDataPropertyOrThrow(obj, "unit", part.[[Unit]])를 수행한다.
    5. CreateDataPropertyOrThrow(result, ! ToString(n), obj)를 수행한다.
    6. nn + 1로 설정한다.
  8. result를 반환한다.

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

%Symbol.toStringTag% 속성의 초기값은 String 값 "Intl.DurationFormat"이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } 속성을 가진다.

13.4 Intl.DurationFormat 인스턴스의 속성

Intl.DurationFormat 인스턴스는 %Intl.DurationFormat.prototype%에서 속성을 상속한다.

Intl.DurationFormat 인스턴스는 [[InitializedDurationFormat]] 내부 슬롯을 가진다.

Intl.DurationFormat 인스턴스는 또한 Intl.DurationFormat 생성자에 의해 계산되는 여러 내부 슬롯을 가진다:

  • [[Locale]]은 형식화에 사용되는 localization의 locale 언어 태그를 가진 String 값이다.
  • [[NumberingSystem]]은 형식화에 사용되는 Unicode Number System Identifier를 나타내는 String 값이다.
  • [[Style]]은 사용되는 duration formatting style을 식별하는 String 값 "long", "short", "narrow" 또는 "digital" 중 하나이다.
  • [[YearsOptions]]Duration Record[[Years]] 필드에 대한 formatting style 및 display criteria를 식별하는 Duration Unit Options Record이다.
  • [[MonthsOptions]]Duration Record[[Months]] 필드에 대한 formatting style 및 display criteria를 식별하는 Duration Unit Options Record이다.
  • [[WeeksOptions]]Duration Record[[Weeks]] 필드에 대한 formatting style 및 display criteria를 식별하는 Duration Unit Options Record이다.
  • [[DaysOptions]]Duration Record[[Days]] 필드에 대한 formatting style 및 display criteria를 식별하는 Duration Unit Options Record이다.
  • [[HoursOptions]]Duration Record[[Hours]] 필드에 대한 formatting style 및 display criteria를 식별하는 Duration Unit Options Record이다.
  • [[MinutesOptions]]Duration Record[[Minutes]] 필드에 대한 formatting style 및 display criteria를 식별하는 Duration Unit Options Record이다.
  • [[SecondsOptions]]Duration Record[[Seconds]] 필드에 대한 formatting style 및 display criteria를 식별하는 Duration Unit Options Record이다.
  • [[MillisecondsOptions]]Duration Record[[Milliseconds]] 필드에 대한 formatting style 및 display criteria를 식별하는 Duration Unit Options Record이다.
  • [[MicrosecondsOptions]]Duration Record[[Microseconds]] 필드에 대한 formatting style 및 display criteria를 식별하는 Duration Unit Options Record이다.
  • [[NanosecondsOptions]]Duration Record[[Nanoseconds]] 필드에 대한 formatting style 및 display criteria를 식별하는 Duration Unit Options Record이다.
  • [[HourMinuteSeparator]]는 두 필드가 모두 표시되고 두 필드가 모두 numeric style을 사용해 형식화될 때 hours와 minutes 사이에 사용될 separator를 식별하는 String 값이다.
  • [[MinuteSecondSeparator]]는 두 필드가 모두 표시되고 두 필드가 모두 numeric style을 사용해 형식화될 때 minutes와 seconds 사이에 사용될 separator를 식별하는 String 값이다.
  • [[FractionalDigits]]undefined이거나 numeric style과 함께 사용될 fractional digit의 수를 식별하는 음이 아닌 정수이다.

13.5 DurationFormat 객체를 위한 추상 연산

13.5.1 Duration Record

Duration Record는 Duration을 나타내는 데 사용되는 Record 값이다.

Duration Record는 Table 22에 나열된 필드를 가진다

Table 22: Duration Record Fields
Field 의미
[[Years]] duration에 포함된 years의 수.
[[Months]] duration에 포함된 months의 수.
[[Weeks]] duration에 포함된 weeks의 수.
[[Days]] duration에 포함된 days의 수.
[[Hours]] duration에 포함된 hours의 수.
[[Minutes]] duration에 포함된 minutes의 수.
[[Seconds]] duration에 포함된 seconds의 수.
[[Milliseconds]] duration에 포함된 milliseconds의 수.
[[Microseconds]] duration에 포함된 microseconds의 수.
[[Nanoseconds]] duration에 포함된 nanoseconds의 수.

13.5.2 ToIntegerIfIntegral ( arg )

The abstract operation ToIntegerIfIntegral takes argument arg (ECMAScript 언어 값) and returns 정수를 포함하는 정상 완료 또는 throw 완료. arg를 그 Number 값을 나타내는 정수로 변환하거나, 그 값이 integral이 아닐 때 RangeError를 던진다. It performs the following steps when called:

  1. number를 ? ToNumber(arg)로 둔다.
  2. numberintegral Number가 아니면 RangeError 예외를 던진다.
  3. (number)를 반환한다.

13.5.3 ToDurationRecord ( input )

The abstract operation ToDurationRecord takes argument input (ECMAScript 언어 값) and returns Duration Record를 포함하는 정상 완료 또는 throw 완료. Duration을 나타내는 주어진 객체를 Duration Record로 변환한다. It performs the following steps when called:

  1. input이 Object가 아니면,
    1. input이 String이면 RangeError 예외를 던진다.
    2. TypeError 예외를 던진다.
  2. result를 각 필드가 0으로 설정된 새 Duration Record로 둔다.
  3. days를 ? Get(input, "days")로 둔다.
  4. daysundefined가 아니면 result.[[Days]]를 ? ToIntegerIfIntegral(days)로 설정한다.
  5. hours를 ? Get(input, "hours")로 둔다.
  6. hoursundefined가 아니면 result.[[Hours]]를 ? ToIntegerIfIntegral(hours)로 설정한다.
  7. microseconds를 ? Get(input, "microseconds")로 둔다.
  8. microsecondsundefined가 아니면 result.[[Microseconds]]를 ? ToIntegerIfIntegral(microseconds)로 설정한다.
  9. milliseconds를 ? Get(input, "milliseconds")로 둔다.
  10. millisecondsundefined가 아니면 result.[[Milliseconds]]를 ? ToIntegerIfIntegral(milliseconds)로 설정한다.
  11. minutes를 ? Get(input, "minutes")로 둔다.
  12. minutesundefined가 아니면 result.[[Minutes]]를 ? ToIntegerIfIntegral(minutes)로 설정한다.
  13. months를 ? Get(input, "months")로 둔다.
  14. monthsundefined가 아니면 result.[[Months]]를 ? ToIntegerIfIntegral(months)로 설정한다.
  15. nanoseconds를 ? Get(input, "nanoseconds")로 둔다.
  16. nanosecondsundefined가 아니면 result.[[Nanoseconds]]를 ? ToIntegerIfIntegral(nanoseconds)로 설정한다.
  17. seconds를 ? Get(input, "seconds")로 둔다.
  18. secondsundefined가 아니면 result.[[Seconds]]를 ? ToIntegerIfIntegral(seconds)로 설정한다.
  19. weeks를 ? Get(input, "weeks")로 둔다.
  20. weeksundefined가 아니면 result.[[Weeks]]를 ? ToIntegerIfIntegral(weeks)로 설정한다.
  21. years를 ? Get(input, "years")로 둔다.
  22. yearsundefined가 아니면 result.[[Years]]를 ? ToIntegerIfIntegral(years)로 설정한다.
  23. years, months, weeks, days, hours, minutes, seconds, milliseconds, microsecondsnanoseconds가 모두 undefined이면 TypeError 예외를 던진다.
  24. IsValidDuration( result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]])가 false이면,
    1. RangeError 예외를 던진다.
  25. result를 반환한다.

13.5.4 DurationSign ( duration )

The abstract operation DurationSign takes argument duration (Duration Record) and returns -1, 0 또는 1. duration 인수에서 가장 중요한 0이 아닌 필드가 양수이면 1을 반환하고, 가장 중요한 0이 아닌 필드가 음수이면 -1을 반환한다. duration의 모든 필드가 0이면 0을 반환한다. It performs the following steps when called:

  1. « duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]] »의 각 값 v에 대해, 다음을 수행한다.
    1. v < 0이면 -1을 반환한다.
    2. v > 0이면 1을 반환한다.
  2. 0을 반환한다.

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

The abstract operation IsValidDuration takes arguments years (정수), months (정수), weeks (정수), days (정수), hours (정수), minutes (정수), seconds (정수), milliseconds (정수), microseconds (정수), and nanoseconds (정수) and returns Boolean. 인수들이 Duration Record를 구성할 수 있는 유효한 입력을 형성하면 true를 반환하고, 그렇지 않으면 false를 반환한다. It performs the following steps when called:

  1. sign을 0으로 둔다.
  2. « years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds »의 각 값 v에 대해, 다음을 수행한다.
    1. 𝔽(v)가 finite가 아니면 false를 반환한다.
    2. v < 0이면,
      1. sign > 0이면 false를 반환한다.
      2. sign을 -1로 설정한다.
    3. 그렇지 않고 v > 0이면,
      1. sign < 0이면 false를 반환한다.
      2. sign을 1로 설정한다.
  3. abs(years) ≥ 232이면 false를 반환한다.
  4. abs(months) ≥ 232이면 false를 반환한다.
  5. abs(weeks) ≥ 232이면 false를 반환한다.
  6. normalizedSecondsdays × 86,400 + hours × 3600 + minutes × 60 + seconds + (𝔽(milliseconds)) × 10-3 + (𝔽(microseconds)) × 10-6 + (𝔽(nanoseconds)) × 10-9로 둔다.
  7. NOTE: 위 단계는 floating-point arithmetic을 사용해 직접 구현할 수 없다. 각각 10-3, 10-6 및 10-9를 곱하는 것은 milliseconds, microseconds 또는 nanoseconds가 unsafe integer일 때 부정확할 수 있다. 이 곱셈은 충분한 quotient bit를 가진 std::remquo() 구현을 사용하여 C++로 구현할 수 있다. 곱셈이 10의 거듭제곱에 의한 것이므로 string 조작도 정확한 결과를 제공한다.
  8. abs(normalizedSeconds) ≥ 253이면 false를 반환한다.
  9. true를 반환한다.

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

The abstract operation GetDurationUnitOptions takes arguments unit (String), options (Object), baseStyle (String), stylesList (String의 List), digitalBase (String), prevStyle (String), and twoDigitHours (Boolean) and returns Duration Unit Options Record를 포함하는 정상 완료 또는 throw 완료. 주어진 임의의 unit에 대해 Object에서 관련 options를 추출하고 이를 Record로 반환한다. It performs the following steps when called:

  1. style을 ? GetOption(options, unit, string, stylesList, undefined)로 둔다.
  2. displayDefault"always"로 둔다.
  3. styleundefined이면,
    1. baseStyle"digital"이면,
      1. styledigitalBase로 설정한다.
      2. unit"hours", "minutes" 또는 "seconds" 중 하나가 아니면 displayDefault"auto"로 설정한다.
    2. 그렇지 않고 prevStyle"fractional", "numeric" 또는 "2-digit" 중 하나이면,
      1. style"numeric"으로 설정한다.
      2. unit"minutes" 또는 "seconds"가 아니면 displayDefault"auto"로 설정한다.
    3. 그렇지 않으면,
      1. stylebaseStyle로 설정한다.
      2. displayDefault"auto"로 설정한다.
  4. style"numeric"이고 IsFractionalSecondUnitName(unit)이 true이면,
    1. style"fractional"로 설정한다.
    2. displayDefault"auto"로 설정한다.
  5. displayFieldunit"Display"의 문자열 연결로 둔다.
  6. display를 ? GetOption(options, displayField, string, « "auto", "always" », displayDefault)로 둔다.
  7. ValidateDurationUnitStyle(unit, style, display, prevStyle)를 수행한다.
  8. unit"hours"이고 twoDigitHourstrue이면 style"2-digit"으로 설정한다.
  9. unit"minutes" 또는 "seconds"이고 prevStyle"numeric" 또는 "2-digit"이면 style"2-digit"으로 설정한다.
  10. Duration Unit Options Record { [[Style]]: style, [[Display]]: display }를 반환한다.

13.5.6.1 Duration Unit Options Record

Duration Unit Options RecordTable 23에 정의된 필드를 가진다.

Table 23: Duration Unit Options Record
필드 이름 값 유형
[[Style]] Table 20의 Styles 열에서 온 String
[[Display]] "auto" 또는 "always"

13.5.6.2 ValidateDurationUnitStyle ( unit, style, display, prevStyle )

The abstract operation ValidateDurationUnitStyle takes arguments unit (String), style (String), display (String), and prevStyle (String) and returns unused를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. display"always"이고 style"fractional"이면 RangeError 예외를 던진다.
  2. prevStyle"fractional"이고 style"fractional"이 아니면 RangeError 예외를 던진다.
  3. prevStyle"numeric" 또는 "2-digit"이고 style"fractional", "numeric" 또는 "2-digit" 중 하나가 아니면 RangeError 예외를 던진다.
  4. unused를 반환한다.
Note
unit은 앞의 알고리즘에서 참조되지 않지만, 구현은 던져진 예외의 메시지를 구성할 때 이를 사용하는 것이 권장된다.

13.5.7 ComputeFractionalDigits ( durationFormat, duration )

The abstract operation ComputeFractionalDigits takes arguments durationFormat (DurationFormat Object) and duration (Duration Record) and returns 수학 값. durationFormat에서 "fractional" style을 사용하는 모든 unit 값의 합을, "fractional" style을 사용하지 않는 durationFormat의 가장 작은 unit의 fraction으로 표현하여 계산한다. It performs the following steps when called:

  1. result를 0으로 둔다.
  2. exponent를 3으로 둔다.
  3. Table 24의 각 행에 대해, 헤더 행을 제외하고 표 순서대로, 다음을 수행한다.
    1. unitOptions를 현재 행의 Internal Slot 값이 이름인 durationFormat의 내부 슬롯 값으로 둔다.
    2. unitOptions.[[Style]]"fractional"이면,
      1. unit을 현재 행의 Unit 값으로 둔다.
      2. Assert: IsFractionalSecondUnitName(unit)은 true이다.
      3. value를 현재 행의 Value Field 값이 이름인 duration의 필드 값으로 둔다.
      4. resultresult + (value / 10exponent)로 설정한다.
      5. exponentexponent + 3으로 설정한다.
  4. result를 반환한다.

13.5.8 NextUnitFractional ( durationFormat, unit )

The abstract operation NextUnitFractional takes arguments durationFormat (DurationFormat Object) and unit (String) and returns Boolean. 다음으로 작은 unit이 "fractional" style을 사용하면 true를 반환한다. It performs the following steps when called:

  1. unit"seconds"이고 durationFormat.[[MillisecondsOptions]].[[Style]]"fractional"이면 true를 반환한다.
  2. unit"milliseconds"이고 durationFormat.[[MicrosecondsOptions]].[[Style]]"fractional"이면 true를 반환한다.
  3. unit"microseconds"이고 durationFormat.[[NanosecondsOptions]].[[Style]]"fractional"이면 true를 반환한다.
  4. false를 반환한다.

13.5.9 FormatNumericHours ( durationFormat, hoursValue, signDisplayed )

The abstract operation FormatNumericHours takes arguments durationFormat (DurationFormat 객체), hoursValue (정수), and signDisplayed (Boolean) and returns RecordList. hoursValue는 hours의 수를 나타내는 정수이다. durationFormat의 유효 locale 및 형식화 options에 따라 hoursValue에 대한 부분을 생성한다. It performs the following steps when called:

  1. result를 새 빈 List로 둔다.
  2. hoursStyledurationFormat.[[HoursOptions]].[[Style]]로 둔다.
  3. Assert: hoursStyle"numeric"이거나 hoursStyle"2-digit"이다.
  4. nfOptionsOrdinaryObjectCreate(null)로 둔다.
  5. numberingSystemdurationFormat.[[NumberingSystem]]으로 둔다.
  6. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", numberingSystem)를 수행한다.
  7. hoursStyle"2-digit"이면,
    1. CreateDataPropertyOrThrow(nfOptions, "minimumIntegerDigits", 2𝔽)를 수행한다.
  8. signDisplayedfalse이면,
    1. CreateDataPropertyOrThrow(nfOptions, "signDisplay", "never")를 수행한다.
  9. CreateDataPropertyOrThrow(nfOptions, "useGrouping", false)를 수행한다.
  10. nf를 ! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOptions »)로 둔다.
  11. hoursPartsPartitionNumberPattern(nf, hoursValue)로 둔다.
  12. hoursParts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
    1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: "hour" }를 result에 append한다.
  13. result를 반환한다.

13.5.10 FormatNumericMinutes ( durationFormat, minutesValue, hoursDisplayed, signDisplayed )

The abstract operation FormatNumericMinutes takes arguments durationFormat (DurationFormat Object), minutesValue (정수), hoursDisplayed (Boolean), and signDisplayed (Boolean) and returns RecordList. minutesValue는 minutes의 수를 나타내는 정수이다. durationFormat의 유효 locale 및 형식화 options에 따라 minutesValue에 대한 부분을 생성한다. It performs the following steps when called:

  1. result를 새 빈 List로 둔다.
  2. hoursDisplayedtrue이면,
    1. separatordurationFormat.[[HourMinuteSeparator]]로 둔다.
    2. Record { [[Type]]: "literal", [[Value]]: separator, [[Unit]]: empty }를 result에 append한다.
  3. minutesStyledurationFormat.[[MinutesOptions]].[[Style]]로 둔다.
  4. Assert: minutesStyle"numeric"이거나 minutesStyle"2-digit"이다.
  5. nfOptionsOrdinaryObjectCreate(null)로 둔다.
  6. numberingSystemdurationFormat.[[NumberingSystem]]으로 둔다.
  7. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", numberingSystem)를 수행한다.
  8. minutesStyle"2-digit"이면,
    1. CreateDataPropertyOrThrow(nfOptions, "minimumIntegerDigits", 2𝔽)를 수행한다.
  9. signDisplayedfalse이면,
    1. CreateDataPropertyOrThrow(nfOptions, "signDisplay", "never")를 수행한다.
  10. CreateDataPropertyOrThrow(nfOptions, "useGrouping", false)를 수행한다.
  11. nf를 ! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOptions »)로 둔다.
  12. minutesPartsPartitionNumberPattern(nf, minutesValue)로 둔다.
  13. minutesParts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
    1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: "minute" }를 result에 append한다.
  14. result를 반환한다.

13.5.11 FormatNumericSeconds ( durationFormat, secondsValue, minutesDisplayed, signDisplayed )

The abstract operation FormatNumericSeconds takes arguments durationFormat (DurationFormat Object), secondsValue (수학 값), minutesDisplayed (Boolean), and signDisplayed (Boolean) and returns RecordList. secondsValue는 seconds의 수를 나타내는 수학 값이다. durationFormat의 유효 locale 및 형식화 options에 따라 secondsValue에 대한 부분을 생성한다. It performs the following steps when called:

  1. result를 새 빈 List로 둔다.
  2. minutesDisplayedtrue이면,
    1. separatordurationFormat.[[MinuteSecondSeparator]]로 둔다.
    2. Record { [[Type]]: "literal", [[Value]]: separator, [[Unit]]: empty }를 result에 append한다.
  3. secondsStyledurationFormat.[[SecondsOptions]].[[Style]]로 둔다.
  4. Assert: secondsStyle"numeric"이거나 secondsStyle"2-digit"이다.
  5. nfOptionsOrdinaryObjectCreate(null)로 둔다.
  6. numberingSystemdurationFormat.[[NumberingSystem]]으로 둔다.
  7. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", numberingSystem)를 수행한다.
  8. secondsStyle"2-digit"이면,
    1. CreateDataPropertyOrThrow(nfOptions, "minimumIntegerDigits", 2𝔽)를 수행한다.
  9. signDisplayedfalse이면,
    1. CreateDataPropertyOrThrow(nfOptions, "signDisplay", "never")를 수행한다.
  10. CreateDataPropertyOrThrow(nfOptions, "useGrouping", false)를 수행한다.
  11. fractionDigitsdurationFormat.[[FractionalDigits]]로 둔다.
  12. fractionDigitsundefined이면,
    1. CreateDataPropertyOrThrow(nfOptions, "maximumFractionDigits", 9𝔽)를 수행한다.
    2. CreateDataPropertyOrThrow(nfOptions, "minimumFractionDigits", +0𝔽)를 수행한다.
  13. 그렇지 않으면,
    1. CreateDataPropertyOrThrow(nfOptions, "maximumFractionDigits", fractionDigits)를 수행한다.
    2. CreateDataPropertyOrThrow(nfOptions, "minimumFractionDigits", fractionDigits)를 수행한다.
  14. CreateDataPropertyOrThrow(nfOptions, "roundingMode", "trunc")를 수행한다.
  15. nf를 ! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOptions »)로 둔다.
  16. secondsPartsPartitionNumberPattern(nf, secondsValue)로 둔다.
  17. secondsParts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
    1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: "second" }를 result에 append한다.
  18. result를 반환한다.

13.5.12 FormatNumericUnits ( durationFormat, duration, firstNumericUnit, signDisplayed )

The abstract operation FormatNumericUnits takes arguments durationFormat (DurationFormat Object), duration (Duration Record), firstNumericUnit (String), and signDisplayed (Boolean) and returns RecordList. durationFormat의 유효 locale 및 형식화 options에 따라 "numeric" 또는 "2-digit" style을 사용하는 duration의 요소를 나타내는 부분을 생성한다. It performs the following steps when called:

  1. Assert: firstNumericUnit"hours", "minutes" 또는 "seconds"이다.
  2. numericPartsList를 새 빈 List로 둔다.
  3. hoursValueduration.[[Hours]]로 둔다.
  4. hoursDisplaydurationFormat.[[HoursOptions]].[[Display]]로 둔다.
  5. minutesValueduration.[[Minutes]]로 둔다.
  6. minutesDisplaydurationFormat.[[MinutesOptions]].[[Display]]로 둔다.
  7. secondsValueduration.[[Seconds]]로 둔다.
  8. duration.[[Milliseconds]]가 0이 아니거나 duration.[[Microseconds]]가 0이 아니거나 duration.[[Nanoseconds]]가 0이 아니면,
    1. secondsValuesecondsValue + ComputeFractionalDigits(durationFormat, duration)로 설정한다.
  9. secondsDisplaydurationFormat.[[SecondsOptions]].[[Display]]로 둔다.
  10. hoursFormattedfalse로 둔다.
  11. firstNumericUnit"hours"이면,
    1. hoursValue가 0이 아니거나 hoursDisplay"always"이면,
      1. hoursFormattedtrue로 설정한다.
  12. secondsValue가 0이 아니거나 secondsDisplay"always"이면,
    1. secondsFormattedtrue로 둔다.
  13. 그렇지 않으면,
    1. secondsFormattedfalse로 둔다.
  14. minutesFormattedfalse로 둔다.
  15. firstNumericUnit"hours" 또는 firstNumericUnit"minutes"이면,
    1. hoursFormattedtrue이고 secondsFormattedtrue이면,
      1. minutesFormattedtrue로 설정한다.
    2. 그렇지 않고 minutesValue가 0이 아니거나 minutesDisplay"always"이면,
      1. minutesFormattedtrue로 설정한다.
  16. hoursFormattedtrue이면,
    1. signDisplayedtrue이면,
      1. hoursValue가 0이고 DurationSign(duration)이 -1이면,
        1. hoursValuenegative-zero로 설정한다.
    2. hoursPartsFormatNumericHours(durationFormat, hoursValue, signDisplayed)로 둔다.
    3. numericPartsListnumericPartsListhoursPartslist-concatenation으로 설정한다.
    4. signDisplayedfalse로 설정한다.
  17. minutesFormattedtrue이면,
    1. signDisplayedtrue이면,
      1. minutesValue가 0이고 DurationSign(duration)이 -1이면,
        1. minutesValuenegative-zero로 설정한다.
    2. minutesPartsFormatNumericMinutes(durationFormat, minutesValue, hoursFormatted, signDisplayed)로 둔다.
    3. numericPartsListnumericPartsListminutesPartslist-concatenation으로 설정한다.
    4. signDisplayedfalse로 설정한다.
  18. secondsFormattedtrue이면,
    1. secondsPartsFormatNumericSeconds(durationFormat, secondsValue, minutesFormatted, signDisplayed)로 둔다.
    2. numericPartsListnumericPartsListsecondsPartslist-concatenation으로 설정한다.
  19. numericPartsList를 반환한다.

13.5.13 IsFractionalSecondUnitName ( unit )

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

  1. unit"milliseconds", "microseconds" 또는 "nanoseconds" 중 하나이면 true를 반환한다.
  2. false를 반환한다.

13.5.14 ListFormatParts ( durationFormat, partitionedPartsList )

The abstract operation ListFormatParts takes arguments durationFormat (DurationFormat Object) and partitionedPartsList (RecordList들의 List) and returns List. durationFormat의 유효 locale 및 형식화 options에 따라 partitionedPartsList 안의 List에 있는 부분에 대응하는 List를 생성한다. It performs the following steps when called:

  1. lfOptionsOrdinaryObjectCreate(null)로 둔다.
  2. CreateDataPropertyOrThrow(lfOptions, "type", "unit")를 수행한다.
  3. listStyledurationFormat.[[Style]]로 둔다.
  4. listStyle"digital"이면,
    1. listStyle"short"로 설정한다.
  5. CreateDataPropertyOrThrow(lfOptions, "style", listStyle)를 수행한다.
  6. lf를 ! Construct(%Intl.ListFormat%, « durationFormat.[[Locale]], lfOptions »)로 둔다.
  7. strings를 새 빈 List로 둔다.
  8. partitionedPartsList의 각 요소 parts에 대해, 다음을 수행한다.
    1. string을 빈 String으로 둔다.
    2. parts의 각 Record { [[Type]], [[Value]], [[Unit]] } part에 대해, 다음을 수행한다.
      1. stringstringpart.[[Value]]의 문자열 연결로 설정한다.
    3. stringstrings에 추가한다.
  9. formattedPartsListCreatePartsFromList(lf, strings)로 둔다.
  10. partitionedPartsIndex를 0으로 둔다.
  11. partitionedLengthpartitionedPartsList의 요소 수로 둔다.
  12. flattenedPartsList를 새 빈 List로 둔다.
  13. formattedPartsList의 각 Record { [[Type]], [[Value]] } listPart에 대해, 다음을 수행한다.
    1. listPart.[[Type]]"element"이면,
      1. 단언: partitionedPartsIndex < partitionedLength.
      2. partspartitionedPartsList[partitionedPartsIndex]로 둔다.
      3. parts의 각 Record { [[Type]], [[Value]], [[Unit]] } part에 대해, 다음을 수행한다.
        1. partflattenedPartsList에 추가한다.
      4. partitionedPartsIndexpartitionedPartsIndex + 1로 설정한다.
    2. 그렇지 않으면,
      1. 단언: listPart.[[Type]]"literal"이다.
      2. Record { [[Type]]: "literal", [[Value]]: listPart.[[Value]], [[Unit]]: empty }를 flattenedPartsList에 추가한다.
  14. flattenedPartsList를 반환한다.

13.5.15 PartitionDurationFormatPattern ( durationFormat, duration )

The abstract operation PartitionDurationFormatPattern takes arguments durationFormat (DurationFormat) and duration (Duration Record) and returns List. durationFormat의 유효 locale 및 형식화 options에 따라 duration에 대응하는 부분을 생성한다. It performs the following steps when called:

  1. result를 새 빈 List로 둔다.
  2. signDisplayedtrue로 둔다.
  3. numericUnitFoundfalse로 둔다.
  4. numericUnitFoundfalse인 동안, Table 24의 각 행에 대해, 헤더 행을 제외하고 표 순서대로 반복한다:
    1. value를 현재 행의 Value Field 값이 이름인 duration의 필드 값으로 둔다.
    2. unitOptions를 현재 행의 Internal Slot 값이 이름인 durationFormat의 내부 슬롯 값으로 둔다.
    3. styleunitOptions.[[Style]]로 둔다.
    4. displayunitOptions.[[Display]]로 둔다.
    5. unit을 현재 행의 Unit 값으로 둔다.
    6. numberFormatUnit을 현재 행의 NumberFormat Unit 값으로 둔다.
    7. style"numeric" 또는 "2-digit"이면,
      1. numericPartsListFormatNumericUnits(durationFormat, duration, unit, signDisplayed)로 둔다.
      2. numericPartsList가 비어 있지 않으면 numericPartsListresult에 append한다.
      3. numericUnitFoundtrue로 설정한다.
    8. 그렇지 않으면,
      1. nfOptionsOrdinaryObjectCreate(null)로 둔다.
      2. NextUnitFractional(durationFormat, unit)이 true이면,
        1. valuevalue + ComputeFractionalDigits(durationFormat, duration)로 설정한다.
        2. fractionDigitsdurationFormat.[[FractionalDigits]]로 둔다.
        3. fractionDigitsundefined이면,
          1. CreateDataPropertyOrThrow(nfOptions, "maximumFractionDigits", 9𝔽)를 수행한다.
          2. CreateDataPropertyOrThrow(nfOptions, "minimumFractionDigits", +0𝔽)를 수행한다.
        4. 그렇지 않으면,
          1. CreateDataPropertyOrThrow(nfOptions, "maximumFractionDigits", fractionDigits)를 수행한다.
          2. CreateDataPropertyOrThrow(nfOptions, "minimumFractionDigits", fractionDigits)를 수행한다.
        5. CreateDataPropertyOrThrow(nfOptions, "roundingMode", "trunc")를 수행한다.
        6. numericUnitFoundtrue로 설정한다.
      3. display"always"이거나 value가 0이 아니면,
        1. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", durationFormat.[[NumberingSystem]])를 수행한다.
        2. signDisplayedtrue이면,
          1. signDisplayedfalse로 설정한다.
          2. value가 0이고 DurationSign(duration)이 -1이면 valuenegative-zero로 설정한다.
        3. 그렇지 않으면,
          1. CreateDataPropertyOrThrow(nfOptions, "signDisplay", "never")를 수행한다.
        4. CreateDataPropertyOrThrow(nfOptions, "style", "unit")를 수행한다.
        5. CreateDataPropertyOrThrow(nfOptions, "unit", numberFormatUnit)를 수행한다.
        6. CreateDataPropertyOrThrow(nfOptions, "unitDisplay", style)를 수행한다.
        7. nf를 ! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOptions »)로 둔다.
        8. partsPartitionNumberPattern(nf, value)로 둔다.
        9. list를 새 빈 List로 둔다.
        10. parts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
          1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: numberFormatUnit }를 list에 append한다.
        11. listresult에 append한다.
  5. ListFormatParts(durationFormat, result)를 반환한다.
Table 24: PartitionDurationFormatPattern과 관련된 DurationFormat 인스턴스 내부 슬롯 및 속성
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 함수가 선택적 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. NewTarget이 undefined이면 TypeError 예외를 던진다.
  2. listFormat을 ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.ListFormat.prototype%", « [[InitializedListFormat]], [[Locale]], [[Type]], [[Style]], [[Templates]] »)로 둔다.
  3. optionsResolution을 ? ResolveOptions(%Intl.ListFormat%, %Intl.ListFormat%.[[LocaleData]], locales, options)로 둔다.
  4. optionsoptionsResolution.[[Options]]로 설정한다.
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]]로 둔다.
  6. listFormat.[[Locale]]resolvedLocale.[[Locale]]로 설정한다.
  7. type을 ? GetOption(options, "type", string, « "conjunction", "disjunction", "unit" », "conjunction")로 둔다.
  8. listFormat.[[Type]]type으로 설정한다.
  9. style을 ? GetOption(options, "style", string, « "long", "short", "narrow" », "long")로 둔다.
  10. listFormat.[[Style]]style로 설정한다.
  11. resolvedLocaleDataresolvedLocale.[[LocaleData]]로 둔다.
  12. dataLocaleTypesresolvedLocaleData.[[<type>]]로 둔다.
  13. listFormat.[[Templates]]dataLocaleTypes.[[<style>]]로 설정한다.
  14. listFormat을 반환한다.

14.2 Intl.ListFormat 생성자의 속성

Intl.ListFormat 생성자는:

  • 값이 %Function.prototype%[[Prototype]] 내부 슬롯을 가진다.
  • 다음 속성을 가진다:

14.2.1 Intl.ListFormat.prototype

Intl.ListFormat.prototype의 값은 %Intl.ListFormat.prototype%이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } 속성을 가진다.

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

supportedLocalesOf 메서드가 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. availableLocales%Intl.ListFormat%.[[AvailableLocales]]로 둔다.
  2. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  3. FilterLocales(availableLocales, requestedLocales, options)를 반환한다.

14.2.3 내부 슬롯

[[AvailableLocales]] 내부 슬롯의 값은 9.1에 설명된 제약 안에서 구현 정의이다.

[[RelevantExtensionKeys]] 내부 슬롯의 값은 « »이다.

[[ResolutionOptionDescriptors]] 내부 슬롯의 값은 « »이다.

Note 1
Intl.ListFormat에는 관련 extension key가 없다.

[[LocaleData]] 내부 슬롯의 값은 9.1에 설명된 제약 및 다음 추가 제약 안에서, %Intl.ListFormat%.[[AvailableLocales]]의 각 locale 값 locale에 대해 구현 정의이다:

  • [[LocaleData]].[[<locale>]]는 세 필드 [[conjunction]], [[disjunction]][[unit]]을 가진 Record이다. 이들 각각은 세 formatting style의 이름인 [[long]], [[short]][[narrow]] 필드를 가져야 하는 Record이다.
  • 그 각 필드는 ListFormat template set으로 간주되며, [[Pair]], [[Start]], [[Middle]][[End]]라는 이름의 필드를 가진 RecordList여야 한다. 그 각 필드는 LDML List Format Rules에 명시된 template string이어야 한다. 각 template string은 부분 문자열 "{0}""{1}"을 정확히 한 번씩 포함해야 한다. 부분 문자열 "{0}"은 부분 문자열 "{1}"보다 앞에 나타나는 것이 좋다.
Note 2
구현은 Common Locale Data Repository(https://cldr.unicode.org/에서 이용 가능)가 제공하는 locale 데이터를 사용하는 것이 권장된다. LDML의 listPattern에서 conjunction은 "standard"에 대응하고, disjunction은 "or"에 대응하며, unit은 "unit"에 대응한다.
Note 3
list type 중에서 conjunction은 "and" 기반 list(예: "A, B, and C")를 의미하고, disjunction은 "or" 기반 list(예: "A, B, or C")를 의미하며, unit은 unit을 가진 값의 list(예: "5 pounds, 12 ounces")를 의미한다.

14.3 Intl.ListFormat Prototype 객체의 속성

Intl.ListFormat prototype 객체는:

  • %Intl.ListFormat.prototype%이다.
  • ordinary 객체이다.
  • Intl.ListFormat 인스턴스가 아니며 [[InitializedListFormat]] 내부 슬롯 또는 Intl.ListFormat 인스턴스 객체의 다른 내부 슬롯을 가지지 않는다.
  • 값이 %Object.prototype%[[Prototype]] 내부 슬롯을 가진다.

14.3.1 Intl.ListFormat.prototype.constructor

Intl.ListFormat.prototype.constructor의 초기값은 %Intl.ListFormat%이다.

14.3.2 Intl.ListFormat.prototype.resolvedOptions ( )

이 함수는 객체 초기화 중 계산된 locale 및 options에 대한 접근을 제공한다.

  1. lfthis 값으로 둔다.
  2. RequireInternalSlot(lf, [[InitializedListFormat]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  4. Table 25의 각 행에 대해, 헤더 행을 제외하고 표 순서대로, 다음을 수행한다.
    1. propertyKey를 현재 행의 Property 값으로 둔다.
    2. value를 현재 행의 Internal Slot 값이 이름인 lf의 내부 슬롯 값으로 둔다.
    3. Assert: valueundefined가 아니다.
    4. CreateDataPropertyOrThrow(options, propertyKey, value)를 수행한다.
  5. options를 반환한다.
Table 25: ListFormat 인스턴스의 Resolved Options
Internal Slot Property
[[Locale]] "locale"
[[Type]] "type"
[[Style]] "style"

14.3.3 Intl.ListFormat.prototype.format ( list )

format 메서드가 인수 list와 함께 호출되면 다음 단계가 수행된다:

  1. lfthis 값으로 둔다.
  2. RequireInternalSlot(lf, [[InitializedListFormat]])를 수행한다.
  3. stringList를 ? StringListFromIterable(list)로 둔다.
  4. FormatList(lf, stringList)를 반환한다.

14.3.4 Intl.ListFormat.prototype.formatToParts ( list )

formatToParts 메서드가 인수 list와 함께 호출되면 다음 단계가 수행된다:

  1. lfthis 값으로 둔다.
  2. RequireInternalSlot(lf, [[InitializedListFormat]])를 수행한다.
  3. stringList를 ? StringListFromIterable(list)로 둔다.
  4. FormatListToParts(lf, stringList)를 반환한다.

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

%Symbol.toStringTag% 속성의 초기값은 String 값 "Intl.ListFormat"이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } 속성을 가진다.

14.4 Intl.ListFormat 인스턴스의 속성

Intl.ListFormat 인스턴스는 %Intl.ListFormat.prototype%에서 속성을 상속한다.

Intl.ListFormat 인스턴스는 [[InitializedListFormat]] 내부 슬롯을 가진다.

Intl.ListFormat 인스턴스는 또한 Intl.ListFormat 생성자에 의해 계산되는 여러 내부 슬롯을 가진다:

  • [[Locale]]은 list format style에서 사용되는 localization의 locale 언어 태그를 가진 String 값이다.
  • [[Type]]은 사용되는 type의 list를 식별하는 String 값 "conjunction", "disjunction" 또는 "unit" 중 하나이다.
  • [[Style]]은 사용되는 list formatting style을 식별하는 String 값 "long", "short" 또는 "narrow" 중 하나이다.
  • [[Templates]]ListFormat template set이다.

14.5 ListFormat 객체를 위한 추상 연산

14.5.1 DeconstructPattern ( pattern, placeables )

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

pattern string을 부분들의 List로 분해한다.

placeables는 key가 pattern string에서 사용되는 placeables token이고 값은 결과 List에서 token 부분을 나타내는 데 사용될 parts Record(PartitionPattern에서와 같은)인 Record이다. 예:

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

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

It performs the following steps when called:

  1. patternPartsPartitionPattern(pattern)으로 둔다.
  2. result를 새 빈 List로 둔다.
  3. patternParts의 각 Record { [[Type]], [[Value]] } patternPart에 대해, 다음을 수행한다.
    1. partTypepatternPart.[[Type]]으로 둔다.
    2. partType"literal"이면,
      1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }를 result에 append한다.
    3. 그렇지 않으면,
      1. Assert: placeables는 [[<partType>]] 필드를 가진다.
      2. substitutionplaceables.[[<partType>]]로 둔다.
      3. substitutionList이면,
        1. substitution의 각 요소 part에 대해, 다음을 수행한다.
          1. partresult에 append한다.
      4. 그렇지 않으면,
        1. substitutionresult에 append한다.
  4. result를 반환한다.

14.5.2 CreatePartsFromList ( listFormat, list )

The abstract operation CreatePartsFromList takes arguments listFormat (Intl.ListFormat) and list (String의 List) and returns [[Type]]("element" 또는 "literal") 및 [[Value]](String) 필드를 가진 RecordList. listFormat의 유효 locale 및 formatting options에 따라 대응하는 parts의 List를 생성한다. It performs the following steps when called:

  1. sizelist의 요소 수로 둔다.
  2. size가 0이면,
    1. 새 빈 List를 반환한다.
  3. size가 2이면,
    1. nlistFormat.[[Locale]], list[0], 그리고 list[1]에 기반한 listFormat.[[Templates]] 내의 인덱스로 둔다.
    2. patternlistFormat.[[Templates]][n].[[Pair]]로 둔다.
    3. firstRecord { [[Type]]: "element", [[Value]]: list[0] }로 둔다.
    4. secondRecord { [[Type]]: "element", [[Value]]: list[1] }로 둔다.
    5. placeablesRecord { [[0]]: first, [[1]]: second }로 둔다.
    6. DeconstructPattern(pattern, placeables)를 반환한다.
  4. lastRecord { [[Type]]: "element", [[Value]]: list[size - 1] }로 둔다.
  5. parts를 « last »로 둔다.
  6. isize - 2로 둔다.
  7. i ≥ 0인 동안 반복한다.
    1. headRecord { [[Type]]: "element", [[Value]]: list[i] }로 둔다.
    2. nlistFormat.[[Locale]], head, 그리고 parts에 기반한 listFormat.[[Templates]] 내의 구현 정의 인덱스로 둔다.
    3. i가 0이면,
      1. patternlistFormat.[[Templates]][n].[[Start]]로 둔다.
    4. 그렇지 않고 isize - 2보다 작으면,
      1. patternlistFormat.[[Templates]][n].[[Middle]]로 둔다.
    5. 그렇지 않으면,
      1. patternlistFormat.[[Templates]][n].[[End]]로 둔다.
    6. placeablesRecord { [[0]]: head, [[1]]: parts }로 둔다.
    7. partsDeconstructPattern(pattern, placeables)로 설정한다.
    8. ii - 1로 설정한다.
  8. parts를 반환한다.
Note
여러 template 중에서 선택하는 index n은 스페인어에서처럼 뒤따르는 단어에 따라 "y" 또는 "e"가 선택될 수 있는 경우와 같이 conjunction이 context에 의존할 수 있게 한다.

14.5.3 FormatList ( listFormat, list )

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

  1. partsCreatePartsFromList(listFormat, list)로 둔다.
  2. result를 빈 String으로 둔다.
  3. parts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
    1. resultresultpart.[[Value]]의 문자열 연결로 설정한다.
  4. result를 반환한다.

14.5.4 FormatListToParts ( listFormat, list )

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

  1. partsCreatePartsFromList(listFormat, list)로 둔다.
  2. result를 ! ArrayCreate(0)으로 둔다.
  3. n을 0으로 둔다.
  4. parts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
    1. objOrdinaryObjectCreate(%Object.prototype%)로 둔다.
    2. CreateDataPropertyOrThrow(obj, "type", part.[[Type]])를 수행한다.
    3. CreateDataPropertyOrThrow(obj, "value", part.[[Value]])를 수행한다.
    4. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), obj)를 수행한다.
    5. nn + 1로 설정한다.
  5. result를 반환한다.

14.5.5 StringListFromIterable ( iterable )

The abstract operation StringListFromIterable takes argument iterable (ECMAScript 언어 값) and returns String의 List를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. iterableundefined이면,
    1. 새 빈 List를 반환한다.
  2. iteratorRecord를 ? GetIterator(iterable, sync)로 둔다.
  3. list를 새 빈 List로 둔다.
  4. 반복한다.
    1. next를 ? IteratorStepValue(iteratorRecord)로 둔다.
    2. nextdone이면,
      1. list를 반환한다.
    3. next가 String이 아니면,
      1. errorThrowCompletion(새로 생성된 TypeError 객체)로 둔다.
      2. IteratorClose(iteratorRecord, error)를 반환한다.
    4. nextlist에 append한다.
Note

이 알고리즘은 String이 아닌 값을 마주치면 예외를 발생시킨다. 임의 값에 대해 명확한 locale-aware coercion이 없기 때문이다.

15 Locale 객체

15.1 Intl.Locale 생성자

Intl.Locale 생성자는:

  • %Intl.Locale%이다.
  • Intl 객체"Locale" 속성의 초기값이다.

15.1.1 Intl.Locale ( tag [ , options ] )

Intl.Locale 함수가 인수 tag 및 선택적 인수 options와 함께 호출되면 다음 단계가 수행된다:

#### ECMARKDOWN PARSE FAILED ####
        1. NewTarget이 *undefined*이면, *TypeError* 예외를 던진다.
        1. _localeExtensionKeys_를 %Intl.Locale%.[[LocaleExtensionKeys]]로 둔다.
        1. _internalSlotsList_를 « [[InitializedLocale]], [[Locale]], [[Calendar]], [[Collation]], [[FirstDayOfWeek]], [[HourCycle]], [[NumberingSystem]] »로 둔다.
        1. _localeExtensionKeys_가 *"kf"*를 포함하면,
          1. [[CaseFirst]]를 _internalSlotsList_에 추가한다.
        1. _localeExtensionKeys_가 *"kn"*을 포함하면,
          1. [[Numeric]]을 _internalSlotsList_에 추가한다.
        1. _locale_을 ? OrdinaryCreateFromConstructor(NewTarget, *"%Intl.Locale.prototype%"*, _internalSlotsList_)로 둔다.
        1. _tag_가 String도 아니고 Object도 아니면, *TypeError* 예외를 던진다.
        1. _tag_가 Object이고 _tag_가 [[InitializedLocale]] 내부 슬롯을 가지면,
          1. _tag_를 _tag_.[[Locale]]로 설정한다.
        1. 그렇지 않으면,
          1. _tag_를 ? ToString(_tag_)으로 설정한다.
        1. _options_를 ? CoerceOptionsToObject(_options_)로 설정한다.
        1. IsWellFormedLanguageTag(_tag_)가 *false*이면, *RangeError* 예외를 던진다.
        1. 참고: 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 locale 비종단 기호와 일치할 수 없으면, *RangeError* 예외를 던진다.
        1. _opt_.[[ca]]를 _calendar_로 설정한다.
        1. _collation_을 ? GetOption(_options_, *"collation"*, ~string~, ~empty~, *undefined*)로 둔다.
        1. _collation_이 *undefined*가 아니면,
          1. _collation_이 type Unicode locale 비종단 기호와 일치할 수 없으면, *RangeError* 예외를 던진다.
        1. _opt_.[[co]]를 _collation_으로 설정한다.
        1. _fw_를 ? GetOption(_options_, *"firstDayOfWeek"*, ~string~, ~empty~, *undefined*)로 둔다.
        1. _fw_가 *undefined*가 아니면,
          1. _fw_를 WeekdayToUValue(_fw_)로 설정한다.
          1. _fw_가 type Unicode locale 비종단 기호와 일치할 수 없으면, *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 locale 비종단 기호와 일치할 수 없으면, *RangeError* 예외를 던진다.
        1. _opt_.[[nu]]를 _numberingSystem_으로 설정한다.
        1. _localeRecord_를 MakeLocaleRecord(_tag_, _opt_, _localeExtensionKeys_)로 둔다.
        1. _locale_.[[Locale]]을 _localeRecord_.[[locale]]로 설정한다.
        1. _locale_.[[Calendar]]를 _localeRecord_.[[ca]]로 설정한다.
        1. _locale_.[[Collation]]을 _localeRecord_.[[co]]로 설정한다.
        1. _locale_.[[FirstDayOfWeek]]를 _localeRecord_.[[fw]]로 설정한다.
        1. _locale_.[[HourCycle]]을 _localeRecord_.[[hc]]로 설정한다.
        1. _localeExtensionKeys_가 *"kf"*를 포함하면,
          1. _locale_.[[CaseFirst]]를 _localeRecord_.[[kf]]로 설정한다.
        1. _localeExtensionKeys_가 *"kn"*을 포함하면,
          1. _localeRecord_.[[kn]]이 *"true"* 또는 빈 String 중 하나이면,
            1. _locale_.[[Numeric]]을 *true*로 설정한다.
          1. 그렇지 않으면,
            1. _locale_.[[Numeric]]을 *false*로 설정한다.
        1. _locale_.[[NumberingSystem]]을 _localeRecord_.[[nu]]로 설정한다.
        1. _locale_을 반환한다.
      

15.1.2 UpdateLanguageId ( tag, options )

The abstract operation UpdateLanguageId takes arguments tag (well-formed language tag) and options (Object) and returns well-formed language tag를 포함하는 정상 완료 또는 throw 완료. tagunicode_language_id subtagoptions의 대응하는 속성에서 가져온 값으로 갱신하고, 이를 검증한 뒤 결과를 반환한다. It performs the following steps when called:

  1. baseNameGetLocaleBaseName(tag)으로 둔다.
  2. language를 ? GetOption(options, "language", string, empty, GetLocaleLanguage(baseName))로 둔다.
  3. languageunicode_language_subtag Unicode locale nonterminal에 의해 매칭될 수 없으면 RangeError 예외를 던진다.
  4. script를 ? GetOption(options, "script", string, empty, GetLocaleScript(baseName))로 둔다.
  5. scriptundefined가 아니면,
    1. scriptunicode_script_subtag Unicode locale nonterminal에 의해 매칭될 수 없으면 RangeError 예외를 던진다.
  6. region을 ? GetOption(options, "region", string, empty, GetLocaleRegion(baseName))로 둔다.
  7. regionundefined가 아니면,
    1. regionunicode_region_subtag Unicode locale nonterminal에 의해 매칭될 수 없으면 RangeError 예외를 던진다.
  8. variants를 ? GetOption(options, "variants", string, empty, GetLocaleVariants(baseName))로 둔다.
  9. variantsundefined가 아니면,
    1. variants가 빈 String이면 RangeError 예외를 던진다.
    2. lowerVariantsvariantsASCII-lowercase로 둔다.
    3. variantSubtagsStringSplitToList(lowerVariants, "-")로 둔다.
    4. variantSubtags의 각 요소 variant에 대해, 다음을 수행한다.
      1. variantunicode_variant_subtag Unicode locale nonterminal에 의해 매칭될 수 없으면 RangeError 예외를 던진다.
    5. variantSubtags가 중복 요소를 포함하면 RangeError 예외를 던진다.
  10. allExtensionsbaseName 뒤에 오는 tag의 접미사로 둔다.
  11. newTaglanguage로 둔다.
  12. scriptundefined가 아니면 newTagnewTag, "-"script의 문자열 연결로 설정한다.
  13. regionundefined가 아니면 newTagnewTag, "-"region의 문자열 연결로 설정한다.
  14. variantsundefined가 아니면 newTagnewTag, "-"variants의 문자열 연결로 설정한다.
  15. newTagnewTagallExtensions의 문자열 연결로 설정한다.
  16. newTag를 반환한다.

15.1.3 MakeLocaleRecord ( tag, options, localeExtensionKeys )

The abstract operation MakeLocaleRecord takes arguments tag (language tag), options (Record), and localeExtensionKeys (String의 List) and returns Record. localeExtensionKeys의 각 요소가 tagUnicode locale extension sequence에 있는 데이터로부터 대응하는 필드를 정의하되, options의 대응하는 필드에 의해 override되는 Record를 구성하여 반환한다. 또한 이 Record에는 그 필드들을 tag에 통합한 결과인 Unicode canonicalized locale identifier를 포함하는 [[locale]] 필드도 포함된다. It performs the following steps when called:

  1. tagUnicode locale extension sequencesubstring을 포함하면,
    1. extensiontag 안의 Unicode locale extension sequencesubstring으로 이루어진 String 값으로 둔다.
    2. componentsUnicodeExtensionComponents(extension)로 둔다.
    3. attributescomponents.[[Attributes]]로 둔다.
    4. keywordscomponents.[[Keywords]]로 둔다.
  2. 그렇지 않으면,
    1. attributes를 새 빈 List로 둔다.
    2. keywords를 새 빈 List로 둔다.
  3. result를 새 Record로 둔다.
  4. localeExtensionKeys의 각 요소 key에 대해, 다음을 수행한다.
    1. keywords[[Key]]key인 요소를 포함하면,
      1. entry[[Key]]keykeywords의 요소로 둔다.
      2. valueentry.[[Value]]로 둔다.
    2. 그렇지 않으면,
      1. entryempty로 둔다.
      2. valueundefined로 둔다.
    3. Assert: options는 [[<key>]] 필드를 가진다.
    4. overrideValueoptions.[[<key>]]로 둔다.
    5. overrideValueundefined가 아니면,
      1. valueCanonicalizeUValue(key, overrideValue)로 설정한다.
      2. entryempty가 아니면,
        1. entry.[[Value]]value로 설정한다.
      3. 그렇지 않으면,
        1. Record { [[Key]]: key, [[Value]]: value }를 keywords에 append한다.
    6. result.[[<key>]]를 value로 설정한다.
  5. localeUnicode locale extension sequence가 제거된 tag인 String 값으로 둔다.
  6. attributes가 비어 있지 않거나 keywords가 비어 있지 않으면,
    1. result.[[locale]]InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords)로 설정한다.
  7. 그렇지 않으면,
    1. result.[[locale]]CanonicalizeUnicodeLocaleId(locale)로 설정한다.
  8. result를 반환한다.

15.2 Intl.Locale 생성자의 속성

Intl.Locale 생성자는:

  • 값이 %Function.prototype%[[Prototype]] 내부 슬롯을 가진다.
  • 다음 속성을 가진다:

15.2.1 Intl.Locale.prototype

Intl.Locale.prototype의 값은 %Intl.Locale.prototype%이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } 속성을 가진다.

15.2.2 내부 슬롯

[[LocaleExtensionKeys]] 내부 슬롯의 값은 « "ca", "co", "fw", "hc", "nu" »의 모든 요소를 반드시 포함하고, %Intl.Collator%.[[RelevantExtensionKeys]]의 요소이기도 한 « "kf", "kn" »의 임의 요소를 추가로 포함해야 하며, 다른 요소를 포함해서는 안 되는 List이다.

15.3 Intl.Locale Prototype 객체의 속성

Intl.Locale prototype 객체는:

  • %Intl.Locale.prototype%이다.
  • ordinary 객체이다.
  • Intl.Locale 인스턴스가 아니며 [[InitializedLocale]] 내부 슬롯 또는 Intl.Locale 인스턴스 객체의 다른 내부 슬롯을 가지지 않는다.
  • 값이 %Object.prototype%[[Prototype]] 내부 슬롯을 가진다.

15.3.1 Intl.Locale.prototype.constructor

Intl.Locale.prototype.constructor의 초기값은 %Intl.Locale%이다.

15.3.2 get Intl.Locale.prototype.baseName

Intl.Locale.prototype.baseName은 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. GetLocaleBaseName(loc.[[Locale]])을 반환한다.

15.3.3 get Intl.Locale.prototype.calendar

Intl.Locale.prototype.calendar는 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. loc.[[Calendar]]를 반환한다.

15.3.4 get Intl.Locale.prototype.caseFirst

이 속성은 %Intl.Locale%.[[LocaleExtensionKeys]]"kf"를 포함하는 경우에만 존재한다.

Intl.Locale.prototype.caseFirst는 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. loc.[[CaseFirst]]를 반환한다.

15.3.5 get Intl.Locale.prototype.collation

Intl.Locale.prototype.collation은 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. loc.[[Collation]]을 반환한다.

15.3.6 get Intl.Locale.prototype.firstDayOfWeek

Intl.Locale.prototype.firstDayOfWeek는 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. loc.[[FirstDayOfWeek]]를 반환한다.

15.3.7 get Intl.Locale.prototype.hourCycle

Intl.Locale.prototype.hourCycle은 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. loc.[[HourCycle]]을 반환한다.

15.3.8 get Intl.Locale.prototype.language

Intl.Locale.prototype.language는 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. GetLocaleLanguage(loc.[[Locale]])를 반환한다.

15.3.9 Intl.Locale.prototype.maximize ( )

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. maximalloc.[[Locale]]에 적용된 Add Likely Subtags 알고리즘의 결과로 둔다. error가 signal되면 maximalloc.[[Locale]]로 설정한다.
  4. Construct(%Intl.Locale%, « maximal »)를 반환한다.

15.3.10 Intl.Locale.prototype.minimize ( )

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. minimalloc.[[Locale]]에 적용된 Remove Likely Subtags 알고리즘의 결과로 둔다. error가 signal되면 minimalloc.[[Locale]]로 설정한다.
  4. Construct(%Intl.Locale%, « minimal »)를 반환한다.

15.3.11 get Intl.Locale.prototype.numberingSystem

Intl.Locale.prototype.numberingSystem은 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. loc.[[NumberingSystem]]을 반환한다.

15.3.12 get Intl.Locale.prototype.numeric

이 속성은 %Intl.Locale%.[[LocaleExtensionKeys]]"kn"을 포함하는 경우에만 존재한다.

Intl.Locale.prototype.numeric은 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. loc.[[Numeric]]을 반환한다.

15.3.13 get Intl.Locale.prototype.region

Intl.Locale.prototype.region은 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. GetLocaleRegion(loc.[[Locale]])을 반환한다.

15.3.14 get Intl.Locale.prototype.script

Intl.Locale.prototype.script는 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. GetLocaleScript(loc.[[Locale]])를 반환한다.

15.3.15 Intl.Locale.prototype.toString ( )

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. loc.[[Locale]]을 반환한다.

15.3.16 Intl.Locale.prototype.getCalendars ( )

getCalendars 메서드가 호출되면 다음 단계가 수행된다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. CalendarsOfLocale(loc)를 반환한다.

15.3.17 Intl.Locale.prototype.getCollations ( )

getCollations 메서드가 호출되면 다음 단계가 수행된다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. CollationsOfLocale(loc)를 반환한다.

15.3.18 Intl.Locale.prototype.getHourCycles ( )

getHourCycles 메서드가 호출되면 다음 단계가 수행된다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. HourCyclesOfLocale(loc)를 반환한다.

15.3.19 Intl.Locale.prototype.getNumberingSystems ( )

getNumberingSystems 메서드가 호출되면 다음 단계가 수행된다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. NumberingSystemsOfLocale(loc)를 반환한다.

15.3.20 Intl.Locale.prototype.getTimeZones ( )

getTimeZones 메서드가 호출되면 다음 단계가 수행된다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. TimeZonesOfLocale(loc)를 반환한다.

15.3.21 Intl.Locale.prototype.getTextInfo ( )

getTextInfo 메서드가 호출되면 다음 단계가 수행된다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. infoOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  4. dirTextDirectionOfLocale(loc)로 둔다.
  5. CreateDataPropertyOrThrow(info, "direction", dir)를 수행한다.
  6. info를 반환한다.

15.3.22 Intl.Locale.prototype.getWeekInfo ( )

getWeekInfo 메서드가 호출되면 다음 단계가 수행된다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. infoOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  4. weekInfoWeekInfoOfLocale(loc)로 둔다.
  5. CreateDataPropertyOrThrow(info, "firstDay", weekInfo.[[FirstDay]])를 수행한다.
  6. CreateDataPropertyOrThrow(info, "weekend", CreateArrayFromList(weekInfo.[[Weekend]]))를 수행한다.
  7. info를 반환한다.

15.3.23 get Intl.Locale.prototype.variants

Intl.Locale.prototype.variants는 set accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. locthis 값으로 둔다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. GetLocaleVariants(loc.[[Locale]])를 반환한다.

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

%Symbol.toStringTag% 속성의 초기값은 String 값 "Intl.Locale"이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } 속성을 가진다.

15.4 Intl.Locale 인스턴스의 속성

Intl.Locale 인스턴스는 %Intl.Locale.prototype%에서 속성을 상속하는 ordinary 객체이다.

Intl.Locale 인스턴스는 [[InitializedLocale]] 내부 슬롯을 가진다.

Intl.Locale 인스턴스는 또한 Intl.Locale 생성자에 의해 계산되는 여러 내부 슬롯을 가진다:

  • [[Locale]]은 형식화에 사용되는 localization의 locale 언어 태그를 가진 String 값이다.
  • [[Calendar]]undefined이거나 canonical form의 well-formed Unicode Calendar Identifier인 String 값이다.
  • [[Collation]]undefined이거나 canonical form의 well-formed Unicode Collation Identifier인 String 값이다.
  • [[FirstDayOfWeek]]undefined이거나 canonical form의 유효한 Unicode First Day Identifier인 String 값이다.
  • [[HourCycle]]undefined이거나 canonical form의 유효한 Unicode Hour Cycle Identifier인 String 값이다.
  • [[NumberingSystem]]undefined이거나 canonical form의 well-formed Unicode Number System Identifier인 String 값이다.
  • [[CaseFirst]]undefined이거나 String 값 "upper", "lower" 또는 "false" 중 하나이다. 이 내부 슬롯은 %Intl.Locale%[[LocaleExtensionKeys]] 내부 슬롯이 "kf"를 포함하는 경우에만 존재한다.
  • [[Numeric]]undefined이거나 locale에서 numeric sorting이 사용되는지 여부를 지정하는 Boolean 값이다. 이 내부 슬롯은 %Intl.Locale%[[LocaleExtensionKeys]] 내부 슬롯이 "kn"을 포함하는 경우에만 존재한다.

15.5 Locale 객체를 위한 추상 연산

15.5.1 GetLocaleBaseName ( locale )

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

  1. Assert: localeunicode_locale_id Unicode locale nonterminal에 의해 매칭될 수 있다.
  2. unicode_language_id Unicode locale nonterminal에 의해 매칭되는 locale의 가장 긴 prefix를 반환한다.

15.5.2 GetLocaleLanguage ( locale )

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

  1. baseNameGetLocaleBaseName(locale)으로 둔다.
  2. Assert: baseName의 첫 번째 subtagunicode_language_subtag Unicode locale nonterminal에 의해 매칭될 수 있다.
  3. baseName의 첫 번째 subtag를 반환한다.

15.5.3 GetLocaleScript ( locale )

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

  1. baseNameGetLocaleBaseName(locale)으로 둔다.
  2. Assert: baseNameunicode_script_subtag Unicode locale nonterminal에 의해 매칭될 수 있는 subtag를 최대 하나 포함한다.
  3. baseNameunicode_script_subtag Unicode locale nonterminal에 의해 매칭되는 subtag를 포함하면, 그 subtag를 반환한다.
  4. undefined를 반환한다.

15.5.4 GetLocaleRegion ( locale )

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

  1. baseNameGetLocaleBaseName(locale)으로 둔다.
  2. NOTE: unicode_region_subtag subtag는 초기 unicode_language_subtag subtag 바로 뒤에서만 유효하며, 선택적으로 그 사이에 단일 unicode_script_subtag subtag가 있을 수 있다. 그 위치에서 unicode_region_subtag는 다른 유효한 subtag와 혼동될 수 없다. 이들의 모든 productions가 서로소이기 때문이다.
  3. Assert: baseName의 첫 번째 subtagunicode_language_subtag Unicode locale nonterminal에 의해 매칭될 수 있다.
  4. baseNameTail을 첫 번째 subtag 뒤에 오는 baseName의 접미사로 둔다.
  5. Assert: baseNameTailunicode_region_subtag Unicode locale nonterminal에 의해 매칭될 수 있는 subtag를 최대 하나 포함한다.
  6. baseNameTailunicode_region_subtag Unicode locale nonterminal에 의해 매칭되는 subtag를 포함하면, 그 subtag를 반환한다.
  7. undefined를 반환한다.

15.5.5 GetLocaleVariants ( locale )

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

  1. baseNameGetLocaleBaseName(locale)으로 둔다.
  2. 참고: baseName에서 "-" 앞에 오는 각 하위 태그는 unicode_script_subtag, unicode_region_subtag, 또는 unicode_variant_subtag 중 하나이지만, unicode_variant_subtag와 일치하는 모든 부분 문자열은 다른 생성식 중 하나와도 일치할 수 있는 그 어떤 접두사보다도 엄격히 더 길다.
  3. subtagsStringSplitToList(baseName, "-")로 둔다.
  4. dashIndexsubtags[0]의 길이로 둔다.
  5. subtags에서 첫 번째 요소를 제거한다.
  6. subtags의 각 String subtag에 대해,
    1. subtagunicode_variant_subtag Unicode locale 비종단 기호와 일치하면,
      1. baseName에서 dashIndex + 1부터의 부분 문자열을 반환한다.
    2. subtagLengthsubtag의 길이로 둔다.
    3. dashIndexdashIndex + subtagLength + 1로 설정한다.
  7. undefined를 반환한다.

15.5.6 UnicodeExtensionValue ( locale, key )

The abstract operation UnicodeExtensionValue takes arguments locale (Unicode canonicalized locale identifier) and key (String) and returns String 또는 empty. It performs the following steps when called:

  1. localeUnicode locale extension sequence를 포함하면,
    1. extensionlocaleUnicode locale extension sequence로 둔다.
    2. componentsUnicodeExtensionComponents(extension)로 둔다.
    3. keywordscomponents.[[Keywords]]로 둔다.
    4. keywordsentry.[[Key]]key인 요소 entry가 존재하면 entry.[[Value]]를 반환한다.
  2. empty를 반환한다.

15.5.7 CanonicalUnicodeSubdivision ( locale, key )

The abstract operation CanonicalUnicodeSubdivision takes arguments locale (Unicode canonicalized locale identifier) and key ("rg" 또는 "sd") and returns String 또는 undefined. It performs the following steps when called:

  1. subdivisionUnicodeExtensionValue(locale, key)로 둔다.
  2. subdivisionempty이면 undefined를 반환한다.
  3. subdivisionunicode_subdivision_id Unicode locale nonterminal에 의해 매칭될 수 없으면 undefined를 반환한다.
  4. regionunicode_region_subtag Unicode locale nonterminal에 의해 매칭되는 subdivision의 가장 긴 prefix로 둔다.
  5. regionLocale"und-"region의 문자열 연결로 둔다.
  6. regionLocaleCanonicalizeUnicodeLocaleId(regionLocale)로 설정한다.
  7. GetLocaleRegion(regionLocale)을 반환한다.

15.5.8 RegionPreference ( locale )

The abstract operation RegionPreference takes argument locale (Unicode canonicalized locale identifier) and returns [[Region]](String) 및 [[RegionOverride]](String 또는 undefined) 필드를 가진 Record. It performs the following steps when called:

  1. regionGetLocaleRegion(locale)으로 둔다.
  2. regionundefined이면,
    1. regionCanonicalUnicodeSubdivision(locale, "sd")로 설정한다.
    2. regionundefined이면,
      1. maximallocale에 적용된 Add Likely Subtags 알고리즘의 결과로 둔다. error가 signal되면 maximallocale로 설정한다.
      2. maximalCanonicalizeUnicodeLocaleId(maximal)로 설정한다.
      3. regionGetLocaleRegion(maximal)으로 설정한다.
      4. regionundefined이면,
        1. region"001"로 설정한다.
  3. regionOverrideCanonicalUnicodeSubdivision(locale, "rg")로 둔다.
  4. { [[Region]]: region, [[RegionOverride]]: regionOverride }를 반환한다.

15.5.9 CalendarsOfLocale ( loc )

The implementation-defined abstract operation CalendarsOfLocale takes argument loc (Intl.Locale) and returns Array. 다음 알고리즘은 Unicode Technical Standard #35 Part 4 Dates, Calendar Preference Data에 명시된 Locale 데이터를 참조한다. It performs the following steps when called:

  1. loc.[[Calendar]]undefined가 아니면,
    1. CreateArrayFromListloc.[[Calendar]] »)를 반환한다.
  2. preferenceRegionPreference(loc.[[Locale]])로 둔다.
  3. regionpreference.[[Region]]으로 둔다.
  4. regionOverridepreference.[[RegionOverride]]로 둔다.
  5. regionOverrideundefined가 아니고 regionOverride에 대한 calendar preference data가 이용 가능하면,
    1. lookupRegionregionOverride로 둔다.
  6. 그렇지 않으면,
    1. lookupRegionregion으로 둔다.
  7. list를 새 빈 List로 둔다.
  8. availableCalendarsAvailableCalendars()로 둔다.
  9. calendarsInUselookupRegion에서 date and time formatting에 공통적으로 사용되는 고유한 calendar typeList로 둔다. 이는 lookupRegion에서 사용 선호도의 내림차순으로 정렬된다. lookupRegion에 대한 calendar preference data가 없으면 list는 비어 있다.
  10. calendarsInUse의 각 요소 identifier에 대해, 다음을 수행한다.
    1. canonicalCanonicalizeUValue("ca", identifier)로 둔다.
    2. identifiercanonical이고 availableCalendarsidentifier를 포함하면,
      1. identifierlist에 append한다.
  11. list가 비어 있으면 list를 « "gregory" »로 설정한다.
  12. CreateArrayFromList(list)를 반환한다.

15.5.10 CollationsOfLocale ( loc )

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

  1. loc.[[Collation]]undefined가 아니면,
    1. CreateArrayFromListloc.[[Collation]] »)를 반환한다.
  2. languageGetLocaleLanguage(loc.[[Locale]])로 둔다.
  3. language"und"가 아니면,
    1. matchLookupMatchingLocaleByPrefix(%Intl.Collator%.[[AvailableLocales]], « loc.[[Locale]] »)로 둔다.
    2. matchundefined가 아니면 foundLocalematch.[[locale]]로 두고, 그렇지 않으면 foundLocaleDefaultLocale()로 둔다.
    3. foundLocaleData%Intl.Collator%.[[SortLocaleData]].[[<foundLocale>]]로 둔다.
    4. listfoundLocaleData.[[co]]의 복사본으로 둔다.
    5. Assert: list[0]은 null이다.
    6. list에서 첫 번째 요소를 제거한다.
  4. 그렇지 않으면,
    1. list를 « "emoji", "eor" »로 둔다.
  5. sortedlexicographic code unit order에 따라 정렬된 list의 복사본으로 둔다.
  6. CreateArrayFromList(sorted)를 반환한다.

15.5.11 HourCyclesOfLocale ( loc )

The implementation-defined abstract operation HourCyclesOfLocale takes argument loc (Intl.Locale) and returns Array. 다음 알고리즘은 Unicode Technical Standard #35 Part 4 Dates, Time Data에 명시된 Locale 데이터를 참조한다. It performs the following steps when called:

  1. loc.[[HourCycle]]undefined가 아니면,
    1. CreateArrayFromListloc.[[HourCycle]] »)를 반환한다.
  2. preferenceRegionPreference(loc.[[Locale]])로 둔다.
  3. regionpreference.[[Region]]으로 둔다.
  4. regionOverridepreference.[[RegionOverride]]로 둔다.
  5. regionOverrideundefined가 아니고 regionOverride에 대한 time data가 이용 가능하면,
    1. lookupRegionregionOverride로 둔다.
  6. 그렇지 않으면,
    1. lookupRegionregion으로 둔다.
  7. list를 고유한 hour cycle identifier의 List로 둔다. 이는 12-hour format("h11", "h12") 또는 24-hour format("h23", "h24") 중 하나를 나타내는 lowercase String 값이어야 하며, lookupRegion에서 date and time formatting에 공통적으로 사용되는 것들의 내림차순 선호도로 정렬된다. lookupRegion에 대한 time data가 없으면 list는 비어 있다.
  8. list가 비어 있으면 list를 « "h23" »으로 설정한다.
  9. CreateArrayFromList(list)를 반환한다.

15.5.12 NumberingSystemsOfLocale ( loc )

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

  1. loc.[[NumberingSystem]]undefined가 아니면,
    1. CreateArrayFromListloc.[[NumberingSystem]] »)를 반환한다.
  2. matchLookupMatchingLocaleByPrefix(%Intl.NumberFormat%.[[AvailableLocales]], « loc.[[Locale]] »)로 둔다.
  3. matchundefined가 아니면,
    1. foundLocalematch.[[locale]]로 둔다.
    2. foundLocaleData%Intl.NumberFormat%.[[LocaleData]].[[<foundLocale>]]로 둔다.
    3. numberingSystemsfoundLocaleData.[[nu]]로 둔다.
    4. list를 « numberingSystems[0] »로 둔다.
  4. 그렇지 않으면,
    1. list를 « "latn" »으로 둔다.
  5. CreateArrayFromList(list)를 반환한다.

15.5.13 TimeZonesOfLocale ( loc )

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

  1. regionGetLocaleRegion(loc.[[Locale]])으로 둔다.
  2. regionundefined이면 undefined를 반환한다.
  3. list를 고유한 canonical time zone identifierList로 둔다. 이는 IANA Time Zone Database의 canonical Zone name을 나타내는 String 값이어야 하며, region에서 공통적으로 사용되는 것들이다. region에서 공통적으로 사용되는 time zone이 없으면 list는 비어 있다. list는 lexicographic code unit order에 따라 정렬된다.
  4. CreateArrayFromList( list )를 반환한다.

15.5.14 TextDirectionOfLocale ( loc )

The implementation-defined abstract operation TextDirectionOfLocale takes argument loc (Intl.Locale) and returns String 또는 undefined. 다음 알고리즘은 Unicode Technical Standard #35 Part 1 Core, Script Metadata에 명시된 Locale 데이터를 참조한다. It performs the following steps when called:

  1. localeloc.[[Locale]]로 둔다.
  2. scriptGetLocaleScript(locale)로 둔다.
  3. scriptundefined이면,
    1. maximallocale에 적용된 Add Likely Subtags 알고리즘의 결과로 둔다. error가 signal되면 undefined를 반환한다.
    2. scriptGetLocaleScript(maximal)로 설정한다.
    3. scriptundefined이면 undefined를 반환한다.
  4. script에서 line 내 character의 default general ordering이 right-to-left이면 "rtl"을 반환한다.
  5. script에서 line 내 character의 default general ordering이 left-to-right이면 "ltr"을 반환한다.
  6. undefined를 반환한다.
Note 1
script에서 line 내 character의 default general ordering 방향을 결정할 수 없거나, 그 방향이 right-to-left도 left-to-right도 아니면 undefined가 반환된다.
Note 2
어떤 언어의 text는 둘 이상의 가능한 방향을 가질 수 있다. 한 script로 쓰인 언어의 text 또한 둘 이상의 가능한 방향을 가질 수 있다. 따라서 text 조각과 연결된 metadata에 direction 정보가 포함되어 있다면, 그 direction 정보가 primary source of truth로 간주되어야 한다. TextDirectionOfLocale이 반환하는 정보는 text와 연결된 metadata가 없어 text의 direction 정보를 제공하지 못할 때의 fallback mechanism으로만 사용되어야 한다. direction 정보가 없지만 language 정보가 알려져 있을 때에만 사용해야 한다. Web developer는 text의 direction을 결정하기 위해 이 API에 과도하게 의존해서는 안 된다.

15.5.15 WeekdayToUValue ( fw )

The abstract operation WeekdayToUValue takes argument fw (String) and returns String. 요일을 숫자로 나타내는 string을 Unicode Technical Standard #35 Part 1 Core Section 3.6.1 Key and Type Definitions에 정의된 유효한 Unicode First Day Identifier로 변환하고, 다른 모든 string은 수정 없이 반환한다. It performs the following steps when called:

  1. Table 26의 각 행에 대해, 헤더 행을 제외하고 표 순서대로, 다음을 수행한다.
    1. weekday를 현재 행의 Weekday 값으로 둔다.
    2. string을 현재 행의 String 값으로 둔다.
    3. fwweekday와 같으면 string을 반환한다.
  2. fw를 반환한다.
Table 26: Weekday String 및 Value
Weekday String Value
"0" "sun" 7𝔽
"1" "mon" 1𝔽
"2" "tue" 2𝔽
"3" "wed" 3𝔽
"4" "thu" 4𝔽
"5" "fri" 5𝔽
"6" "sat" 6𝔽
"7" "sun" 7𝔽

15.5.16 WeekdayUValueToNumber ( fw )

The abstract operation WeekdayUValueToNumber takes argument fw (String) and returns integral Number 또는 undefined. Unicode Technical Standard #35 Part 1 Core Section 3.6.1 Key and Type Definitions에 정의된 Unicode First Day Identifier를 숫자 ISO 8601 calendar day of week로 변환하고, 다른 모든 string에 대해 undefined를 반환한다. It performs the following steps when called:

  1. Table 26의 각 행에 대해, 헤더 행을 제외하고 표 순서대로, 다음을 수행한다.
    1. string을 현재 행의 String 값으로 둔다.
    2. value를 현재 행의 Value 값으로 둔다.
    3. fwstring과 같으면 value를 반환한다.
  2. undefined를 반환한다.

15.5.17 WeekInfoOfLocale ( loc )

The implementation-defined abstract operation WeekInfoOfLocale takes argument loc (Intl.Locale) and returns Record. 다음 알고리즘은 Unicode Technical Standard #35 Part 4 Dates, Week Elements에 명시된 Locale 데이터를 참조한다. It performs the following steps when called:

  1. localeloc.[[Locale]]로 둔다.
  2. weekInfoTable 27에 정의된 필드를 가진 Record로 둔다. 값은 locale에 기반한다.
  3. firstDayStringloc.[[FirstDayOfWeek]]로 둔다.
  4. firstDayStringundefined가 아니면,
    1. firstDayWeekdayUValueToNumber(firstDayString)로 둔다.
    2. firstDayundefined가 아니면 weekInfo.[[FirstDay]]firstDay로 설정한다.
  5. weekInfo를 반환한다.
Note
Record의 반환 값은 Unicode Technical Standard #35 Part 4 Dates, Week DataFirst Day Overrides에 요약된 명세에 따라 locale에 의해 결정된다.
Table 27: WeekInfo Record 필드
필드 이름 의미
[[FirstDay]] calendar day의 ISO 8601 calendar day of week이며, Monday가 1𝔽로 시작하고 Sunday가 7𝔽로 끝나는 week calendar day 시퀀스 안에서의 1-based ordinal position이다. calendar 목적으로 week의 어느 day가 “first”로 간주되는지.
[[Weekend]] 오름차순 숫자 순서의, 1𝔽(Monday)부터 7𝔽(Sunday)까지 하나 이상의 ISO 8601 calendar day of week integral Number 값의 List. calendar 목적으로 week의 어떤 day들이 “weekend”의 일부로 간주되는지를 나타내는 weekday 값의 list. weekend의 day 수는 locale마다 다를 수 있으며, 연속적이지 않을 수도 있음에 주의하라.

16 NumberFormat 객체

16.1 Intl.NumberFormat 생성자

Intl.NumberFormat 생성자는:

  • %Intl.NumberFormat%이다.
  • Intl 객체"NumberFormat" 속성의 초기값이다.

Intl 객체의 모든 서비스 생성자 속성에 공통인 동작은 9.1에 명시되어 있다.

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

Intl.NumberFormat 함수가 선택적 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. NewTarget이 undefined이면 newTargetactive function object로 두고, 그렇지 않으면 newTarget을 NewTarget으로 둔다.
  2. numberFormat을 ? OrdinaryCreateFromConstructor(newTarget, "%Intl.NumberFormat.prototype%", « [[InitializedNumberFormat]], [[Locale]], [[LocaleData]], [[NumberingSystem]], [[Style]], [[Unit]], [[UnitDisplay]], [[Currency]], [[CurrencyDisplay]], [[CurrencySign]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[RoundingType]], [[Notation]], [[CompactDisplay]], [[UseGrouping]], [[SignDisplay]], [[RoundingIncrement]], [[RoundingMode]], [[ComputedRoundingPriority]], [[TrailingZeroDisplay]], [[BoundFormat]] »)로 둔다.
  3. optionsResolution을 ? ResolveOptions(%Intl.NumberFormat%, %Intl.NumberFormat%.[[LocaleData]], locales, options, « coerce-options »)로 둔다.
  4. optionsoptionsResolution.[[Options]]로 설정한다.
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]]로 둔다.
  6. numberFormat.[[Locale]]resolvedLocale.[[Locale]]로 설정한다.
  7. numberFormat.[[LocaleData]]resolvedLocale.[[LocaleData]]로 설정한다.
  8. numberFormat.[[NumberingSystem]]resolvedLocale.[[nu]]로 설정한다.
  9. SetNumberFormatUnitOptions(numberFormat, options)를 수행한다.
  10. stylenumberFormat.[[Style]]로 둔다.
  11. notation을 ? GetOption(options, "notation", string, « "standard", "scientific", "engineering", "compact" », "standard")로 둔다.
  12. numberFormat.[[Notation]]notation으로 설정한다.
  13. style"currency"이고 notation"standard"이면,
    1. currencynumberFormat.[[Currency]]로 둔다.
    2. cDigitsCurrencyDigits(currency)로 둔다.
    3. mnfdDefaultcDigits로 둔다.
    4. mxfdDefaultcDigits로 둔다.
  14. 그렇지 않으면,
    1. mnfdDefault를 0으로 둔다.
    2. style"percent"이면,
      1. mxfdDefault를 0으로 둔다.
    3. 그렇지 않으면,
      1. mxfdDefault를 3으로 둔다.
  15. SetNumberFormatDigitOptions(numberFormat, options, mnfdDefault, mxfdDefault, notation)를 수행한다.
  16. compactDisplay를 ? GetOption(options, "compactDisplay", string, « "short", "long" », "short")로 둔다.
  17. defaultUseGrouping"auto"로 둔다.
  18. notation"compact"이면,
    1. numberFormat.[[CompactDisplay]]compactDisplay로 설정한다.
    2. defaultUseGrouping"min2"로 설정한다.
  19. NOTE: 역사적인 이유로, string "true""false"는 허용되며 기본값으로 대체된다.
  20. useGrouping을 ? GetBooleanOrStringNumberFormatOption(options, "useGrouping", « "min2", "auto", "always", "true", "false" », defaultUseGrouping)로 둔다.
  21. useGrouping"true" 또는 useGrouping"false"이면 useGroupingdefaultUseGrouping으로 설정한다.
  22. useGroupingtrue이면 useGrouping"always"로 설정한다.
  23. numberFormat.[[UseGrouping]]useGrouping으로 설정한다.
  24. signDisplay를 ? GetOption(options, "signDisplay", string, « "auto", "never", "always", "exceptZero", "negative" », "auto")로 둔다.
  25. numberFormat.[[SignDisplay]]signDisplay로 설정한다.
  26. 구현이 4.3 Note 1의 규범적 선택 사항 constructor mode를 지원하면,
    1. thisthis 값으로 둔다.
    2. ChainNumberFormat(numberFormat, NewTarget, this)를 반환한다.
  27. numberFormat을 반환한다.

16.1.1.1 ChainNumberFormat ( numberFormat, newTarget, this )

The abstract operation ChainNumberFormat takes arguments numberFormat (Intl.NumberFormat), newTarget (ECMAScript 언어 값), and this (ECMAScript 언어 값) and returns Object를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. newTargetundefined이고 ? OrdinaryHasInstance(%Intl.NumberFormat%, this)가 true이면,
    1. DefinePropertyOrThrow(this, %Intl%.[[FallbackSymbol]], PropertyDescriptor { [[Value]]: numberFormat, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false })를 수행한다.
    2. this를 반환한다.
  2. numberFormat을 반환한다.

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

The abstract operation SetNumberFormatDigitOptions takes arguments intlObj (Object), options (Object), mnfdDefault (정수), mxfdDefault (정수), and notation (String) and returns unused를 포함하는 정상 완료 또는 throw 완료. locale-independent number rounding에 영향을 주는 intlObj의 내부 슬롯을 채운다(16.5.3 참조). It performs the following steps when called:

  1. mnid를 ? GetNumberOption(options, "minimumIntegerDigits", 1, 21, 1)로 둔다.
  2. mnfd를 ? Get(options, "minimumFractionDigits")로 둔다.
  3. mxfd를 ? Get(options, "maximumFractionDigits")로 둔다.
  4. mnsd를 ? Get(options, "minimumSignificantDigits")로 둔다.
  5. mxsd를 ? Get(options, "maximumSignificantDigits")로 둔다.
  6. intlObj.[[MinimumIntegerDigits]]mnid로 설정한다.
  7. roundingIncrement를 ? GetNumberOption(options, "roundingIncrement", 1, 5000, 1)로 둔다.
  8. roundingIncrement가 « 1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000, 2500, 5000 » 안에 없으면 RangeError 예외를 던진다.
  9. roundingMode를 ? GetOption(options, "roundingMode", string, « "ceil", "floor", "expand", "trunc", "halfCeil", "halfFloor", "halfExpand", "halfTrunc", "halfEven" », "halfExpand")로 둔다.
  10. roundingPriority를 ? GetOption(options, "roundingPriority", string, « "auto", "morePrecision", "lessPrecision" », "auto")로 둔다.
  11. trailingZeroDisplay를 ? GetOption(options, "trailingZeroDisplay", string, « "auto", "stripIfInteger" », "auto")로 둔다.
  12. NOTE: SetNumberFormatDigitOptions가 요구하는 모든 필드는 이제 options에서 읽혔다. 이 AO의 나머지는 options를 해석하며 예외를 던질 수 있다.
  13. roundingIncrement가 1이 아니면 mxfdDefaultmnfdDefault로 설정한다.
  14. intlObj.[[RoundingIncrement]]roundingIncrement로 설정한다.
  15. intlObj.[[RoundingMode]]roundingMode로 설정한다.
  16. intlObj.[[TrailingZeroDisplay]]trailingZeroDisplay로 설정한다.
  17. mnsdundefined이고 mxsdundefined이면 hasSdfalse로 둔다. 그렇지 않으면 hasSdtrue로 둔다.
  18. mnfdundefined이고 mxfdundefined이면 hasFdfalse로 둔다. 그렇지 않으면 hasFdtrue로 둔다.
  19. needSdtrue로 둔다.
  20. needFdtrue로 둔다.
  21. roundingPriority"auto"이면,
    1. needSdhasSd로 설정한다.
    2. needSdtrue이거나, hasFdfalse이고 notation"compact"이면,
      1. needFdfalse로 설정한다.
  22. needSdtrue이면,
    1. hasSdtrue이면,
      1. intlObj.[[MinimumSignificantDigits]]를 ? DefaultNumberOption(mnsd, 1, 21, 1)로 설정한다.
      2. intlObj.[[MaximumSignificantDigits]]를 ? DefaultNumberOption(mxsd, intlObj.[[MinimumSignificantDigits]], 21, 21)로 설정한다.
    2. 그렇지 않으면,
      1. intlObj.[[MinimumSignificantDigits]]를 1로 설정한다.
      2. intlObj.[[MaximumSignificantDigits]]를 21로 설정한다.
  23. needFdtrue이면,
    1. hasFdtrue이면,
      1. mnfd를 ? DefaultNumberOption(mnfd, 0, 100, undefined)로 설정한다.
      2. mxfd를 ? DefaultNumberOption(mxfd, 0, 100, undefined)로 설정한다.
      3. mnfdundefined이면 mnfdmin(mnfdDefault, mxfd)로 설정한다.
      4. 그렇지 않고 mxfdundefined이면 mxfdmax(mxfdDefault, mnfd)로 설정한다.
      5. 그렇지 않고 mnfdmxfd보다 크면 RangeError 예외를 던진다.
      6. intlObj.[[MinimumFractionDigits]]mnfd로 설정한다.
      7. intlObj.[[MaximumFractionDigits]]mxfd로 설정한다.
    2. 그렇지 않으면,
      1. intlObj.[[MinimumFractionDigits]]mnfdDefault로 설정한다.
      2. intlObj.[[MaximumFractionDigits]]mxfdDefault로 설정한다.
  24. needSdfalse이고 needFdfalse이면,
    1. intlObj.[[MinimumFractionDigits]]를 0으로 설정한다.
    2. intlObj.[[MaximumFractionDigits]]를 0으로 설정한다.
    3. intlObj.[[MinimumSignificantDigits]]를 1로 설정한다.
    4. intlObj.[[MaximumSignificantDigits]]를 2로 설정한다.
    5. intlObj.[[RoundingType]]more-precision으로 설정한다.
    6. intlObj.[[ComputedRoundingPriority]]"morePrecision"으로 설정한다.
  25. 그렇지 않고 roundingPriority"morePrecision"이면,
    1. intlObj.[[RoundingType]]more-precision으로 설정한다.
    2. intlObj.[[ComputedRoundingPriority]]"morePrecision"으로 설정한다.
  26. 그렇지 않고 roundingPriority"lessPrecision"이면,
    1. intlObj.[[RoundingType]]less-precision으로 설정한다.
    2. intlObj.[[ComputedRoundingPriority]]"lessPrecision"으로 설정한다.
  27. 그렇지 않고 hasSdtrue이면,
    1. intlObj.[[RoundingType]]significant-digits로 설정한다.
    2. intlObj.[[ComputedRoundingPriority]]"auto"로 설정한다.
  28. 그렇지 않으면,
    1. intlObj.[[RoundingType]]fraction-digits로 설정한다.
    2. intlObj.[[ComputedRoundingPriority]]"auto"로 설정한다.
  29. roundingIncrement가 1이 아니면,
    1. intlObj.[[RoundingType]]fraction-digits가 아니면 TypeError 예외를 던진다.
    2. intlObj.[[MaximumFractionDigits]]intlObj.[[MinimumFractionDigits]]가 아니면 RangeError 예외를 던진다.
  30. unused를 반환한다.

16.1.3 SetNumberFormatUnitOptions ( intlObj, options )

The abstract operation SetNumberFormatUnitOptions takes arguments intlObj (Intl.NumberFormat) and options (Object) and returns unused를 포함하는 정상 완료 또는 throw 완료. unit과 관련된 사용자 지정 options를 intlObj에 resolve한다. It performs the following steps when called:

  1. style을 ? GetOption(options, "style", string, « "decimal", "percent", "currency", "unit" », "decimal")로 둔다.
  2. intlObj.[[Style]]style로 설정한다.
  3. currency를 ? GetOption(options, "currency", string, empty, undefined)로 둔다.
  4. currencyundefined이면,
    1. style"currency"이면 TypeError 예외를 던진다.
  5. 그렇지 않으면,
    1. IsWellFormedCurrencyCode(currency)가 false이면 RangeError 예외를 던진다.
  6. currencyDisplay를 ? GetOption(options, "currencyDisplay", string, « "code", "symbol", "narrowSymbol", "name" », "symbol")로 둔다.
  7. currencySign을 ? GetOption(options, "currencySign", string, « "standard", "accounting" », "standard")로 둔다.
  8. unit을 ? GetOption(options, "unit", string, empty, undefined)로 둔다.
  9. unitundefined이면,
    1. style"unit"이면 TypeError 예외를 던진다.
  10. 그렇지 않으면,
    1. IsWellFormedUnitIdentifier(unit)가 false이면 RangeError 예외를 던진다.
  11. unitDisplay를 ? GetOption(options, "unitDisplay", string, « "short", "narrow", "long" », "short")로 둔다.
  12. style"currency"이면,
    1. intlObj.[[Currency]]currencyASCII-uppercase로 설정한다.
    2. intlObj.[[CurrencyDisplay]]currencyDisplay로 설정한다.
    3. intlObj.[[CurrencySign]]currencySign으로 설정한다.
  13. style"unit"이면,
    1. intlObj.[[Unit]]unit으로 설정한다.
    2. intlObj.[[UnitDisplay]]unitDisplay로 설정한다.
  14. unused를 반환한다.

16.2 Intl.NumberFormat 생성자의 속성

Intl.NumberFormat 생성자는:

  • 값이 %Function.prototype%[[Prototype]] 내부 슬롯을 가진다.
  • 다음 속성을 가진다:

16.2.1 Intl.NumberFormat.prototype

Intl.NumberFormat.prototype의 값은 %Intl.NumberFormat.prototype%이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } 속성을 가진다.

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

supportedLocalesOf 메서드가 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. availableLocales%Intl.NumberFormat%.[[AvailableLocales]]로 둔다.
  2. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  3. FilterLocales(availableLocales, requestedLocales, options)를 반환한다.

16.2.3 내부 슬롯

[[AvailableLocales]] 내부 슬롯의 값은 9.1에 설명된 제약 안에서 구현 정의이다.

[[RelevantExtensionKeys]] 내부 슬롯의 값은 « "nu" »이다.

[[ResolutionOptionDescriptors]] 내부 슬롯의 값은 « { [[Key]]: "nu", [[Property]]: "numberingSystem" } »이다.

Note 1
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions는 number formatting과 관련된 세 locale extension key를 설명한다. currency용 "cu", currency format style용 "cf", 그리고 numbering system용 "nu"이다. 그러나 Intl.NumberFormat은 currency format의 currency가 options 객체의 currency property를 통해 지정되고, currency format의 currency format style이 options 객체의 currencySign property를 통해 지정될 것을 요구한다.

[[LocaleData]] 내부 슬롯의 값은 9.1에 설명된 제약 및 다음 추가 제약 안에서 구현 정의이다:

  • [[LocaleData]]의 임의 locale 필드의 "nu" 필드 값인 List"native", "traditio" 또는 "finance" 값을 포함해서는 안 된다.
  • [[LocaleData]].[[<locale>]]는 모든 locale 값 locale에 대해 [[patterns]] 필드를 가져야 한다. 이 필드의 값은 Record여야 하며, 네 number format style의 이름인 "decimal", "percent", "currency""unit" 필드를 가져야 한다.
  • 위에 언급된 두 필드 "currency""unit"은 적어도 하나의 필드 "fallback"을 가진 Record여야 한다. "currency"6.3에 따른 currency code에 대응하는 key를 가진 추가 필드를 가질 수 있다. "currency"의 각 필드는 가능한 currencyDisplay 값 "code", "symbol", "narrowSymbol""name"에 대응하는 필드를 가진 Record여야 한다. 그 각 필드는 가능한 currencySign 값 "standard" 또는 "accounting"에 대응하는 필드를 가진 Record를 포함해야 한다. ([[LocaleData]].[[<locale>]]의) "unit" 필드는 필수 필드 "fallback" 외에도 6.6에 대응하는 core measurement unit identifier에 대응하는 key를 가진 추가 필드를 가질 수 있다. "unit"의 각 필드는 가능한 unitDisplay 값 "narrow", "short""long"에 대응하는 필드를 가진 Record여야 한다.
  • 지금까지 patterns tree에 대해 설명한 모든 leaf 필드("decimal", "percent", "currency"의 great-grandchildren 및 "unit"의 grandchildren)는 key "positivePattern", "zeroPattern""negativePattern"을 가진 Record여야 한다.
  • 앞서 언급한 필드(sign-dependent pattern fields)의 값은 반드시 substring "{number}"를 포함하는 string 값이어야 한다. "positivePattern"substring "{plusSign}"를 포함해야 하지만 "{minusSign}"는 포함해서는 안 된다. "negativePattern"substring "{minusSign}"를 포함해야 하지만 "{plusSign}"는 포함해서는 안 된다. 그리고 "zeroPattern""{plusSign}" 또는 "{minusSign}" 어느 것도 포함해서는 안 된다. 추가로, "percent" 필드 안의 값은 substring "{percentSign}"도 포함해야 한다. "currency" 필드 안의 값은 다음 substring 중 하나 이상을 포함해야 한다: "{currencyCode}", "{currencyPrefix}", 또는 "{currencySuffix}". 그리고 "unit" 필드 안의 값은 다음 substring 중 하나 이상을 포함해야 한다: "{unitPrefix}" 또는 "{unitSuffix}". pattern string은 ECMA-262, 6.1.4에 설명된 것처럼 UTF-16으로 인코딩된 code point 시퀀스로 해석될 때, Unicode Standard에 명시된 General Category "Number, decimal digit"의 code point를 포함해서는 안 된다.
  • [[LocaleData]].[[<locale>]]는 모든 locale 값 locale에 대해 [[notationSubPatterns]] 필드도 가져야 한다. 이 필드의 값은 Record여야 하며, 두 필드 [[scientific]][[compact]]를 가져야 한다. [[scientific]] 필드는 substring "{number}", "{scientificSeparator}""{scientificExponent}"를 포함하는 string 값이어야 한다. [[compact]] 필드는 두 필드 "short""long"을 가진 Record여야 한다. 이 각 필드는 구현이 compact notation에 대해 지원하는 모든 discrete magnitude에 대응하는 integer key를 가진 Record여야 한다. 이 각 필드는 substring "{number}"를 포함할 수 있는 string 값이어야 한다. "short"에서 내려온 string은 substring "{compactSymbol}"를 포함해야 하며, "long"에서 내려온 string은 substring "{compactName}"를 포함해야 한다.
Note 2
구현은 Common Locale Data Repository(https://cldr.unicode.org/에서 이용 가능)가 제공하는 locale 데이터를 사용하는 것이 권장된다.

16.3 Intl.NumberFormat Prototype 객체의 속성

Intl.NumberFormat prototype 객체는:

  • %Intl.NumberFormat.prototype%이다.
  • ordinary 객체이다.
  • Intl.NumberFormat 인스턴스가 아니며 [[InitializedNumberFormat]] 내부 슬롯 또는 Intl.NumberFormat 인스턴스 객체의 다른 내부 슬롯을 가지지 않는다.
  • 값이 %Object.prototype%[[Prototype]] 내부 슬롯을 가진다.

16.3.1 Intl.NumberFormat.prototype.constructor

Intl.NumberFormat.prototype.constructor의 초기값은 %Intl.NumberFormat%이다.

16.3.2 Intl.NumberFormat.prototype.resolvedOptions ( )

이 함수는 객체 초기화 중 계산된 locale 및 options에 대한 접근을 제공한다.

  1. nfthis 값으로 둔다.
  2. 구현이 4.3 Note 1의 규범적 선택 사항 constructor mode를 지원하면,
    1. nf를 ? UnwrapNumberFormat(nf)로 설정한다.
  3. RequireInternalSlot(nf, [[InitializedNumberFormat]])를 수행한다.
  4. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  5. Table 28의 각 행에 대해, 헤더 행을 제외하고 표 순서대로, 다음을 수행한다.
    1. propertyKey를 현재 행의 Property 값으로 둔다.
    2. value를 현재 행의 Internal Slot 값이 이름인 nf의 내부 슬롯 값으로 둔다.
    3. valueundefined가 아니면,
      1. 현재 행에 Conversion 값이 있으면,
        1. Assert: 현재 행의 Conversion 값은 number이다.
        2. value𝔽(value)로 설정한다.
      2. CreateDataPropertyOrThrow(options, propertyKey, value)를 수행한다.
  6. options를 반환한다.
Table 28: NumberFormat 인스턴스의 Resolved Options
Internal Slot Property Conversion
[[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 accessor function이 undefinedaccessor property이다. 그 get accessor function은 다음 단계를 수행한다:

  1. nfthis 값으로 둔다.
  2. 구현이 4.3 Note 1의 규범적 선택 사항 constructor mode를 지원하면,
    1. nf를 ? UnwrapNumberFormat(nf)로 설정한다.
  3. RequireInternalSlot(nf, [[InitializedNumberFormat]])를 수행한다.
  4. nf.[[BoundFormat]]undefined이면,
    1. func를 Number Format Functions(16.5.2)에 정의된 새 built-in function object로 둔다.
    2. func.[[NumberFormat]]nf로 설정한다.
    3. nf.[[BoundFormat]]func로 설정한다.
  5. nf.[[BoundFormat]]을 반환한다.
Note
반환된 함수는 nf에 bound되어 Array.prototype.map 또는 다른 함수에 직접 전달될 수 있다. 이는 historical artefact로 간주되며, 새 기능에서는 더 이상 따르지 않는 관례의 일부이지만, 기존 프로그램과의 compatibility를 유지하기 위해 보존된다.

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

formatRange 메서드가 인수 startend와 함께 호출되면 다음 단계가 수행된다:

  1. nfthis 값으로 둔다.
  2. RequireInternalSlot(nf, [[InitializedNumberFormat]])를 수행한다.
  3. startundefined이거나 endundefined이면 TypeError 예외를 던진다.
  4. x를 ? ToIntlMathematicalValue(start)로 둔다.
  5. y를 ? ToIntlMathematicalValue(end)로 둔다.
  6. FormatNumericRange(nf, x, y)를 반환한다.

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

formatRangeToParts 메서드가 인수 startend와 함께 호출되면 다음 단계가 수행된다:

  1. nfthis 값으로 둔다.
  2. RequireInternalSlot(nf, [[InitializedNumberFormat]])를 수행한다.
  3. startundefined이거나 endundefined이면 TypeError 예외를 던진다.
  4. x를 ? ToIntlMathematicalValue(start)로 둔다.
  5. y를 ? ToIntlMathematicalValue(end)로 둔다.
  6. FormatNumericRangeToParts(nf, x, y)를 반환한다.

16.3.6 Intl.NumberFormat.prototype.formatToParts ( value )

formatToParts 메서드가 선택적 인수 value와 함께 호출되면 다음 단계가 수행된다:

  1. nfthis 값으로 둔다.
  2. RequireInternalSlot(nf, [[InitializedNumberFormat]])를 수행한다.
  3. x를 ? ToIntlMathematicalValue(value)로 둔다.
  4. FormatNumericToParts(nf, x)를 반환한다.

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

%Symbol.toStringTag% 속성의 초기값은 String 값 "Intl.NumberFormat"이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } 속성을 가진다.

16.4 Intl.NumberFormat 인스턴스의 속성

Intl.NumberFormat 인스턴스는 %Intl.NumberFormat.prototype%에서 속성을 상속하는 ordinary 객체이다.

Intl.NumberFormat 인스턴스는 [[InitializedNumberFormat]] 내부 슬롯을 가진다.

Intl.NumberFormat 인스턴스는 또한 Intl.NumberFormat 생성자에 의해 계산되는 여러 내부 슬롯을 가진다:

  • [[Locale]]은 형식화에 사용되는 localization의 locale 언어 태그를 가진 String 값이다.
  • [[LocaleData]]는 형식화를 위해 구현에서 사용할 수 있는 데이터를 나타내는 Record이다. 이는 [[Locale]]의 값 또는 그 prefix와 연결된 %Intl.NumberFormat%.[[LocaleData]]의 entry 값이다.
  • [[NumberingSystem]]은 형식화에 사용되는 Unicode Number System Identifier를 나타내는 String 값이다.
  • [[Style]]은 측정되는 수량의 type을 식별하는 String 값 "decimal", "currency", "percent" 또는 "unit" 중 하나이다.
  • [[Currency]]"currency" unit type으로 형식화할 때 사용할 currency를 식별하는 currency code를 가진 String 값이다. 이는 [[Style]] 값이 "currency"일 때에만 사용된다.
  • [[CurrencyDisplay]]"currency" style로 형식화할 때 currency를 ISO 4217 alphabetic currency code, localized currency symbol 또는 localized currency name으로 표시할지 지정하는 String 값 "code", "symbol", "narrowSymbol" 또는 "name" 중 하나이다. 이는 [[Style]] 값이 "currency"일 때에만 사용된다.
  • [[CurrencySign]]은 negative number를 accounting format으로 렌더링할지 지정하는 String 값 "standard" 또는 "accounting" 중 하나이며, 보통 parenthesis로 표시된다. 이는 [[Style]] 값이 "currency"이고 [[SignDisplay]]"never"가 아닐 때에만 사용된다.
  • [[Unit]]core unit identifier이다. 이는 [[Style]] 값이 "unit"일 때에만 사용된다.
  • [[UnitDisplay]]"unit" style로 형식화할 때 unit을 symbol, narrow symbol 또는 localized long name으로 표시할지 지정하는 String 값 "short", "narrow" 또는 "long" 중 하나이다. 이는 [[Style]] 값이 "unit"일 때에만 사용된다.
  • [[MinimumIntegerDigits]]는 사용할 최소 integer digits를 나타내는 non-negative integer이다. 필요하면 number는 leading zero로 padding된다.
  • [[MinimumFractionDigits]][[MaximumFractionDigits]]는 사용할 최소 및 최대 fraction digits를 나타내는 non-negative integer이다. 필요하면 number는 반올림되거나 trailing zero로 padding된다. 이러한 속성은 [[RoundingType]]fraction-digits, more-precision 또는 less-precision일 때에만 사용된다.
  • [[MinimumSignificantDigits]][[MaximumSignificantDigits]]는 표시할 최소 및 최대 fraction digits를 나타내는 positive integer이다. 존재하면 formatter는 지정된 significant digits 수를 표시하는 데 필요한 만큼의 fraction digits를 사용한다. 이러한 속성은 [[RoundingType]]significant-digits, more-precision 또는 less-precision일 때에만 사용된다.
  • [[UseGrouping]]은 grouping separator를 사용해야 하는 조건을 나타내는 Boolean 또는 String 값이다. grouping separator의 위치와 formatted number에 grouping separator를 표시할지 여부는 구현 정의이다. 값 "always"는 가능하면 grouping separator를 표시하도록 구현에 hint를 준다. "min2"는 group에 적어도 2개의 digit가 있는 경우, "auto"는 locale이 formatted number에 grouping separator 사용을 선호하는 경우이다. 값 false는 grouping separator를 비활성화한다.
  • [[RoundingType]]은 사용할 rounding strategy를 나타내는 fraction-digits, significant-digits, more-precision 또는 less-precision 중 하나의 값이다. fraction-digits이면 formatted number는 위에 설명된 것처럼 [[MinimumFractionDigits]][[MaximumFractionDigits]]에 따라 반올림된다. significant-digits이면 formatted number는 위에 설명된 것처럼 [[MinimumSignificantDigits]][[MaximumSignificantDigits]]에 따라 반올림된다. more-precision 또는 less-precision이면 네 설정 모두가 사용되며, 어느 set를 사용할지 disambiguate하는 specific rule이 적용된다. [[RoundingType]]"roundingPriority" option에서 도출된다.
  • [[ComputedRoundingPriority]]는 String 값 "auto", "morePrecision" 또는 "lessPrecision" 중 하나이다. 이는 [[RoundingType]]을 유효한 "roundingPriority" option으로 다시 변환하기 위해 16.3.2에서만 사용된다.
  • [[Notation]]은 formatted number가 scaling 없이 표시될지, scientific notation에서 power of ten을 사용해 units place로 scaling될지, scientific notation에서 power of ten을 사용해 nearest thousand로 scaling될지, 또는 대응하는 compact decimal notation affix와 함께 nearest ILD compact decimal notation power of ten으로 scaling될지를 지정하는 String 값 "standard", "scientific", "engineering" 또는 "compact" 중 하나이다.
  • [[CompactDisplay]]는 compact notation affix를 short form("5K") 또는 long form("5 thousand")으로 표시할지 지정하는 "short", "long" 또는 undefined 중 하나이다. [[Notation]]"compact" 이외의 값을 가질 때 그리고 그때에만 undefined이다.
  • [[SignDisplay]]는 sign을 언제 포함할지 지정하는 String 값 "auto", "always", "never", "exceptZero" 또는 "negative" 중 하나이다(non-"auto" options는 각각 항상 포함, 절대 포함하지 않음, non-zero number에만 포함, 또는 non-zero negative number에만 포함에 대응한다). scientific notation에서 이 슬롯은 mantissa의 sign display에 영향을 주지만 exponent에는 영향을 주지 않는다.
  • [[RoundingIncrement]]는 10, 100, 1000 또는 10000을 tenths, fifths, quarters 또는 halves로 균등하게 나누는 정수이다. 이는 계산된 rounding magnitude를 기준으로 rounding이 이루어져야 하는 increment를 나타낸다. 예를 들어 [[MaximumFractionDigits]]가 2이고 [[RoundingIncrement]]가 5이면 formatted number는 가장 가까운 0.05로 반올림된다("nickel rounding").
  • [[RoundingMode]]rounding mode이며, Table 29의 Identifier 열에 있는 String 값 중 하나이다.
  • [[TrailingZeroDisplay]]는 formatted number가 integer인 경우(즉, non-zero fraction digit를 가지지 않는 경우) trailing zero를 제거할지 여부를 나타내는 String 값 "auto" 또는 "stripIfInteger" 중 하나이다.
Table 29: Intl.NumberFormat의 Rounding mode
Identifier Description 예: 0 fraction digit로 반올림
-1.5 0.4 0.5 0.6 1.5
"ceil" 양의 무한대 방향 ⬆️ [-1] ⬆️ [1] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"floor" 음의 무한대 방향 ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬇️ [0] ⬇️ [1]
"expand" 0에서 멀어지는 방향 ⬇️ [-2] ⬆️ [1] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"trunc" 0 방향 ⬆️ [-1] ⬇️ [0] ⬇️ [0] ⬇️ [0] ⬇️ [1]
"halfCeil" tie는 양의 무한대 방향 ⬆️ [-1] ⬇️ [0] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"halfFloor" tie는 음의 무한대 방향 ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬇️ [1]
"halfExpand" tie는 0에서 멀어지는 방향 ⬇️ [-2] ⬇️ [0] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"halfTrunc" tie는 0 방향 ⬆️ [-1] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬇️ [1]
"halfEven" tie는 짝수 rounding increment multiple 방향 ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬆️ [2]
Note
예시는 각 option의 고유한 동작을 설명하기 위한 것이다. ⬆️는 "양의 무한대 방향으로 resolve됨"을 의미하고, ⬇️는 "음의 무한대 방향으로 resolve됨"을 의미한다.

마지막으로, Intl.NumberFormat 인스턴스는 format accessor(16.3.3)가 반환하는 함수를 cache하는 [[BoundFormat]] 내부 슬롯을 가진다.

16.5 NumberFormat 객체를 위한 추상 연산

16.5.1 CurrencyDigits ( currency )

The implementation-defined abstract operation CurrencyDigits takes argument currency (String) and returns non-negative integer. It performs the following steps when called:

  1. Assert: IsWellFormedCurrencyCode(currency)는 true이다.
  2. currency에 대응하는 currency의 수량을 형식화할 때 사용되는 fractional digit의 수를 나타내는 non-negative integer를 반환한다. 사용할 digit 수에 대한 이용 가능한 정보가 없으면 2를 반환한다.

16.5.2 Number Format 함수

Number format 함수는 [[NumberFormat]] 내부 슬롯을 가지는 익명 built-in function이다.

Number format 함수 func가 선택적 인수 value와 함께 호출되면 다음 단계가 수행된다:

  1. nffunc.[[NumberFormat]]으로 둔다.
  2. Assert: nf는 Object이고 nf[[InitializedNumberFormat]] 내부 슬롯을 가진다.
  3. value가 제공되지 않았으면 valueundefined로 둔다.
  4. x를 ? ToIntlMathematicalValue(value)로 둔다.
  5. FormatNumeric(nf, x)를 반환한다.

Number format 함수의 "length" 속성은 1𝔽이다.

16.5.3 FormatNumericToString ( intlObj, x )

The abstract operation FormatNumericToString takes arguments intlObj (Object) and x (mathematical value 또는 negative-zero) and returns [[RoundedNumber]](mathematical value 또는 negative-zero) 및 [[FormattedString]](String) 필드를 가진 Record. intlObj의 내부 슬롯에 따라 xIntl mathematical value로 반올림한다. [[RoundedNumber]] 필드는 반올림된 결과 값을 포함하고, [[FormattedString]] 필드는 intlObj의 내부 슬롯에 따라 형식화된 그 결과의 String 값 표현을 포함한다. It performs the following steps when called:

  1. Assert: intlObj[[RoundingMode]], [[RoundingType]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[RoundingIncrement]][[TrailingZeroDisplay]] 내부 슬롯을 가진다.
  2. xnegative-zero이면,
    1. signnegative로 둔다.
    2. x를 0으로 설정한다.
  3. 그렇지 않으면,
    1. Assert: xmathematical value이다.
    2. x < 0이면 signnegative로 두고, 그렇지 않으면 signpositive로 둔다.
    3. signnegative이면,
      1. x를 -x로 설정한다.
  4. unsignedRoundingModeGetUnsignedRoundingMode(intlObj.[[RoundingMode]], sign)로 둔다.
  5. intlObj.[[RoundingType]]significant-digits이면,
    1. resultToRawPrecision(x, intlObj.[[MinimumSignificantDigits]], intlObj.[[MaximumSignificantDigits]], unsignedRoundingMode)로 둔다.
  6. 그렇지 않고 intlObj.[[RoundingType]]fraction-digits이면,
    1. resultToRawFixed(x, intlObj.[[MinimumFractionDigits]], intlObj.[[MaximumFractionDigits]], intlObj.[[RoundingIncrement]], unsignedRoundingMode)로 둔다.
  7. 그렇지 않으면,
    1. significantResultToRawPrecision(x, intlObj.[[MinimumSignificantDigits]], intlObj.[[MaximumSignificantDigits]], unsignedRoundingMode)로 둔다.
    2. fractionResultToRawFixed(x, intlObj.[[MinimumFractionDigits]], intlObj.[[MaximumFractionDigits]], intlObj.[[RoundingIncrement]], unsignedRoundingMode)로 둔다.
    3. fractionResult.[[RoundingMagnitude]] < significantResult.[[RoundingMagnitude]]이면 fixedIsMorePrecisetrue로 두고, 그렇지 않으면 fixedIsMorePrecisefalse로 둔다.
    4. intlObj.[[RoundingType]]more-precision이고 fixedIsMorePrecisetrue이면,
      1. resultfractionResult로 둔다.
    5. 그렇지 않고 intlObj.[[RoundingType]]less-precision이고 fixedIsMorePrecisefalse이면,
      1. resultfractionResult로 둔다.
    6. 그렇지 않으면,
      1. resultsignificantResult로 둔다.
  8. xresult.[[RoundedNumber]]로 설정한다.
  9. stringresult.[[FormattedString]]로 둔다.
  10. intlObj.[[TrailingZeroDisplay]]"stripIfInteger"이고 x modulo 1 = 0이면,
    1. iStringIndexOf(string, ".", 0)으로 둔다.
    2. inot-found가 아니면 stringstring의 0부터 i까지의 substring으로 설정한다.
  11. intresult.[[IntegerDigitsCount]]로 둔다.
  12. minIntDigitsintlObj.[[MinimumIntegerDigits]]로 둔다.
  13. int < minIntDigits이면,
    1. forwardZeros를 code unit 0x0030 (DIGIT ZERO)이 minIntDigits - int번 나타나는 것으로 구성된 String으로 둔다.
    2. stringforwardZerosstring의 문자열 연결로 설정한다.
  14. signnegative이면,
    1. x가 0이면 xnegative-zero로 설정한다. 그렇지 않으면 x를 -x로 설정한다.
  15. Record { [[RoundedNumber]]: x, [[FormattedString]]: string }를 반환한다.

16.5.4 PartitionNumberPattern ( numberFormat, x )

The abstract operation PartitionNumberPattern takes arguments numberFormat (NumberFormat으로 초기화된 object) and x (Intl mathematical value) and returns [[Type]](String) 및 [[Value]](String) 필드를 가진 RecordList. numberFormat의 유효 locale 및 formatting options에 따라 xmathematical value를 나타내는 parts를 생성한다. It performs the following steps when called:

  1. exponent를 0으로 둔다.
  2. xnot-a-number이면,
    1. formattedStringNaN 값을 나타내는 ILD String 값으로 둔다.
  3. 그렇지 않고 xpositive-infinity이면,
    1. formattedString을 positive infinity를 나타내는 ILD String 값으로 둔다.
  4. 그렇지 않고 xnegative-infinity이면,
    1. formattedString을 negative infinity를 나타내는 ILD String 값으로 둔다.
  5. 그렇지 않으면,
    1. xnegative-zero가 아니면,
      1. Assert: xmathematical value이다.
      2. numberFormat.[[Style]]"percent"이면 x를 100 × x로 설정한다.
      3. exponentComputeExponent(numberFormat, x)로 설정한다.
      4. xx × 10-exponent로 설정한다.
    2. formatNumberResultFormatNumericToString(numberFormat, x)로 둔다.
    3. formattedStringformatNumberResult.[[FormattedString]]로 둔다.
    4. xformatNumberResult.[[RoundedNumber]]로 설정한다.
  6. patternGetNumberFormatPattern(numberFormat, x)로 둔다.
  7. result를 새 빈 List로 둔다.
  8. patternPartsPartitionPattern(pattern)으로 둔다.
  9. patternParts의 각 Record { [[Type]], [[Value]] } patternPart에 대해, 다음을 수행한다.
    1. partTypepatternPart.[[Type]]로 둔다.
    2. partType"literal"이면,
      1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }를 result에 append한다.
    3. 그렇지 않고 partType"number"이면,
      1. notationSubPartsPartitionNotationSubPattern(numberFormat, x, formattedString, exponent)로 둔다.
      2. resultresultnotationSubPartslist-concatenation으로 설정한다.
    4. 그렇지 않고 partType"plusSign"이면,
      1. plusSignSymbol을 plus sign을 나타내는 ILND String으로 둔다.
      2. Record { [[Type]]: "plusSign", [[Value]]: plusSignSymbol }를 result에 append한다.
    5. 그렇지 않고 partType"minusSign"이면,
      1. minusSignSymbol을 minus sign을 나타내는 ILND String으로 둔다.
      2. Record { [[Type]]: "minusSign", [[Value]]: minusSignSymbol }를 result에 append한다.
    6. 그렇지 않고 partType"percentSign"이고 numberFormat.[[Style]]"percent"이면,
      1. percentSignSymbol을 percent sign을 나타내는 ILND String으로 둔다.
      2. Record { [[Type]]: "percentSign", [[Value]]: percentSignSymbol }를 result에 append한다.
    7. 그렇지 않고 partType"unitPrefix"이고 numberFormat.[[Style]]"unit"이면,
      1. unitnumberFormat.[[Unit]]으로 둔다.
      2. unitDisplaynumberFormat.[[UnitDisplay]]로 둔다.
      3. unitStringunitDisplay 형식에서 x 앞의 unit을 나타내는 ILD String 값으로 둔다. 이는 서로 다른 plural form을 가진 언어에서 x에 의존할 수 있다.
      4. Record { [[Type]]: "unit", [[Value]]: unitString }를 result에 append한다.
    8. 그렇지 않고 partType"unitSuffix"이고 numberFormat.[[Style]]"unit"이면,
      1. unitnumberFormat.[[Unit]]으로 둔다.
      2. unitDisplaynumberFormat.[[UnitDisplay]]로 둔다.
      3. unitStringunitDisplay 형식에서 x 뒤의 unit을 나타내는 ILD String 값으로 둔다. 이는 서로 다른 plural form을 가진 언어에서 x에 의존할 수 있다.
      4. Record { [[Type]]: "unit", [[Value]]: unitString }를 result에 append한다.
    9. 그렇지 않고 partType"currencyCode"이고 numberFormat.[[Style]]"currency"이면,
      1. currencynumberFormat.[[Currency]]로 둔다.
      2. Record { [[Type]]: "currency", [[Value]]: currency }를 result에 append한다.
    10. 그렇지 않고 partType"currencyPrefix"이고 numberFormat.[[Style]]"currency"이면,
      1. currencynumberFormat.[[Currency]]로 둔다.
      2. currencyDisplaynumberFormat.[[CurrencyDisplay]]로 둔다.
      3. currencyStringcurrencyDisplay 형식에서 x 앞의 currency를 나타내는 ILD String 값으로 둔다. 이는 서로 다른 plural form을 가진 언어에서 x에 의존할 수 있다.
      4. Record { [[Type]]: "currency", [[Value]]: currencyString }를 result에 append한다.
    11. 그렇지 않고 partType"currencySuffix"이고 numberFormat.[[Style]]"currency"이면,
      1. currencynumberFormat.[[Currency]]로 둔다.
      2. currencyDisplaynumberFormat.[[CurrencyDisplay]]로 둔다.
      3. currencyStringcurrencyDisplay 형식에서 x 뒤의 currency를 나타내는 ILD String 값으로 둔다. 이는 서로 다른 plural form을 가진 언어에서 x에 의존할 수 있다. 구현이 currency의 그러한 표현을 가지지 않으면 currency 자체를 사용한다.
      4. Record { [[Type]]: "currency", [[Value]]: currencyString }를 result에 append한다.
    12. 그렇지 않으면,
      1. unknownxpartType에 기반한 ILND String으로 둔다.
      2. Record { [[Type]]: "unknown", [[Value]]: unknown }를 result에 append한다.
  10. result를 반환한다.

16.5.5 PartitionNotationSubPattern ( numberFormat, x, formattedString, exponent )

The abstract operation PartitionNotationSubPattern takes arguments numberFormat (Intl.NumberFormat), x (Intl mathematical value), formattedString (String), and exponent (정수) and returns [[Type]](String) 및 [[Value]](String) 필드를 가진 RecordList. x는 rounding이 적용된 후의 Intl mathematical value이고 formattedString은 중간 formatted string이다. numberFormat의 유효 locale 및 formatting options에 따라 number 및 notation에 대응하는 parts를 생성한다. It performs the following steps when called:

  1. result를 새 빈 List로 둔다.
  2. xnot-a-number이면,
    1. Record { [[Type]]: "nan", [[Value]]: formattedString }를 result에 append한다.
  3. 그렇지 않고 xpositive-infinity 또는 negative-infinity이면,
    1. Record { [[Type]]: "infinity", [[Value]]: formattedString }를 result에 append한다.
  4. 그렇지 않으면,
    1. notationSubPatternGetNotationSubPattern(numberFormat, exponent)로 둔다.
    2. patternPartsPartitionPattern(notationSubPattern)으로 둔다.
    3. patternParts의 각 Record { [[Type]], [[Value]] } patternPart에 대해, 다음을 수행한다.
      1. partTypepatternPart.[[Type]]로 둔다.
      2. partType"literal"이면,
        1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }를 result에 append한다.
      3. 그렇지 않고 partType"number"이면,
        1. numberFormat.[[NumberingSystem]]이 아래 Table 30의 Numbering System 열에 있는 값 중 하나와 match하면,
          1. digitsTable 30의 matching row의 Digits 열에 명시된 code point를 요소로 하는 List로 둔다.
          2. Assert: digits의 길이는 10이다.
          3. transliterated를 빈 String으로 둔다.
          4. lengthformattedString의 길이로 둔다.
          5. position을 0으로 둔다.
          6. position < length인 동안 반복한다.
            1. cformattedString 안의 index position에 있는 code unit으로 둔다.
            2. 0x0030 ≤ c ≤ 0x0039이면,
              1. NOTE: c는 ASCII digit이다.
              2. ic - 0x0030으로 둔다.
              3. cCodePointsToStringdigits[i] »)로 설정한다.
            3. transliteratedtransliteratedc의 문자열 연결로 설정한다.
            4. positionposition + 1로 설정한다.
          7. formattedStringtransliterated로 설정한다.
        2. 그렇지 않으면,
          1. 구현 의존 알고리즘을 사용하여 formattedString을 주어진 numbering system에서 formattedString의 적절한 표현으로 매핑한다.
        3. decimalSepIndexStringIndexOf(formattedString, ".", 0)으로 둔다.
        4. decimalSepIndexnot-found가 아니고 decimalSepIndex > 0이면,
          1. intDigitsformattedString의 0부터 decimalSepIndex까지의 substring으로 둔다.
          2. fractionDigitsformattedStringdecimalSepIndex + 1부터의 substring으로 둔다.
        5. 그렇지 않으면,
          1. intDigitsformattedString으로 둔다.
          2. fractionDigitsundefined로 둔다.
        6. numberFormat.[[UseGrouping]]false이면,
          1. Record { [[Type]]: "integer", [[Value]]: intDigits }를 result에 append한다.
        7. 그렇지 않으면,
          1. groupSepSymbol을 grouping separator를 나타내는 ILND String으로 둔다.
          2. groupsintDigits 안의 ILND location 집합이 정의하는 substring을 왼쪽에서 오른쪽 순서로 요소로 하는 List로 둔다. 이는 numberFormat.[[UseGrouping]]의 값에 의존할 수 있다.
          3. Assert: groups List의 요소 수는 0보다 크다.
          4. groups List가 비어 있지 않은 동안 반복한다.
            1. groups에서 첫 번째 요소를 제거하고 intGroup을 그 요소의 값으로 둔다.
            2. Record { [[Type]]: "integer", [[Value]]: intGroup }를 result에 append한다.
            3. groups List가 비어 있지 않으면,
              1. Record { [[Type]]: "group", [[Value]]: groupSepSymbol }를 result에 append한다.
        8. fractionDigitsundefined가 아니면,
          1. decimalSepSymbol을 decimal separator를 나타내는 ILND String으로 둔다.
          2. Record { [[Type]]: "decimal", [[Value]]: decimalSepSymbol }를 result에 append한다.
          3. Record { [[Type]]: "fraction", [[Value]]: fractionDigits }를 result에 append한다.
      4. 그렇지 않고 partType"compactSymbol"이면,
        1. compactSymbol을 short form에서 exponent를 나타내는 ILD string으로 둔다. 이는 서로 다른 plural form을 가진 언어에서 x에 의존할 수 있다. 구현은 이 string을 제공할 수 있어야 하며, 그렇지 않으면 pattern에 "{compactSymbol}" placeholder가 없었을 것이다.
        2. Record { [[Type]]: "compact", [[Value]]: compactSymbol }를 result에 append한다.
      5. 그렇지 않고 partType"compactName"이면,
        1. compactName을 long form에서 exponent를 나타내는 ILD string으로 둔다. 이는 서로 다른 plural form을 가진 언어에서 x에 의존할 수 있다. 구현은 이 string을 제공할 수 있어야 하며, 그렇지 않으면 pattern에 "{compactName}" placeholder가 없었을 것이다.
        2. Record { [[Type]]: "compact", [[Value]]: compactName }를 result에 append한다.
      6. 그렇지 않고 partType"scientificSeparator"이면,
        1. scientificSeparator를 exponent separator를 나타내는 ILND String으로 둔다.
        2. Record { [[Type]]: "exponentSeparator", [[Value]]: scientificSeparator }를 result에 append한다.
      7. 그렇지 않고 partType"scientificExponent"이면,
        1. exponent < 0이면,
          1. minusSignSymbol을 minus sign을 나타내는 ILND String으로 둔다.
          2. Record { [[Type]]: "exponentMinusSign", [[Value]]: minusSignSymbol }를 result에 append한다.
          3. exponent를 -exponent로 둔다.
        2. exponentResultToRawFixed(exponent, 0, 0, 1, undefined)로 둔다.
        3. Record { [[Type]]: "exponentInteger", [[Value]]: exponentResult.[[FormattedString]] }를 result에 append한다.
      8. 그렇지 않으면,
        1. unknownxpartType에 기반한 ILND String으로 둔다.
        2. Record { [[Type]]: "unknown", [[Value]]: unknown }를 result에 append한다.
  5. result를 반환한다.
Table 30: 단순 digit mapping을 가진 numbering system
Numbering System Digits
adlm U+1E950 to U+1E959
ahom U+11730 to U+11739
arab U+0660 to U+0669
arabext U+06F0 to U+06F9
bali U+1B50 to U+1B59
beng U+09E6 to U+09EF
bhks U+11C50 to U+11C59
brah U+11066 to U+1106F
cakm U+11136 to U+1113F
cham U+AA50 to U+AA59
deva U+0966 to U+096F
diak U+11950 to U+11959
fullwide U+FF10 to U+FF19
gara U+10D40 to U+10D49
gong U+11DA0 to U+11DA9
gonm U+11D50 to U+11D59
gujr U+0AE6 to U+0AEF
gukh U+16130 to U+16139
guru U+0A66 to U+0A6F
hanidec U+3007, U+4E00, U+4E8C, U+4E09, U+56DB, U+4E94, U+516D, U+4E03, U+516B, U+4E5D
hmng U+16B50 to U+16B59
hmnp U+1E140 to U+1E149
java U+A9D0 to U+A9D9
kali U+A900 to U+A909
kawi U+11F50 to U+11F59
khmr U+17E0 to U+17E9
knda U+0CE6 to U+0CEF
krai U+16D70 to U+16D79
lana U+1A80 to U+1A89
lanatham U+1A90 to U+1A99
laoo U+0ED0 to U+0ED9
latn U+0030 to U+0039
lepc U+1C40 to U+1C49
limb U+1946 to U+194F
mathbold U+1D7CE to U+1D7D7
mathdbl U+1D7D8 to U+1D7E1
mathmono U+1D7F6 to U+1D7FF
mathsanb U+1D7EC to U+1D7F5
mathsans U+1D7E2 to U+1D7EB
mlym U+0D66 to U+0D6F
modi U+11650 to U+11659
mong U+1810 to U+1819
mroo U+16A60 to U+16A69
mtei U+ABF0 to U+ABF9
mymr U+1040 to U+1049
mymrepka U+116DA to U+116E3
mymrpao U+116D0 to U+116D9
mymrshan U+1090 to U+1099
mymrtlng U+A9F0 to U+A9F9
nagm U+1E4F0 to U+1E4F9
newa U+11450 to U+11459
nkoo U+07C0 to U+07C9
olck U+1C50 to U+1C59
onao U+1E5F1 to U+1E5FA
orya U+0B66 to U+0B6F
osma U+104A0 to U+104A9
outlined U+1CCF0 to U+1CCF9
rohg U+10D30 to U+10D39
saur U+A8D0 to U+A8D9
segment U+1FBF0 to U+1FBF9
shrd U+111D0 to U+111D9
sind U+112F0 to U+112F9
sinh U+0DE6 to U+0DEF
sora U+110F0 to U+110F9
sund U+1BB0 to U+1BB9
sunu U+11BF0 to U+11BF9
takr U+116C0 to U+116C9
talu U+19D0 to U+19D9
tamldec U+0BE6 to U+0BEF
telu U+0C66 to U+0C6F
thai U+0E50 to U+0E59
tibt U+0F20 to U+0F29
tirh U+114D0 to U+114D9
tnsa U+16AC0 to U+16AC9
tols U+11DE0 to U+11DE9
vaii U+A620 to U+A629
wara U+118E0 to U+118E9
wcho U+1E2F0 to U+1E2F9
Note 1
계산은 numberFormat의 유효 locale 또는 numberFormat의 유효 locale 및 numbering system에 의존하는 numeric string 안의 location 및 ILDILND String 값에 의존한다. 언급된 ILDILND String 값은 currency name에 대한 것을 제외하고, Unicode Standard에 명시된 General Category "Number, decimal digit"의 code point를 포함해서는 안 된다.
Note 2
구현은 Common Locale Data Repository(https://cldr.unicode.org/에서 이용 가능)가 제공하는 locale을 사용하는 것이 권장된다.

16.5.6 FormatNumeric ( numberFormat, x )

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

  1. partsPartitionNumberPattern(numberFormat, x)로 둔다.
  2. result를 빈 String으로 둔다.
  3. parts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
    1. resultresultpart.[[Value]]의 문자열 연결로 설정한다.
  4. result를 반환한다.

16.5.7 FormatNumericToParts ( numberFormat, x )

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

  1. partsPartitionNumberPattern(numberFormat, x)로 둔다.
  2. result를 ! ArrayCreate(0)으로 둔다.
  3. n을 0으로 둔다.
  4. parts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
    1. partObjOrdinaryObjectCreate(%Object.prototype%)로 둔다.
    2. CreateDataPropertyOrThrow(partObj, "type", part.[[Type]])를 수행한다.
    3. CreateDataPropertyOrThrow(partObj, "value", part.[[Value]])를 수행한다.
    4. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), partObj)를 수행한다.
    5. nn + 1로 설정한다.
  5. result를 반환한다.

16.5.8 ToRawPrecision ( x, minPrecision, maxPrecision, unsignedRoundingMode )

The abstract operation ToRawPrecision takes arguments x (non-negative mathematical value), minPrecision (inclusive interval 1부터 21까지의 정수), maxPrecision (inclusive interval 1부터 21까지의 정수), and unsignedRoundingMode (Table 31의 Unsigned Rounding Mode 열에서 온 specification type, 또는 undefined) and returns [[FormattedString]](String), [[RoundedNumber]](mathematical value), [[IntegerDigitsCount]](정수) 및 [[RoundingMagnitude]](정수) 필드를 가진 Record.

이는 integer input이 주어졌을 때 유효한 mathematical value를 반환하는 다음 equation을 푸는 것을 포함한다:

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

It performs the following steps when called:

  1. pmaxPrecision으로 둔다.
  2. x = 0이면,
    1. m을 code unit 0x0030 (DIGIT ZERO)이 p번 나타나는 것으로 구성된 String으로 둔다.
    2. e를 0으로 둔다.
    3. xFinal을 0으로 둔다.
  3. 그렇지 않으면,
    1. n1e1 각각을 정수로, r1mathematical value로 두며, r1 = ToRawPrecisionFn(n1, e1, p)이고, r1x이며 r1이 최대가 되도록 한다.
    2. n2e2 각각을 정수로, r2mathematical value로 두며, r2 = ToRawPrecisionFn(n2, e2, p)이고, r2x이며 r2가 최소가 되도록 한다.
    3. xFinalApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode)로 둔다.
    4. xFinalr1이면,
      1. nn1으로 둔다.
      2. ee1으로 둔다.
    5. 그렇지 않으면,
      1. nn2로 둔다.
      2. ee2로 둔다.
    6. mn의 decimal representation의 digit로 구성된 String으로 둔다(순서대로, leading zero 없이).
  4. e ≥ (p - 1)이면,
    1. mm과 code unit 0x0030 (DIGIT ZERO)이 e - p + 1번 나타나는 것의 문자열 연결로 설정한다.
    2. inte + 1로 둔다.
  5. 그렇지 않고 e ≥ 0이면,
    1. mm의 첫 e + 1 code unit, code unit 0x002E (FULL STOP), 그리고 m의 남은 p - (e + 1) code unit의 문자열 연결로 설정한다.
    2. inte + 1로 둔다.
  6. 그렇지 않으면,
    1. Assert: e < 0이다.
    2. m"0.", code unit 0x0030 (DIGIT ZERO)이 -(e + 1)번 나타나는 것, 그리고 m의 문자열 연결로 설정한다.
    3. int를 1로 둔다.
  7. m이 code unit 0x002E (FULL STOP)를 포함하고 maxPrecision > minPrecision이면,
    1. cutmaxPrecision - minPrecision으로 둔다.
    2. cut > 0이고 m의 마지막 code unit이 0x0030 (DIGIT ZERO)인 동안 반복한다.
      1. m에서 마지막 code unit을 제거한다.
      2. cutcut - 1로 설정한다.
    3. m의 마지막 code unit이 0x002E (FULL STOP)이면,
      1. m에서 마지막 code unit을 제거한다.
  8. Record { [[FormattedString]]: m, [[RoundedNumber]]: xFinal, [[IntegerDigitsCount]]: int, [[RoundingMagnitude]]: ep+1 }를 반환한다.

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

The abstract operation ToRawFixed takes arguments x (non-negative mathematical value), minFraction (inclusive interval 0부터 100까지의 정수), maxFraction (inclusive interval 0부터 100까지의 정수), roundingIncrement (정수), and unsignedRoundingMode (Table 31의 Unsigned Rounding Mode 열에서 온 specification type, 또는 undefined) and returns [[FormattedString]](String), [[RoundedNumber]](mathematical value), [[IntegerDigitsCount]](정수) 및 [[RoundingMagnitude]](정수) 필드를 가진 Record.

이는 integer input이 주어졌을 때 유효한 mathematical value를 반환하는 다음 equation을 푸는 것을 포함한다:

ToRawFixedFn(n, f) = n × 10f

It performs the following steps when called:

  1. fmaxFraction으로 둔다.
  2. n1을 정수로, r1mathematical value로 두며, r1 = ToRawFixedFn(n1, f)이고, n1 modulo roundingIncrement = 0, r1x이며 r1이 최대가 되도록 한다.
  3. n2를 정수로, r2mathematical value로 두며, r2 = ToRawFixedFn(n2, f)이고, n2 modulo roundingIncrement = 0, r2x이며 r2가 최소가 되도록 한다.
  4. xFinalApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode)로 둔다.
  5. xFinalr1이면 nn1으로 둔다. 그렇지 않으면 nn2로 둔다.
  6. n = 0이면 m"0"으로 둔다. 그렇지 않으면 mn의 decimal representation의 digit로 구성된 String으로 둔다(순서대로, leading zero 없이).
  7. f ≠ 0이면,
    1. km의 길이로 둔다.
    2. kf이면,
      1. z를 code unit 0x0030 (DIGIT ZERO)이 f + 1 - k번 나타나는 것으로 구성된 String 값으로 둔다.
      2. mzm의 문자열 연결로 설정한다.
      3. kf + 1로 설정한다.
    3. am의 처음 k - f code unit으로 두고, bm의 남은 f code unit으로 둔다.
    4. ma, "."b의 문자열 연결로 설정한다.
    5. inta의 길이로 둔다.
  8. 그렇지 않으면,
    1. intm의 길이로 둔다.
  9. cutmaxFraction - minFraction으로 둔다.
  10. cut > 0이고 m의 마지막 code unit이 0x0030 (DIGIT ZERO)인 동안 반복한다.
    1. m에서 마지막 code unit을 제거한다.
    2. cutcut - 1로 설정한다.
  11. m의 마지막 code unit이 0x002E (FULL STOP)이면,
    1. m에서 마지막 code unit을 제거한다.
  12. Record { [[FormattedString]]: m, [[RoundedNumber]]: xFinal, [[IntegerDigitsCount]]: int, [[RoundingMagnitude]]: –f }를 반환한다.

16.5.10 UnwrapNumberFormat ( nf )

The abstract operation UnwrapNumberFormat takes argument nf (ECMAScript 언어 값) and returns ECMAScript 언어 값을 포함하는 정상 완료 또는 throw 완료. input object의 NumberFormat 인스턴스를 반환한다. 이는 값 자체이거나 4.3 Note 1의 규범적 선택 사항 constructor mode에 따라 %Intl.NumberFormat%에 의해 연결된 값이다. It performs the following steps when called:

  1. nf가 Object가 아니면 TypeError 예외를 던진다.
  2. nf[[InitializedNumberFormat]] 내부 슬롯을 가지지 않고 ? OrdinaryHasInstance(%Intl.NumberFormat%, nf)가 true이면,
    1. Get(nf, %Intl%.[[FallbackSymbol]])를 반환한다.
  3. nf를 반환한다.

16.5.11 GetNumberFormatPattern ( numberFormat, x )

The abstract operation GetNumberFormatPattern takes arguments numberFormat (Intl.NumberFormat) and x (Intl mathematical value) and returns String. number format object 안의 resolved unit-related options와 형식화되는 최종 scaled 및 rounded number(Intl mathematical value)를 함께 고려하고, 16.2.3에 설명된 String 값인 pattern을 반환한다. It performs the following steps when called:

  1. resolvedLocaleDatanumberFormat.[[LocaleData]]로 둔다.
  2. patternsresolvedLocaleData.[[patterns]]로 둔다.
  3. Assert: patternsRecord이다(16.2.3 참조).
  4. stylenumberFormat.[[Style]]로 둔다.
  5. style"percent"이면,
    1. patternspatterns.[[percent]]로 설정한다.
  6. 그렇지 않고 style"unit"이면,
    1. unitnumberFormat.[[Unit]]으로 둔다.
    2. unitDisplaynumberFormat.[[UnitDisplay]]로 둔다.
    3. patternspatterns.[[unit]]으로 설정한다.
    4. patterns가 [[<unit>]] 필드를 가지지 않으면,
      1. unit"fallback"으로 설정한다.
    5. patternspatterns.[[<unit>]]으로 설정한다.
    6. patternspatterns.[[<unitDisplay>]]로 설정한다.
  7. 그렇지 않고 style"currency"이면,
    1. currencynumberFormat.[[Currency]]로 둔다.
    2. currencyDisplaynumberFormat.[[CurrencyDisplay]]로 둔다.
    3. currencySignnumberFormat.[[CurrencySign]]으로 둔다.
    4. patternspatterns.[[currency]]로 설정한다.
    5. patterns가 [[<currency>]] 필드를 가지지 않으면,
      1. currency"fallback"으로 설정한다.
    6. patternspatterns.[[<currency>]]로 설정한다.
    7. patternspatterns.[[<currencyDisplay>]]로 설정한다.
    8. patternspatterns.[[<currencySign>]]으로 설정한다.
  8. 그렇지 않으면,
    1. Assert: style"decimal"이다.
    2. patternspatterns.[[decimal]]로 설정한다.
  9. xnegative-infinity이면,
    1. categorynegative-non-zero로 둔다.
  10. 그렇지 않고 xnegative-zero이면,
    1. categorynegative-zero로 둔다.
  11. 그렇지 않고 xnot-a-number이면,
    1. categorypositive-zero로 둔다.
  12. 그렇지 않고 xpositive-infinity이면,
    1. categorypositive-non-zero로 둔다.
  13. 그렇지 않으면,
    1. Assert: xmathematical value이다.
    2. x < 0이면,
      1. categorynegative-non-zero로 둔다.
    3. 그렇지 않고 x > 0이면,
      1. categorypositive-non-zero로 둔다.
    4. 그렇지 않으면,
      1. categorypositive-zero로 둔다.
  14. signDisplaynumberFormat.[[SignDisplay]]로 둔다.
  15. signDisplay"never"이면,
    1. patternpatterns.[[zeroPattern]]으로 둔다.
  16. 그렇지 않고 signDisplay"auto"이면,
    1. categorypositive-non-zero 또는 positive-zero이면,
      1. patternpatterns.[[zeroPattern]]으로 둔다.
    2. 그렇지 않으면,
      1. patternpatterns.[[negativePattern]]으로 둔다.
  17. 그렇지 않고 signDisplay"always"이면,
    1. categorypositive-non-zero 또는 positive-zero이면,
      1. patternpatterns.[[positivePattern]]으로 둔다.
    2. 그렇지 않으면,
      1. patternpatterns.[[negativePattern]]으로 둔다.
  18. 그렇지 않고 signDisplay"exceptZero"이면,
    1. categorypositive-zero 또는 negative-zero이면,
      1. patternpatterns.[[zeroPattern]]으로 둔다.
    2. 그렇지 않고 categorypositive-non-zero이면,
      1. patternpatterns.[[positivePattern]]으로 둔다.
    3. 그렇지 않으면,
      1. patternpatterns.[[negativePattern]]으로 둔다.
  19. 그렇지 않으면,
    1. Assert: signDisplay"negative"이다.
    2. categorynegative-non-zero이면,
      1. patternpatterns.[[negativePattern]]으로 둔다.
    3. 그렇지 않으면,
      1. patternpatterns.[[zeroPattern]]으로 둔다.
  20. pattern을 반환한다.

16.5.12 GetNotationSubPattern ( numberFormat, exponent )

The abstract operation GetNotationSubPattern takes arguments numberFormat (Intl.NumberFormat) and exponent (정수) and returns String. resolved notation과 exponent를 고려하고, 16.2.3에 설명된 notation sub pattern의 String 값을 반환한다. It performs the following steps when called:

  1. resolvedLocaleDatanumberFormat.[[LocaleData]]로 둔다.
  2. notationSubPatternsresolvedLocaleData.[[notationSubPatterns]]로 둔다.
  3. Assert: notationSubPatternsRecord이다(16.2.3 참조).
  4. notationnumberFormat.[[Notation]]으로 둔다.
  5. notation"scientific" 또는 notation"engineering"이면,
    1. notationSubPatterns.[[scientific]]을 반환한다.
  6. 그렇지 않고 exponent가 0이 아니면,
    1. Assert: notation"compact"이다.
    2. compactDisplaynumberFormat.[[CompactDisplay]]로 둔다.
    3. compactPatternsnotationSubPatterns.[[compact]].[[<compactDisplay>]]로 둔다.
    4. compactPatterns.[[<exponent>]]를 반환한다.
  7. 그렇지 않으면,
    1. "{number}"를 반환한다.

16.5.13 ComputeExponent ( numberFormat, x )

The abstract operation ComputeExponent takes arguments numberFormat (Intl.NumberFormat) and x (mathematical value) and returns 정수. number formatting settings에 따라 x를 scale할 exponent(power of ten)를 계산한다. 이는 999가 1000으로 반올림되어 다른 exponent가 필요한 경우를 처리한다. It performs the following steps when called:

  1. x = 0이면,
    1. 0을 반환한다.
  2. x < 0이면,
    1. x = -x로 둔다.
  3. magnitudefloor(log10(x))로 둔다.
  4. exponentComputeExponentForMagnitude(numberFormat, magnitude)로 둔다.
  5. xx × 10-exponent로 설정한다.
  6. formatNumberResultFormatNumericToString(numberFormat, x)로 둔다.
  7. formatNumberResult.[[RoundedNumber]] = 0이면,
    1. exponent를 반환한다.
  8. newMagnitudefloor(log10(formatNumberResult.[[RoundedNumber]]))로 둔다.
  9. newMagnitudemagnitude - exponent이면,
    1. exponent를 반환한다.
  10. ComputeExponentForMagnitude(numberFormat, magnitude + 1)를 반환한다.

16.5.14 ComputeExponentForMagnitude ( numberFormat, magnitude )

The abstract operation ComputeExponentForMagnitude takes arguments numberFormat (Intl.NumberFormat) and magnitude (정수) and returns 정수. locale 및 원하는 notation(scientific, engineering 또는 compact)에 따라 주어진 magnitude(most significant digit의 power of ten)를 가진 number를 scale할 exponent를 계산한다. It performs the following steps when called:

  1. notationnumberFormat.[[Notation]]으로 둔다.
  2. notation"standard"이면,
    1. 0을 반환한다.
  3. 그렇지 않고 notation"scientific"이면,
    1. magnitude를 반환한다.
  4. 그렇지 않고 notation"engineering"이면,
    1. thousandsmagnitude / 3보다 크지 않은 가장 큰 정수로 둔다.
    2. thousands × 3을 반환한다.
  5. 그렇지 않으면,
    1. Assert: notation"compact"이다.
    2. exponent를 current locale의 compact notation에서 주어진 magnitude의 number를 scale할 ILD 정수로 둔다.
    3. exponent를 반환한다.

16.5.15 Runtime Semantics: StringIntlMV

The syntax-directed operation StringIntlMV takes no arguments.

Note

StringNumericLiteral을 Number 값으로 변환하는 것은 전체적으로 NumericLiteralNumericValue 결정과 유사하지만(12.9.3 참조), 일부 세부 사항은 다르다.

It is defined piecewise over the following productions:

StringNumericLiteral ::: StrWhiteSpaceopt
  1. 0을 반환한다.
StringNumericLiteral ::: StrWhiteSpaceopt StrNumericLiteral StrWhiteSpaceopt
  1. StrNumericLiteralStringIntlMV를 반환한다.
StrNumericLiteral ::: NonDecimalIntegerLiteral
  1. NonDecimalIntegerLiteral의 MV를 반환한다.
StrDecimalLiteral ::: - StrUnsignedDecimalLiteral
  1. aStrUnsignedDecimalLiteralStringIntlMV로 둔다.
  2. a가 0이면 negative-zero를 반환한다.
  3. apositive-infinity이면 negative-infinity를 반환한다.
  4. -a를 반환한다.
StrUnsignedDecimalLiteral ::: Infinity
  1. positive-infinity를 반환한다.
StrUnsignedDecimalLiteral ::: DecimalDigits . DecimalDigitsopt ExponentPartopt
  1. a를 첫 번째 DecimalDigits의 MV로 둔다.
  2. 두 번째 DecimalDigits가 존재하면,
    1. b를 두 번째 DecimalDigits의 MV로 둔다.
    2. n을 두 번째 DecimalDigits 안의 code point 수로 둔다.
  3. 그렇지 않으면,
    1. b를 0으로 둔다.
    2. n을 0으로 둔다.
  4. ExponentPart가 존재하면 eExponentPart의 MV로 둔다. 그렇지 않으면 e를 0으로 둔다.
  5. (a + (b × 10-n)) × 10e를 반환한다.
StrUnsignedDecimalLiteral ::: . DecimalDigits ExponentPartopt
  1. bDecimalDigits의 MV로 둔다.
  2. ExponentPart가 존재하면 eExponentPart의 MV로 둔다. 그렇지 않으면 e를 0으로 둔다.
  3. nDecimalDigits 안의 code point 수로 둔다.
  4. b × 10e - n를 반환한다.
StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPartopt
  1. aDecimalDigits의 MV로 둔다.
  2. ExponentPart가 존재하면 eExponentPart의 MV로 둔다. 그렇지 않으면 e를 0으로 둔다.
  3. a × 10e를 반환한다.

16.5.16 ToIntlMathematicalValue ( value )

The abstract operation ToIntlMathematicalValue takes argument value (ECMAScript 언어 값) and returns Intl mathematical value를 포함하는 정상 완료 또는 throw 완료. valueIntl mathematical value로 변환하여 반환한다. 이는 mathematical valuepositive-infinity, negative-infinity, not-a-numbernegative-zero를 함께 포함한다. 이 추상 연산은 7.1.3과 유사하지만, exact decimal value를 나타낼 수 있도록 Number 또는 BigInt 대신 mathematical value를 반환할 수 있다. It performs the following steps when called:

  1. primValue를 ? ToPrimitive(value, number)로 둔다.
  2. primValue가 BigInt이면 (primValue)를 반환한다.
  3. primValue가 String이면,
    1. strprimValue로 둔다.
  4. 그렇지 않으면,
    1. x를 ? ToNumber(primValue)로 둔다.
    2. x-0𝔽이면 negative-zero를 반환한다.
    3. strNumber::toString(x, 10)으로 둔다.
  5. textStringToCodePoints(str)로 둔다.
  6. literalParseText(text, StringNumericLiteral)로 둔다.
  7. literal이 error의 List이면 not-a-number를 반환한다.
  8. intlMVliteralStringIntlMV로 둔다.
  9. intlMVmathematical value이면,
    1. roundedRoundMVResult(abs(intlMV))로 둔다.
    2. rounded+∞𝔽이고 intlMV < 0이면 negative-infinity를 반환한다.
    3. rounded+∞𝔽이면 positive-infinity를 반환한다.
    4. rounded+0𝔽이고 intlMV < 0이면 negative-zero를 반환한다.
    5. rounded+0𝔽이면 0을 반환한다.
  10. intlMV를 반환한다.

16.5.17 GetUnsignedRoundingMode ( roundingMode, sign )

The abstract operation GetUnsignedRoundingMode takes arguments roundingMode (rounding mode) and sign (negative 또는 positive) and returns Table 31의 Unsigned Rounding Mode 열에서 온 specification type. number의 절댓값에 적용했을 때 roundingMode가 number의 signed value에 적용되었을 때와 같은 결과를 생성하는 rounding mode를 반환한다(signnegative이면 negative, 그렇지 않으면 positive). It performs the following steps when called:

  1. Identifier 열의 값이 roundingMode이고 Sign 열의 값이 sign인 행에 대해, Table 31의 Unsigned Rounding Mode 열에 있는 specification type을 반환한다.
Table 31: rounding mode에서 unsigned rounding mode로의 변환
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, r1, r2, unsignedRoundingMode )

The abstract operation ApplyUnsignedRoundingMode takes arguments x (mathematical value), r1 (mathematical value), r2 (mathematical value), and unsignedRoundingMode (Table 31의 Unsigned Rounding Mode 열에서 온 specification type, 또는 undefined) and returns mathematical value. 아래쪽은 r1, 위쪽은 r2로 bracket된 x를 고려하고, unsignedRoundingMode에 따라 r1 또는 r2를 반환한다. It performs the following steps when called:

  1. xr1이면 r1을 반환한다.
  2. Assert: r1 < x < r2이다.
  3. Assert: unsignedRoundingModeundefined가 아니다.
  4. unsignedRoundingModezero이면 r1을 반환한다.
  5. unsignedRoundingModeinfinity이면 r2를 반환한다.
  6. d1xr1로 둔다.
  7. d2r2x로 둔다.
  8. d1 < d2이면 r1을 반환한다.
  9. d2 < d1이면 r2를 반환한다.
  10. Assert: d1d2이다.
  11. unsignedRoundingModehalf-zero이면 r1을 반환한다.
  12. unsignedRoundingModehalf-infinity이면 r2를 반환한다.
  13. Assert: unsignedRoundingModehalf-even이다.
  14. cardinality(r1 / (r2r1)) modulo 2로 둔다.
  15. cardinality가 0이면 r1을 반환한다.
  16. r2를 반환한다.

16.5.19 PartitionNumberRangePattern ( numberFormat, x, y )

The abstract operation PartitionNumberRangePattern takes arguments numberFormat (Intl.NumberFormat), x (Intl mathematical value), and y (Intl mathematical value) and returns [[Type]](String), [[Value]](String) 및 [[Source]](String) 필드를 가진 RecordList를 포함하는 정상 완료 또는 throw 완료. x, ynumberFormat의 formatting options에 따라 localized number range의 parts를 생성한다. It performs the following steps when called:

  1. xnot-a-number 또는 ynot-a-number이면 RangeError 예외를 던진다.
  2. xResultPartitionNumberPattern(numberFormat, x)로 둔다.
  3. yResultPartitionNumberPattern(numberFormat, y)로 둔다.
  4. FormatNumeric(numberFormat, x)가 FormatNumeric(numberFormat, y)이면,
    1. approximateResultFormatApproximately(numberFormat, xResult)로 둔다.
    2. approximateResult의 각 요소 part에 대해, 다음을 수행한다.
      1. part.[[Source]]"shared"로 설정한다.
    3. approximateResult를 반환한다.
  5. result를 새 빈 List로 둔다.
  6. xResult의 각 요소 part에 대해, 다음을 수행한다.
    1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Source]]: "startRange" }를 result에 append한다.
  7. rangeSeparator를 두 number를 분리하는 데 사용되는 ILND String 값으로 둔다.
  8. Record { [[Type]]: "literal", [[Value]]: rangeSeparator, [[Source]]: "shared" }를 result에 append한다.
  9. yResult의 각 요소 part에 대해, 다음을 수행한다.
    1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Source]]: "endRange" }를 result에 append한다.
  10. CollapseNumberRange(numberFormat, result)를 반환한다.

16.5.20 FormatApproximately ( numberFormat, result )

The abstract operation FormatApproximately takes arguments numberFormat (Intl.NumberFormat) and result ([[Type]](String) 및 [[Value]](String) 필드를 가진 RecordList) and returns [[Type]](String) 및 [[Value]](String) 필드를 가진 RecordList. PartitionNumberPattern에 설명된 Record 값의 List여야 하는 result를 수정하여 approximately sign에 대한 새 Record를 추가한다. 이는 numberFormat에 의존할 수 있다. It performs the following steps when called:

  1. approximatelySign을 number가 approximate임을 나타내는 데 사용되는 ILND String 값으로 둔다.
  2. approximatelySign이 비어 있지 않으면, Record { [[Type]]: "approximatelySign", [[Value]]: approximatelySign }를 resultILND index에 삽입한다. 예를 들어 numberFormat[[Locale]] "en-US", [[NumberingSystem]] "latn"[[Style]] "decimal"을 가지면, 새 Recordresult의 첫 번째 요소 앞에 삽입될 수 있다.
  3. result를 반환한다.

16.5.21 CollapseNumberRange ( numberFormat, result )

The implementation-defined abstract operation CollapseNumberRange takes arguments numberFormat (Intl.NumberFormat) and result ([[Type]](String), [[Value]](String) 및 [[Source]](String) 필드를 가진 RecordList) and returns [[Type]](String), [[Value]](String) 및 [[Source]](String) 필드를 가진 RecordList. result(PartitionNumberRangePattern 안에서 구성된 RecordList여야 함)를 numberFormat의 유효 locale 및 formatting options에 따라 수정한다. redundant information을 제거하고, internal inconsistency를 resolve하며, 필요하면 character를 대체하고, 필요하면 spacing을 삽입한다. 그런 다음 결과 List를 반환한다. 알고리즘은 ILND이지만, CollapseNumberRange의 trivial implementation이 항상 result를 수정 없이 반환할 때 같은 인수 List에 대한 결과가 같지 않을 경우, Intl.NumberFormat.prototype.formatRange ( start, end )의 인수 List « start1, end1 »에 대한 결과가 인수 List « start2, end2 »에 대한 결과와 같아지게 하는 ambiguity를 도입해서는 안 된다.

예를 들어, 구현은 range separator 뒤의 currency symbol을 나타내는 Record를 제거하여 "$3–$5"를 나타내는 results List"$3–5"를 나타내는 List로 변환할 수 있다.

구현은 grammatical correctness를 위해 Record [[Value]] 필드를 수정할 수도 있다. 예를 들어 "0.5 miles–1 mile"을 나타내는 results List"0.5–1 miles"를 나타내는 List로 변환할 수 있다.

result를 수정 없이 반환하는 것은 CollapseNumberRange의 올바른 구현임이 보장된다.

16.5.22 FormatNumericRange ( numberFormat, x, y )

The abstract operation FormatNumericRange takes arguments numberFormat (Intl.NumberFormat), x (Intl mathematical value), and y (Intl mathematical value) and returns String을 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. parts를 ? PartitionNumberRangePattern(numberFormat, x, y)로 둔다.
  2. result를 빈 String으로 둔다.
  3. parts의 각 요소 part에 대해, 다음을 수행한다.
    1. resultresultpart.[[Value]]의 문자열 연결로 설정한다.
  4. result를 반환한다.

16.5.23 FormatNumericRangeToParts ( numberFormat, x, y )

The abstract operation FormatNumericRangeToParts takes arguments numberFormat (Intl.NumberFormat), x (Intl mathematical value), and y (Intl mathematical value) and returns Array를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. parts를 ? PartitionNumberRangePattern(numberFormat, x, y)로 둔다.
  2. result를 ! ArrayCreate(0)으로 둔다.
  3. n을 0으로 둔다.
  4. parts의 각 요소 part에 대해, 다음을 수행한다.
    1. partObjOrdinaryObjectCreate(%Object.prototype%)로 둔다.
    2. CreateDataPropertyOrThrow(partObj, "type", part.[[Type]])를 수행한다.
    3. CreateDataPropertyOrThrow(partObj, "value", part.[[Value]])를 수행한다.
    4. CreateDataPropertyOrThrow(partObj, "source", part.[[Source]])를 수행한다.
    5. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), partObj)를 수행한다.
    6. nn + 1로 설정한다.
  5. result를 반환한다.

17 PluralRules 객체

17.1 Intl.PluralRules 생성자

Intl.PluralRules 생성자는:

  • %Intl.PluralRules%이다.
  • Intl 객체"PluralRules" 속성의 초기값이다.

Intl 객체의 모든 서비스 생성자 속성에 공통인 동작은 9.1에 명시되어 있다.

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

Intl.PluralRules 함수가 선택적 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. NewTarget이 undefined이면 TypeError 예외를 던진다.
  2. pluralRules를 ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.PluralRules.prototype%", « [[InitializedPluralRules]], [[Locale]], [[Type]], [[Notation]], [[CompactDisplay]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[RoundingType]], [[RoundingIncrement]], [[RoundingMode]], [[ComputedRoundingPriority]], [[TrailingZeroDisplay]] »)로 둔다.
  3. optionsResolution을 ? ResolveOptions(%Intl.PluralRules%, %Intl.PluralRules%.[[LocaleData]], locales, options, « coerce-options »)로 둔다.
  4. optionsoptionsResolution.[[Options]]로 설정한다.
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]]로 둔다.
  6. pluralRules.[[Locale]]resolvedLocale.[[Locale]]로 설정한다.
  7. type을 ? GetOption(options, "type", string, « "cardinal", "ordinal" », "cardinal")로 둔다.
  8. pluralRules.[[Type]]type으로 설정한다.
  9. notation을 ? GetOption(options, "notation", string, « "standard", "scientific", "engineering", "compact" », "standard")로 둔다.
  10. pluralRules.[[Notation]]notation으로 설정한다.
  11. compactDisplay를 ? GetOption(options, "compactDisplay", string, « "short", "long" », "short")로 둔다.
  12. notation"compact"이면,
    1. pluralRules.[[CompactDisplay]]compactDisplay로 설정한다.
  13. SetNumberFormatDigitOptions(pluralRules, options, 0, 3, notation)를 수행한다.
  14. pluralRules를 반환한다.

17.2 Intl.PluralRules 생성자의 속성

Intl.PluralRules 생성자는:

  • 값이 %Function.prototype%[[Prototype]] 내부 슬롯을 가진다.
  • 다음 속성을 가진다:

17.2.1 Intl.PluralRules.prototype

Intl.PluralRules.prototype의 값은 %Intl.PluralRules.prototype%이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } 속성을 가진다.

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

supportedLocalesOf 메서드가 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. availableLocales%Intl.PluralRules%.[[AvailableLocales]]로 둔다.
  2. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  3. FilterLocales(availableLocales, requestedLocales, options)를 반환한다.

17.2.3 내부 슬롯

[[AvailableLocales]] 내부 슬롯의 값은 9.1에 설명된 제약 안에서 구현 정의이다.

[[RelevantExtensionKeys]] 내부 슬롯의 값은 « »이다.

[[ResolutionOptionDescriptors]] 내부 슬롯의 값은 « »이다.

Note 1
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions는 pluralization process와 관련된 locale extension key를 설명하지 않는다.

[[LocaleData]] 내부 슬롯의 값은 9.1에 설명된 제약 안에서 구현 정의이다.

Note 2
구현은 Common Locale Data Repository(https://cldr.unicode.org/에서 이용 가능)가 제공하는 locale 데이터를 사용하는 것이 권장된다.

17.3 Intl.PluralRules Prototype 객체의 속성

Intl.PluralRules prototype 객체는:

  • %Intl.PluralRules.prototype%이다.
  • ordinary 객체이다.
  • Intl.PluralRules 인스턴스가 아니며 [[InitializedPluralRules]] 내부 슬롯 또는 Intl.PluralRules 인스턴스 객체의 다른 내부 슬롯을 가지지 않는다.
  • 값이 %Object.prototype%[[Prototype]] 내부 슬롯을 가진다.

17.3.1 Intl.PluralRules.prototype.constructor

Intl.PluralRules.prototype.constructor의 초기값은 %Intl.PluralRules%이다.

17.3.2 Intl.PluralRules.prototype.resolvedOptions ( )

이 함수는 객체 초기화 중 계산된 locale 및 options에 대한 접근을 제공한다.

  1. prthis 값으로 둔다.
  2. RequireInternalSlot(pr, [[InitializedPluralRules]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  4. pluralCategories를 선택된 locale pr.[[Locale]]에 대해 PluralRuleSelect의 가능한 모든 결과를 포함하는 String의 List로 둔다. 이는 다음 순서에 따라 정렬된다: "zero", "one", "two", "few", "many", "other".
  5. Table 32의 각 행에 대해, 헤더 행을 제외하고 표 순서대로, 다음을 수행한다.
    1. propertyKey를 현재 행의 Property 값으로 둔다.
    2. propertyKey"pluralCategories"이면,
      1. valueCreateArrayFromList(pluralCategories)로 둔다.
    3. 그렇지 않으면,
      1. value를 현재 행의 Internal Slot 값이 이름인 pr의 내부 슬롯 값으로 둔다.
    4. valueundefined가 아니면,
      1. 현재 행에 Conversion 값이 있으면,
        1. Assert: 현재 행의 Conversion 값은 number이다.
        2. value𝔽(value)로 설정한다.
      2. CreateDataPropertyOrThrow(options, propertyKey, value)를 수행한다.
  6. options를 반환한다.
Table 32: PluralRules 인스턴스의 Resolved Options
Internal Slot Property Conversion
[[Locale]] "locale"
[[Type]] "type"
[[Notation]] "notation"
[[CompactDisplay]] "compactDisplay"
[[MinimumIntegerDigits]] "minimumIntegerDigits" number
[[MinimumFractionDigits]] "minimumFractionDigits" number
[[MaximumFractionDigits]] "maximumFractionDigits" number
[[MinimumSignificantDigits]] "minimumSignificantDigits" number
[[MaximumSignificantDigits]] "maximumSignificantDigits" number
"pluralCategories"
[[RoundingIncrement]] "roundingIncrement" number
[[RoundingMode]] "roundingMode"
[[ComputedRoundingPriority]] "roundingPriority"
[[TrailingZeroDisplay]] "trailingZeroDisplay"

17.3.3 Intl.PluralRules.prototype.select ( value )

select 메서드가 인수 value와 함께 호출되면 다음 단계가 수행된다:

  1. prthis 값으로 둔다.
  2. RequireInternalSlot(pr, [[InitializedPluralRules]])를 수행한다.
  3. n을 ? ToIntlMathematicalValue(value)로 둔다.
  4. ResolvePlural(pr, n).[[PluralCategory]]를 반환한다.

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

selectRange 메서드가 인수 startend와 함께 호출되면 다음 단계가 수행된다:

  1. prthis 값으로 둔다.
  2. RequireInternalSlot(pr, [[InitializedPluralRules]])를 수행한다.
  3. startundefined이거나 endundefined이면 TypeError 예외를 던진다.
  4. x를 ? ToIntlMathematicalValue(start)로 둔다.
  5. y를 ? ToIntlMathematicalValue(end)로 둔다.
  6. ResolvePluralRange(pr, x, y)를 반환한다.

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

%Symbol.toStringTag% 속성의 초기값은 String 값 "Intl.PluralRules"이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } 속성을 가진다.

17.4 Intl.PluralRules 인스턴스의 속성

Intl.PluralRules 인스턴스는 %Intl.PluralRules.prototype%에서 속성을 상속하는 ordinary 객체이다.

Intl.PluralRules 인스턴스는 [[InitializedPluralRules]] 내부 슬롯을 가진다.

Intl.PluralRules 인스턴스는 또한 Intl.PluralRules 생성자에 의해 계산되는 여러 내부 슬롯을 가진다:

  • [[Locale]]은 plural rules가 사용하는 localization의 locale 언어 태그를 가진 String 값이다.
  • [[Type]]은 사용되는 plural rules를 식별하는 String 값 "cardinal" 또는 "ordinal" 중 하나이다.
  • [[Notation]]은 사용되는 notation을 식별하는 String 값 "standard", "scientific", "engineering" 또는 "compact" 중 하나이다.
  • [[CompactDisplay]]는 compact notation affix를 short form("5K") 또는 long form("5 thousand")으로 표시할지 지정하는 "short", "long" 또는 undefined 중 하나이며, 이는 경우에 따라 plural form 선택에 영향을 줄 수 있다. [[Notation]]"compact" 이외의 값을 가질 때 그리고 그때에만 undefined이다.
  • [[MinimumIntegerDigits]]는 사용할 최소 integer digits를 나타내는 non-negative integer이다.
  • [[MinimumFractionDigits]][[MaximumFractionDigits]]는 사용할 최소 및 최대 fraction digits를 나타내는 non-negative integer이다. 필요하면 number는 반올림되거나 trailing zero로 padding된다.
  • [[MinimumSignificantDigits]][[MaximumSignificantDigits]]는 사용할 최소 및 최대 fraction digits를 나타내는 positive integer이다. 이러한 속성은 없거나 둘 다 존재한다. 존재하면 minimum 및 maximum integer와 fraction digits를 override한다.
  • [[RoundingType]]은 어떤 rounding strategy를 사용할지 나타내는 fraction-digits, significant-digits, more-precision 또는 less-precision 중 하나의 값이며, 16.4에서 논의된 바와 같다.
  • [[ComputedRoundingPriority]]는 String 값 "auto", "morePrecision" 또는 "lessPrecision" 중 하나이다. 이는 [[RoundingType]]을 유효한 "roundingPriority" option으로 다시 변환하기 위해 17.3.2에서만 사용된다.
  • [[RoundingIncrement]]는 10, 100, 1000 또는 10000을 tenths, fifths, quarters 또는 halves로 균등하게 나누는 정수이다. 이는 계산된 rounding magnitude를 기준으로 rounding이 이루어져야 하는 increment를 나타낸다. 예를 들어 [[MaximumFractionDigits]]가 2이고 [[RoundingIncrement]]가 5이면 formatted number는 가장 가까운 0.05로 반올림된다("nickel rounding").
  • [[RoundingMode]]는 사용할 rounding mode를 식별한다.
  • [[TrailingZeroDisplay]]는 formatted number가 integer인 경우(즉, non-zero fraction digit를 가지지 않는 경우) trailing zero를 제거할지 여부를 나타내는 String 값 "auto" 또는 "stripIfInteger" 중 하나이다.

17.5 PluralRules 객체를 위한 추상 연산

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

The implementation-defined abstract operation PluralRuleSelect takes arguments locale (language tag), type ("cardinal" 또는 "ordinal"), notation (String), compactDisplay ("short" 또는 "long"), and decimalString (decimal String) and returns "zero", "one", "two", "few", "many" 또는 "other". 반환된 String은 대응하는 locale에 대해 type, notationcompactDisplay에 따라 decimalString의 plural category를 특징짓는다.

17.5.2 ResolvePlural ( pluralRules, n )

The abstract operation ResolvePlural takes arguments pluralRules (Intl.PluralRules) and n (Intl mathematical value) and returns [[PluralCategory]]("zero", "one", "two", "few", "many" 또는 "other") 및 [[FormattedString]](String) 필드를 가진 Record. 반환된 RecordpluralRules의 유효 locale 및 내부 슬롯에 따라 n을 설명하는 두 string-valued 필드를 포함한다: [[PluralCategory]]는 그 plural category를 특징짓고, [[FormattedString]]은 그 formatted representation을 포함한다. It performs the following steps when called:

  1. nnot-a-number이면,
    1. formattedStringNaN 값을 나타내는 ILD String 값으로 둔다.
    2. Record { [[PluralCategory]]: "other", [[FormattedString]]: formattedString }를 반환한다.
  2. npositive-infinity이면,
    1. formattedString을 positive infinity를 나타내는 ILD String 값으로 둔다.
    2. Record { [[PluralCategory]]: "other", [[FormattedString]]: formattedString }를 반환한다.
  3. nnegative-infinity이면,
    1. formattedString을 negative infinity를 나타내는 ILD String 값으로 둔다.
    2. Record { [[PluralCategory]]: "other", [[FormattedString]]: formattedString }를 반환한다.
  4. resFormatNumericToString(pluralRules, n)로 둔다.
  5. formattedStringres.[[FormattedString]]로 둔다.
  6. localepluralRules.[[Locale]]로 둔다.
  7. typepluralRules.[[Type]]으로 둔다.
  8. notationpluralRules.[[Notation]]으로 둔다.
  9. compactDisplaypluralRules.[[CompactDisplay]]로 둔다.
  10. pluralCategoryPluralRuleSelect(locale, type, notation, compactDisplay, formattedString)로 둔다.
  11. Record { [[PluralCategory]]: pluralCategory, [[FormattedString]]: formattedString }를 반환한다.

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

The implementation-defined abstract operation PluralRuleSelectRange takes arguments locale (language tag), type ("cardinal" 또는 "ordinal"), notation (String), compactDisplay ("short" 또는 "long"), xp ("zero", "one", "two", "few", "many" 또는 "other"), and yp ("zero", "one", "two", "few", "many" 또는 "other") and returns "zero", "one", "two", "few", "many" 또는 "other". 범위의 시작과 끝을 각각 특징짓는 plural category String 값 xpyp를 대응하는 locale에 대해 type, notationcompactDisplay가 나타내는 범위 전체의 plural form에 대한 resolved String 값 또는 String 값 "other"로 매핑하는 구현 의존 알고리즘을 수행한다.

17.5.4 ResolvePluralRange ( pluralRules, x, y )

The abstract operation ResolvePluralRange takes arguments pluralRules (Intl.PluralRules), x (Intl mathematical value), and y (Intl mathematical value) and returns "zero", "one", "two", "few", "many" 또는 "other" 중 하나를 포함하는 정상 완료 또는 throw 완료. 반환된 String 값은 pluralRules의 유효 locale 및 내부 슬롯에 따라 x에서 시작하여 y에서 끝나는 범위의 plural form을 나타낸다. It performs the following steps when called:

  1. xnot-a-number 또는 ynot-a-number이면 RangeError 예외를 던진다.
  2. xResultResolvePlural(pluralRules, x)로 둔다.
  3. yResultResolvePlural(pluralRules, y)로 둔다.
  4. xResult.[[FormattedString]]yResult.[[FormattedString]]이면,
    1. xResult.[[PluralCategory]]를 반환한다.
  5. localepluralRules.[[Locale]]로 둔다.
  6. typepluralRules.[[Type]]으로 둔다.
  7. notationpluralRules.[[Notation]]으로 둔다.
  8. compactDisplaypluralRules.[[CompactDisplay]]로 둔다.
  9. PluralRuleSelectRange(locale, type, notation, compactDisplay, xResult.[[PluralCategory]], yResult.[[PluralCategory]])를 반환한다.

18 RelativeTimeFormat 객체

18.1 Intl.RelativeTimeFormat 생성자

Intl.RelativeTimeFormat 생성자는:

  • %Intl.RelativeTimeFormat%이다.
  • Intl 객체"RelativeTimeFormat" 속성의 초기값이다.

Intl 객체의 모든 서비스 생성자 속성에 공통되는 동작은 9.1에 명시되어 있다.

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

Intl.RelativeTimeFormat 함수가 선택적 인수 localesoptions로 호출되면, 다음 단계가 수행된다:

  1. NewTarget이 undefined이면, TypeError 예외를 던진다.
  2. relativeTimeFormat을 ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.RelativeTimeFormat.prototype%", « [[InitializedRelativeTimeFormat]], [[Locale]], [[LocaleData]], [[Style]], [[Numeric]], [[NumberFormat]], [[NumberingSystem]], [[PluralRules]] »)로 둔다.
  3. optionsResolution을 ? ResolveOptions(%Intl.RelativeTimeFormat%, %Intl.RelativeTimeFormat%.[[LocaleData]], locales, options, « coerce-options »)로 둔다.
  4. optionsoptionsResolution.[[Options]]로 설정한다.
  5. resolvedLocaleoptionsResolution.[[ResolvedLocale]]로 둔다.
  6. localeresolvedLocale.[[Locale]]로 둔다.
  7. relativeTimeFormat.[[Locale]]locale로 설정한다.
  8. relativeTimeFormat.[[LocaleData]]resolvedLocale.[[LocaleData]]로 설정한다.
  9. relativeTimeFormat.[[NumberingSystem]]resolvedLocale.[[nu]]로 설정한다.
  10. style을 ? GetOption(options, "style", string, « "long", "short", "narrow" », "long")로 둔다.
  11. relativeTimeFormat.[[Style]]style로 설정한다.
  12. numeric을 ? GetOption(options, "numeric", string, « "always", "auto" », "always")로 둔다.
  13. relativeTimeFormat.[[Numeric]]numeric으로 설정한다.
  14. nfOptionsOrdinaryObjectCreate(null)로 둔다.
  15. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", relativeTimeFormat.[[NumberingSystem]])를 수행한다.
  16. relativeTimeFormat.[[NumberFormat]]을 ! Construct(%Intl.NumberFormat%, « locale, nfOptions »)로 둔다.
  17. relativeTimeFormat.[[PluralRules]]를 ! Construct(%Intl.PluralRules%, « locale »)로 둔다.
  18. relativeTimeFormat을 반환한다.

18.2 Intl.RelativeTimeFormat 생성자의 속성

Intl.RelativeTimeFormat 생성자는:

  • 값이 %Function.prototype%[[Prototype]] 내부 슬롯을 가진다.
  • 다음 속성을 가진다:

18.2.1 Intl.RelativeTimeFormat.prototype

Intl.RelativeTimeFormat.prototype의 값은 %Intl.RelativeTimeFormat.prototype%이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } 특성을 가진다.

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

supportedLocalesOf 메서드가 인수 localesoptions로 호출되면, 다음 단계가 수행된다:

  1. availableLocales%Intl.RelativeTimeFormat%.[[AvailableLocales]]로 둔다.
  2. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  3. FilterLocales(availableLocales, requestedLocales, options)를 반환한다.

18.2.3 내부 슬롯

[[AvailableLocales]] 내부 슬롯의 값은 9.1에 설명된 제약 조건 내에서 구현 정의이다.

[[RelevantExtensionKeys]] 내부 슬롯의 값은 « "nu" »이다.

[[ResolutionOptionDescriptors]] 내부 슬롯의 값은 « { [[Key]]: "nu", [[Property]]: "numberingSystem" } »이다.

Note 1
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions는 상대 시간 형식 지정과 관련된 하나의 locale 확장 키를 설명한다: numbering system(형식화된 숫자의)에 대한 "nu".

[[LocaleData]] 내부 슬롯의 값은 9.1에 설명된 제약 조건 및 다음 추가 제약 조건 내에서, 모든 locale 값 locale에 대해 구현 정의이다:

  • [[LocaleData]].[[<locale>]]는 "second", "minute", "hour", "day", "week", "month", "quarter", 그리고 "year" 필드를 가진다. 이전 이름들과 문자열 "-narrow" 또는 "-short"를 연결한 이름의 추가 필드가 존재할 수 있다. 이러한 필드에 대응하는 값은 다음 두 범주의 필드를 포함하는 Record이다:
    • "future""past" 필드. 이는 locale에 관련된 각 plural category에 대한 필드를 가진 Record이다. 해당 필드에 대응하는 값은 형식화된 숫자로 대체될 "{0}"을 포함할 수 있는 pattern이다.
    • 선택적으로, key가 Number의 ToString 결과이고 값은 template으로 취급되지 않는 literal String인 추가 필드.
  • [[LocaleData]]의 어떤 locale 필드의 "nu" 필드 값인 List"native", "traditio", 또는 "finance" 값을 포함해서는 안 된다.
Note 2
구현은 Common Locale Data Repository(https://cldr.unicode.org/에서 이용 가능)가 제공하는 locale data를 사용하는 것이 권장된다.

18.3 Intl.RelativeTimeFormat 프로토타입 객체의 속성

Intl.RelativeTimeFormat 프로토타입 객체는:

  • %Intl.RelativeTimeFormat.prototype%이다.
  • 일반 객체이다.
  • Intl.RelativeTimeFormat 인스턴스가 아니며 [[InitializedRelativeTimeFormat]] 내부 슬롯이나 Intl.RelativeTimeFormat 인스턴스 객체의 다른 내부 슬롯을 가지지 않는다.
  • 값이 %Object.prototype%[[Prototype]] 내부 슬롯을 가진다.

18.3.1 Intl.RelativeTimeFormat.prototype.constructor

Intl.RelativeTimeFormat.prototype.constructor의 초기값은 %Intl.RelativeTimeFormat%이다.

18.3.2 Intl.RelativeTimeFormat.prototype.resolvedOptions ( )

이 함수는 객체의 초기화 중에 계산된 locale 및 option에 대한 접근을 제공한다.

  1. relativeTimeFormatthis 값으로 둔다.
  2. RequireInternalSlot(relativeTimeFormat, [[InitializedRelativeTimeFormat]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  4. Table 33의 각 행에 대해, 헤더 행은 제외하고 표 순서대로, 다음을 수행한다.
    1. propertyKey를 현재 행의 Property 값으로 둔다.
    2. value를, 그 이름이 현재 행의 Internal Slot 값인 relativeTimeFormat의 내부 슬롯 값으로 둔다.
    3. 단언: valueundefined가 아니다.
    4. CreateDataPropertyOrThrow(options, propertyKey, value)를 수행한다.
  5. options를 반환한다.
Table 33: RelativeTimeFormat 인스턴스의 Resolved Options
Internal Slot Property
[[Locale]] "locale"
[[Style]] "style"
[[Numeric]] "numeric"
[[NumberingSystem]] "numberingSystem"

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

format 메서드가 인수 valueunit으로 호출되면, 다음 단계가 수행된다:

  1. relativeTimeFormatthis 값으로 둔다.
  2. RequireInternalSlot(relativeTimeFormat, [[InitializedRelativeTimeFormat]])를 수행한다.
  3. value를 ? ToNumber(value)로 설정한다.
  4. unit을 ? ToString(unit)으로 설정한다.
  5. FormatRelativeTime(relativeTimeFormat, value, unit)를 반환한다.

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

formatToParts 메서드가 인수 valueunit으로 호출되면, 다음 단계가 수행된다:

  1. relativeTimeFormatthis 값으로 둔다.
  2. RequireInternalSlot(relativeTimeFormat, [[InitializedRelativeTimeFormat]])를 수행한다.
  3. value를 ? ToNumber(value)로 설정한다.
  4. unit을 ? ToString(unit)으로 설정한다.
  5. FormatRelativeTimeToParts(relativeTimeFormat, value, unit)를 반환한다.

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

%Symbol.toStringTag% 속성의 초기값은 String 값 "Intl.RelativeTimeFormat"이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } 특성을 가진다.

18.4 Intl.RelativeTimeFormat 인스턴스의 속성

Intl.RelativeTimeFormat 인스턴스는 %Intl.RelativeTimeFormat.prototype%에서 속성을 상속하는 일반 객체이다.

Intl.RelativeTimeFormat 인스턴스는 [[InitializedRelativeTimeFormat]] 내부 슬롯을 가진다.

Intl.RelativeTimeFormat 인스턴스는 또한 Intl.RelativeTimeFormat 생성자에 의해 계산되는 여러 내부 슬롯을 가진다:

  • [[Locale]]은 형식 지정에 사용되는 현지화의 locale에 대한 language tag를 가진 String 값이다.
  • [[LocaleData]]는 형식 지정에 대해 구현이 사용할 수 있는 data를 나타내는 Record이다. 이는 [[Locale]] 값 또는 그 접두사 중 하나와 연관된 %Intl.RelativeTimeFormat%.[[LocaleData]]의 항목 값이다.
  • [[Style]]은 사용되는 상대 시간 형식 style을 식별하는 String 값 "long", "short", 또는 "narrow" 중 하나이다.
  • [[Numeric]]은 수치 설명이 항상 사용되는지, 또는 더 구체적인 버전을 사용할 수 없을 때에만 사용되는지(예: "1일 전" vs "어제")를 식별하는 String 값 "always" 또는 "auto" 중 하나이다.
  • [[NumberFormat]]은 형식 지정에 사용되는 Intl.NumberFormat 객체이다.
  • [[NumberingSystem]]은 형식 지정에 사용되는 Unicode Number System Identifier를 나타내는 String 값이다.
  • [[PluralRules]]은 형식 지정에 사용되는 Intl.PluralRules 객체이다.

18.5 RelativeTimeFormat 객체를 위한 추상 연산

18.5.1 SingularRelativeTimeUnit ( unit )

The abstract operation SingularRelativeTimeUnit takes argument unit (String) and returns String을 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. unit"seconds"이면, "second"를 반환한다.
  2. unit"minutes"이면, "minute"를 반환한다.
  3. unit"hours"이면, "hour"를 반환한다.
  4. unit"days"이면, "day"를 반환한다.
  5. unit"weeks"이면, "week"를 반환한다.
  6. unit"months"이면, "month"를 반환한다.
  7. unit"quarters"이면, "quarter"를 반환한다.
  8. unit"years"이면, "year"를 반환한다.
  9. unit"second", "minute", "hour", "day", "week", "month", "quarter", 또는 "year" 중 하나가 아니면, RangeError 예외를 던진다.
  10. unit을 반환한다.

18.5.2 PartitionRelativeTimePattern ( relativeTimeFormat, value, unit )

The abstract operation PartitionRelativeTimePattern takes arguments relativeTimeFormat (Intl.RelativeTimeFormat), value (Number), and unit (String) and returns [[Type]](String), [[Value]](String), 그리고 [[Unit]](String 또는 empty) 필드를 가진 RecordsList를 포함하는 정상 완료, 또는 throw 완료. It performs the following steps when called:

  1. valueNaN, +∞𝔽, 또는 -∞𝔽이면, RangeError 예외를 던진다.
  2. unit을 ? SingularRelativeTimeUnit(unit)으로 설정한다.
  3. fieldsrelativeTimeFormat.[[LocaleData]]로 둔다.
  4. patternsfields.[[<unit>]]로 둔다.
  5. stylerelativeTimeFormat.[[Style]]로 둔다.
  6. style"short" 또는 "narrow"이면,
    1. keyunit, "-", 그리고 style의 문자열 연결로 둔다.
    2. fields에 [[<key>]] 필드가 있으면, patternsfields.[[<key>]]로 설정한다.
  7. relativeTimeFormat.[[Numeric]]"auto"이면,
    1. valueString을 ! ToString(value)로 둔다.
    2. patterns에 [[<valueString>]] 필드가 있으면,
      1. resultpatterns.[[<valueString>]]로 둔다.
      2. Record { [[Type]]: "literal", [[Value]]: result, [[Unit]]: empty }를 포함하는 List를 반환한다.
  8. value-0𝔽이거나 value < -0𝔽이면,
    1. tense"past"로 둔다.
  9. 그렇지 않으면,
    1. tense"future"로 둔다.
  10. tensePatternspatterns.[[<tense>]]로 둔다.
  11. formattedValuePartitionNumberPattern(relativeTimeFormat.[[NumberFormat]], (value))로 둔다.
  12. pluralCategoryResolvePlural(relativeTimeFormat.[[PluralRules]], value).[[PluralCategory]]로 둔다.
  13. patterntensePatterns.[[<pluralCategory>]]로 둔다.
  14. MakePartsList(pattern, unit, formattedValue)를 반환한다.

18.5.3 MakePartsList ( pattern, unit, parts )

The abstract operation MakePartsList takes arguments pattern (Pattern String), unit (String), and parts (형식화된 Number를 나타내는 RecordsList) and returns [[Type]](String), [[Value]](String), 그리고 [[Unit]](String 또는 empty) 필드를 가진 RecordsList. It performs the following steps when called:

  1. patternPartsPartitionPattern(pattern)으로 둔다.
  2. result를 새 빈 List로 둔다.
  3. patternParts의 각 Record { [[Type]], [[Value]] } patternPart에 대해, 다음을 수행한다.
    1. patternPart.[[Type]]"literal"이면,
      1. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]], [[Unit]]: empty }를 result에 추가한다.
    2. 그렇지 않으면,
      1. 단언: patternPart.[[Type]]"0"이다.
      2. parts의 각 Record { [[Type]], [[Value]] } part에 대해, 다음을 수행한다.
        1. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: unit }를 result에 추가한다.
  4. result를 반환한다.
Note
예:
  1. MakePartsList("AA{0}BB", "hour", « Record { [[Type]]: "integer", [[Value]]: "15" } »)를 반환한다.
이는 다음과 같은 RecordsList를 반환할 것이다. « { [[Type]]: "literal", [[Value]]: "AA", [[Unit]]: empty}, { [[Type]]: "integer", [[Value]]: "15", [[Unit]]: "hour"}, { [[Type]]: "literal", [[Value]]: "BB", [[Unit]]: empty} »

18.5.4 FormatRelativeTime ( relativeTimeFormat, value, unit )

The abstract operation FormatRelativeTime takes arguments relativeTimeFormat (Intl.RelativeTimeFormat), value (Number), and unit (String) and returns String을 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. parts를 ? PartitionRelativeTimePattern(relativeTimeFormat, value, unit)로 둔다.
  2. result를 빈 String으로 둔다.
  3. parts의 각 Record { [[Type]], [[Value]], [[Unit]] } part에 대해, 다음을 수행한다.
    1. resultresultpart.[[Value]]의 문자열 연결로 설정한다.
  4. result를 반환한다.

18.5.5 FormatRelativeTimeToParts ( relativeTimeFormat, value, unit )

The abstract operation FormatRelativeTimeToParts takes arguments relativeTimeFormat (Intl.RelativeTimeFormat), value (Number), and unit (String) and returns Array를 포함하는 정상 완료 또는 throw 완료. It performs the following steps when called:

  1. parts를 ? PartitionRelativeTimePattern(relativeTimeFormat, value, unit)로 둔다.
  2. result를 ! ArrayCreate(0)으로 둔다.
  3. n을 0으로 둔다.
  4. parts의 각 Record { [[Type]], [[Value]], [[Unit]] } part에 대해, 다음을 수행한다.
    1. partObjOrdinaryObjectCreate(%Object.prototype%)로 둔다.
    2. CreateDataPropertyOrThrow(partObj, "type", part.[[Type]])를 수행한다.
    3. CreateDataPropertyOrThrow(partObj, "value", part.[[Value]])를 수행한다.
    4. part.[[Unit]]empty가 아니면,
      1. CreateDataPropertyOrThrow(partObj, "unit", part.[[Unit]])를 수행한다.
    5. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), partObj)를 수행한다.
    6. nn + 1로 설정한다.
  5. result를 반환한다.

19 Segmenter 객체

19.1 Intl.Segmenter 생성자

Intl.Segmenter 생성자는:

  • %Intl.Segmenter%이다.
  • Intl 객체"Segmenter" 속성의 초기값이다.

Intl 객체의 모든 서비스 생성자 속성에 공통되는 동작은 9.1에 명시되어 있다.

19.1.1 Intl.Segmenter ( [ locales [ , options ] ] )

Intl.Segmenter 함수가 선택적 인수 localesoptions로 호출되면, 다음 단계가 수행된다:

  1. NewTarget이 undefined이면, TypeError 예외를 던진다.
  2. internalSlotsList를 « [[InitializedSegmenter]], [[Locale]], [[SegmenterGranularity]] »로 둔다.
  3. segmenter를 ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.Segmenter.prototype%", internalSlotsList)로 둔다.
  4. optionsResolution을 ? ResolveOptions(%Intl.Segmenter%, %Intl.Segmenter%.[[LocaleData]], locales, options)로 둔다.
  5. optionsoptionsResolution.[[Options]]로 설정한다.
  6. resolvedLocaleoptionsResolution.[[ResolvedLocale]]로 둔다.
  7. segmenter.[[Locale]]resolvedLocale.[[Locale]]로 설정한다.
  8. granularity를 ? GetOption(options, "granularity", string, « "grapheme", "word", "sentence" », "grapheme")로 둔다.
  9. segmenter.[[SegmenterGranularity]]granularity로 설정한다.
  10. segmenter를 반환한다.

19.2 Intl.Segmenter 생성자의 속성

Intl.Segmenter 생성자는:

  • 값이 %Function.prototype%[[Prototype]] 내부 슬롯을 가진다.
  • 다음 속성을 가진다:

19.2.1 Intl.Segmenter.prototype

Intl.Segmenter.prototype의 값은 %Intl.Segmenter.prototype%이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false } 특성을 가진다.

19.2.2 Intl.Segmenter.supportedLocalesOf ( locales [ , options ] )

supportedLocalesOf 메서드가 인수 localesoptions로 호출되면, 다음 단계가 수행된다:

  1. availableLocales%Intl.Segmenter%.[[AvailableLocales]]로 둔다.
  2. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  3. FilterLocales(availableLocales, requestedLocales, options)를 반환한다.

19.2.3 내부 슬롯

[[AvailableLocales]] 내부 슬롯의 값은 9.1에 설명된 제약 조건 내에서 구현 정의이다.

[[RelevantExtensionKeys]] 내부 슬롯의 값은 « »이다.

[[ResolutionOptionDescriptors]] 내부 슬롯의 값은 « »이다.

Note
Intl.Segmenter에는 관련된 extension key가 없다.

[[LocaleData]] 내부 슬롯의 값은 9.1에 설명된 제약 조건 내에서 구현 정의이다.

19.3 Intl.Segmenter 프로토타입 객체의 속성

Intl.Segmenter 프로토타입 객체는:

  • %Intl.Segmenter.prototype%이다.
  • 일반 객체이다.
  • Intl.Segmenter 인스턴스가 아니며 [[InitializedSegmenter]] 내부 슬롯이나 Intl.Segmenter 인스턴스 객체의 다른 내부 슬롯을 가지지 않는다.
  • 값이 %Object.prototype%[[Prototype]] 내부 슬롯을 가진다.

19.3.1 Intl.Segmenter.prototype.constructor

Intl.Segmenter.prototype.constructor의 초기값은 %Intl.Segmenter%이다.

19.3.2 Intl.Segmenter.prototype.resolvedOptions ( )

이 함수는 객체의 초기화 중에 계산된 locale 및 option에 대한 접근을 제공한다.

  1. segmenterthis 값으로 둔다.
  2. RequireInternalSlot(segmenter, [[InitializedSegmenter]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  4. Table 34의 각 행에 대해, 헤더 행은 제외하고 표 순서대로, 다음을 수행한다.
    1. propertyKey를 현재 행의 Property 값으로 둔다.
    2. value를, 그 이름이 현재 행의 Internal Slot 값인 segmenter의 내부 슬롯 값으로 둔다.
    3. 단언: valueundefined가 아니다.
    4. CreateDataPropertyOrThrow(options, propertyKey, value)를 수행한다.
  5. options를 반환한다.
Table 34: Segmenter 인스턴스의 Resolved Options
Internal Slot Property
[[Locale]] "locale"
[[SegmenterGranularity]] "granularity"

19.3.3 Intl.Segmenter.prototype.segment ( string )

Intl.Segmenter.prototype.segment 메서드는 Intl.Segmenter 인스턴스에서 인수 string으로 호출되어, Intl.Segmenter 인스턴스의 locale 및 options를 사용해 해당 문자열에 대한 Segments 인스턴스를 생성한다. 다음 단계가 수행된다:

  1. segmenterthis 값으로 둔다.
  2. RequireInternalSlot(segmenter, [[InitializedSegmenter]])를 수행한다.
  3. string을 ? ToString(string)으로 설정한다.
  4. CreateSegmentsObject(segmenter, string)를 반환한다.

19.3.4 Intl.Segmenter.prototype [ %Symbol.toStringTag% ]

%Symbol.toStringTag% 속성의 초기값은 String 값 "Intl.Segmenter"이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } 특성을 가진다.

19.4 Intl.Segmenter 인스턴스의 속성

Intl.Segmenter 인스턴스는 %Intl.Segmenter.prototype%에서 속성을 상속하는 일반 객체이다.

Intl.Segmenter 인스턴스는 [[InitializedSegmenter]] 내부 슬롯을 가진다.

Intl.Segmenter 인스턴스는 또한 Intl.Segmenter 생성자에 의해 계산되는 내부 슬롯을 가진다:

  • [[Locale]]은 segmentation에 사용되는 현지화의 locale에 대한 language tag를 가진 String 값이다.
  • [[SegmenterGranularity]]는 segment할 text element의 종류를 식별하는 String 값 "grapheme", "word", 또는 "sentence" 중 하나이다.

19.5 Segments 객체

Segments 인스턴스는 생성한 Intl.Segmenter 인스턴스의 locale 및 options에 따라, 특정 문자열의 segments를 나타내는 객체이다.

19.5.1 CreateSegmentsObject ( segmenter, string )

The abstract operation CreateSegmentsObject takes arguments segmenter (Intl.Segmenter) and string (String) and returns Segments 인스턴스. It performs the following steps when called:

  1. internalSlotsList를 « [[SegmentsSegmenter]], [[SegmentsString]] »로 둔다.
  2. segmentsOrdinaryObjectCreate(%IntlSegmentsPrototype%, internalSlotsList)로 둔다.
  3. segments.[[SegmentsSegmenter]]segmenter로 설정한다.
  4. segments.[[SegmentsString]]string으로 설정한다.
  5. segments를 반환한다.

19.5.2 %IntlSegmentsPrototype% 객체

%IntlSegmentsPrototype% 객체는:

  • 모든 Segments 객체의 프로토타입이다.
  • 일반 객체이다.
  • 값이 %Object.prototype%[[Prototype]] 내부 슬롯을 가진다.
  • 다음 속성을 가진다:

19.5.2.1 %IntlSegmentsPrototype%.containing ( index )

containing 메서드는 Segments 인스턴스에서 인수 index로 호출되어, Segments 인스턴스를 생성한 Intl.Segmenter 인스턴스의 locale 및 options에 따라 지정된 index의 code unit을 포함하는 문자열 내 segment를 설명하는 Segment Data 객체를 반환한다. 다음 단계가 수행된다:

  1. segmentsthis 값으로 둔다.
  2. RequireInternalSlot(segments, [[SegmentsSegmenter]])를 수행한다.
  3. segmentersegments.[[SegmentsSegmenter]]로 둔다.
  4. stringsegments.[[SegmentsString]]으로 둔다.
  5. lengthstring의 길이로 둔다.
  6. n을 ? ToIntegerOrInfinity(index)로 둔다.
  7. n < 0이거나 nlength이면, undefined를 반환한다.
  8. startIndexFindBoundary(segmenter, string, n, before)로 둔다.
  9. endIndexFindBoundary(segmenter, string, n, after)로 둔다.
  10. CreateSegmentDataObject(segmenter, string, startIndex, endIndex)를 반환한다.

19.5.2.2 %IntlSegmentsPrototype% [ %Symbol.iterator% ] ( )

%Symbol.iterator% 메서드는 Segments 인스턴스에서 호출되어, 생성한 Intl.Segmenter 인스턴스의 locale 및 options를 사용해 그 문자열에 대한 Segment Iterator를 생성한다. 다음 단계가 수행된다:

  1. segmentsthis 값으로 둔다.
  2. RequireInternalSlot(segments, [[SegmentsSegmenter]])를 수행한다.
  3. segmentersegments.[[SegmentsSegmenter]]로 둔다.
  4. stringsegments.[[SegmentsString]]으로 둔다.
  5. CreateSegmentIterator(segmenter, string)를 반환한다.

이 함수의 "name" 속성 값은 "[Symbol.iterator]"이다.

19.5.3 Segments 인스턴스의 속성

Segments 인스턴스%IntlSegmentsPrototype%에서 속성을 상속하는 일반 객체이다.

Segments 인스턴스는 생성 Intl.Segmenter 인스턴스를 참조하는 [[SegmentsSegmenter]] 내부 슬롯을 가진다.

Segments 인스턴스는 노출하는 segments의 String 값을 참조하는 [[SegmentsString]] 내부 슬롯을 가진다.

19.6 Segment Iterator 객체

Segment Iterator는 특정 문자열의 segments에 대한 특정 iteration을 나타내는 객체이다.

19.6.1 CreateSegmentIterator ( segmenter, string )

The abstract operation CreateSegmentIterator takes arguments segmenter (Intl.Segmenter) and string (String) and returns Segment Iterator. It performs the following steps when called:

  1. internalSlotsList를 « [[IteratingSegmenter]], [[IteratedString]], [[IteratedStringNextSegmentCodeUnitIndex]] »로 둔다.
  2. iteratorOrdinaryObjectCreate(%IntlSegmentIteratorPrototype%, internalSlotsList)로 둔다.
  3. iterator.[[IteratingSegmenter]]segmenter로 설정한다.
  4. iterator.[[IteratedString]]string으로 설정한다.
  5. iterator.[[IteratedStringNextSegmentCodeUnitIndex]]를 0으로 설정한다.
  6. iterator를 반환한다.

19.6.2 %IntlSegmentIteratorPrototype% 객체

%IntlSegmentIteratorPrototype% 객체는:

  • 모든 Segment Iterator 객체의 프로토타입이다.
  • 일반 객체이다.
  • 값이 %Iterator.prototype%[[Prototype]] 내부 슬롯을 가진다.
  • 다음 속성을 가진다:

19.6.2.1 %IntlSegmentIteratorPrototype%.next ( )

next 메서드는 Segment Iterator 인스턴스에서 호출되어 이를 한 segment 앞으로 진행시키고, 새 segment를 설명하거나 iteration 완료를 선언하는 IteratorResult 객체를 반환한다. 다음 단계가 수행된다:

  1. iteratorthis 값으로 둔다.
  2. RequireInternalSlot(iterator, [[IteratingSegmenter]])를 수행한다.
  3. segmenteriterator.[[IteratingSegmenter]]로 둔다.
  4. stringiterator.[[IteratedString]]으로 둔다.
  5. startIndexiterator.[[IteratedStringNextSegmentCodeUnitIndex]]로 둔다.
  6. lengthstring의 길이로 둔다.
  7. startIndexlength이면,
    1. CreateIteratorResultObject(undefined, true)를 반환한다.
  8. endIndexFindBoundary(segmenter, string, startIndex, after)로 둔다.
  9. iterator.[[IteratedStringNextSegmentCodeUnitIndex]]endIndex로 설정한다.
  10. segmentDataCreateSegmentDataObject(segmenter, string, startIndex, endIndex)로 둔다.
  11. CreateIteratorResultObject(segmentData, false)를 반환한다.

19.6.2.2 %IntlSegmentIteratorPrototype% [ %Symbol.toStringTag% ]

%Symbol.toStringTag% 속성의 초기값은 String 값 "Segmenter String Iterator"이다.

이 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true } 특성을 가진다.

19.6.3 Segment Iterator 인스턴스의 속성

Segment Iterator 인스턴스는 %SegmentIteratorPrototype%에서 속성을 상속하는 일반 객체이다. Segment Iterator 인스턴스는 처음에 Table 35에 설명된 내부 슬롯으로 생성된다.

Table 35: Segment Iterator 인스턴스의 내부 슬롯
Internal Slot 설명
[[IteratingSegmenter]] iteration에 사용되는 Intl.Segmenter 인스턴스.
[[IteratedString]] iteration 대상인 String 값.
[[IteratedStringNextSegmentCodeUnitIndex]] 다음 segment의 시작 위치에서, iteration 대상인 String 값 내 code unit index.

19.7 Segment Data 객체

Segment Data 객체는 문자열에서 특정 segment를 나타내는 객체이다.

19.7.1 CreateSegmentDataObject ( segmenter, string, startIndex, endIndex )

The abstract operation CreateSegmentDataObject takes arguments segmenter (Intl.Segmenter), string (String), startIndex (음이 아닌 정수), and endIndex (음이 아닌 정수) and returns Segment Data 객체. It performs the following steps when called:

  1. lengthstring의 길이로 둔다.
  2. 단언: endIndexlength.
  3. 단언: startIndex < endIndex.
  4. resultOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  5. segmentstring에서 startIndex부터 endIndex까지의 부분 문자열로 둔다.
  6. CreateDataPropertyOrThrow(result, "segment", segment)를 수행한다.
  7. CreateDataPropertyOrThrow(result, "index", 𝔽(startIndex))를 수행한다.
  8. CreateDataPropertyOrThrow(result, "input", string)를 수행한다.
  9. granularitysegmenter.[[SegmenterGranularity]]로 둔다.
  10. granularity"word"이면,
    1. isWordLike를 locale segmenter.[[Locale]]에 따라 stringsegment가 "word-like"인지 여부를 나타내는 Boolean으로 둔다.
    2. CreateDataPropertyOrThrow(result, "isWordLike", isWordLike)를 수행한다.
  11. result를 반환한다.
Note
segment가 "word-like"인지 여부는 구현 의존이며, 구현은 locale-sensitive tailorings를 사용하는 것이 권장된다. 일반적으로 공백 및/또는 구두점만으로 구성된 segments(예: ICU [International Components for Unicode, https://unicode-org.github.io/icu-docs/에 문서화됨]에서 "WORD_NONE" boundaries로 끝나는 것)는 "word-like"인 것으로 간주되지 않는다.

19.8 Segmenter 객체를 위한 추상 연산

19.8.1 FindBoundary ( segmenter, string, startIndex, direction )

The abstract operation FindBoundary takes arguments segmenter (Intl.Segmenter), string (String), startIndex (음이 아닌 정수), and direction (before 또는 after) and returns 음이 아닌 정수. It performs the following steps when called:

  1. lengthstring의 길이로 둔다.
  2. 단언: startIndex < length.
  3. localesegmenter.[[Locale]]로 둔다.
  4. granularitysegmenter.[[SegmenterGranularity]]로 둔다.
  5. directionbefore이면,
    1. locale locale 및 text element granularity granularity를 사용하여, 시작부터 최대 startIndex code units가 앞서는 마지막 segmentation boundary를 string에서 검색한다.
    2. boundary가 발견되면, 그 앞에 있는 string의 code units 수를 반환한다.
    3. 0을 반환한다.
  6. 단언: directionafter이다.
  7. locale locale 및 text element granularity granularity를 사용하여, index startIndex의 code unit 뒤에 오는 첫 번째 segmentation boundary를 string에서 검색한다.
  8. boundary가 발견되면, 그 앞에 있는 string의 code units 수를 반환한다.
  9. length를 반환한다.
Note
Boundary 결정은 구현 의존이지만, 일반 기본 알고리즘은 Unicode Standard Annex #29에 명시되어 있다. 구현은 Common Locale Data Repository(https://cldr.unicode.org에서 이용 가능)가 제공하는 것과 같은 locale-sensitive tailorings를 사용하는 것이 권장된다.

20 ECMAScript 언어 명세의 Locale Sensitive 함수

ECMA-262는 여러 locale-sensitive 함수를 설명한다. 이 명세를 구현하는 ECMAScript 구현은 이 함수들을 여기 설명된 대로 구현해야 한다.

Note
이 절의 알고리즘에서 생성되는 Collator, NumberFormat 또는 DateTimeFormat 객체는 이 알고리즘 안에서만 사용된다. 이들은 ECMAScript 코드에서 직접 접근되지 않으며, 구현 안에 실제로 존재할 필요는 없다.

20.1 String Prototype 객체의 속성

20.1.1 String.prototype.localeCompare ( that [ , locales [ , options ] ] )

이 정의는 ECMA-262, 22.1.3.12에 제공된 정의를 대체한다.

localeCompare 메서드가 인수 that 및 선택적 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. thisValue를 ? RequireObjectCoercible(this value)로 둔다.
  2. string을 ? ToString(thisValue)로 둔다.
  3. thatValue를 ? ToString(that)로 둔다.
  4. collator를 ? Construct(%Intl.Collator%, « locales, options »)로 둔다.
  5. CompareStrings(collator, string, thatValue)를 반환한다.

이 함수의 "length" 속성은 1𝔽이다.

Note 1
localeCompare 메서드 자체는 Array.prototype.sort의 인수로 직접 사용하기에 적합하지 않다. 후자는 두 인수의 함수를 요구하기 때문이다.
Note 2
localeCompare 함수는 의도적으로 generic이다. 이 함수는 자신의 this 값이 String 객체일 것을 요구하지 않는다. 따라서 메서드로 사용하기 위해 다른 종류의 객체로 옮길 수 있다.

20.1.2 String.prototype.toLocaleLowerCase ( [ locales ] )

이 정의는 ECMA-262, 22.1.3.26에 제공된 정의를 대체한다.

이 함수는 ECMA-262, 6.1.4에 설명된 것처럼 String 값을 code point의 시퀀스로 해석한다. 다음 단계가 수행된다:

  1. thisValue를 ? RequireObjectCoercible(this value)로 둔다.
  2. string을 ? ToString(thisValue)로 둔다.
  3. TransformCase(string, locales, lower)를 반환한다.
Note
toLocaleLowerCase 함수는 의도적으로 generic이다. 이 함수는 자신의 this 값이 String 객체일 것을 요구하지 않는다. 따라서 메서드로 사용하기 위해 다른 종류의 객체로 옮길 수 있다.

20.1.2.1 TransformCase ( string, locales, targetCase )

The abstract operation TransformCase takes arguments string (String), locales (ECMAScript 언어 값), and targetCase (lower 또는 upper). ECMA-262, 6.1.4에 설명된 것처럼 string을 UTF-16으로 인코딩된 code point의 시퀀스로 해석하고, targetCaseILD 변환한 결과를 새 String 값으로 반환한다. It performs the following steps when called:

  1. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  2. requestedLocales가 빈 List가 아니면,
    1. requestedLocalerequestedLocales[0]으로 둔다.
  3. 그렇지 않으면,
    1. requestedLocaleDefaultLocale()로 둔다.
  4. availableLocales를 Unicode Character Database가 language-sensitive case mapping을 포함하는 언어 태그를 포함하는 Available Locales List로 둔다. 구현이 추가적인 locale-sensitive case mapping을 지원한다면, availableLocales는 그에 대응하는 언어 태그도 포함해야 한다.
  5. matchLookupMatchingLocaleByPrefix(availableLocales, « requestedLocale »)로 둔다.
  6. matchundefined가 아니면 localematch.[[locale]]로 두고, 그렇지 않으면 locale"und"로 둔다.
  7. codePointsStringToCodePoints(string)로 둔다.
  8. targetCaselower이면,
    1. newCodePointslocale 또는 Unicode Default Case Conversion 알고리즘을 사용하는 implementation-derived 알고리즘에 따라 codePoints를 lowercase 변환한 결과를 요소로 하는 List로 둔다.
  9. 그렇지 않으면,
    1. Assert: targetCaseupper이다.
    2. newCodePointslocale 또는 Unicode Default Case Conversion 알고리즘을 사용하는 implementation-derived 알고리즘에 따라 codePoints를 uppercase 변환한 결과를 요소로 하는 List로 둔다.
  10. CodePointsToString(newCodePoints)를 반환한다.

Code point mapping은 Unicode Standard의 Default Case Conversion Algorithms의 tailored 버전에 따라 도출될 수 있다. 구현은 Unicode Character Database의 SpecialCasing.txt 파일 및/또는 CLDR 및/또는 다른 custom tailoring에 정의된 locale-sensitive tailoring을 사용할 수 있다. tailoring과 관계없이, conforming 구현의 case transformation 알고리즘은 동일한 입력 code point, locale 및 target case가 주어졌을 때 항상 동일한 결과를 산출해야 한다.

Note
일부 code point의 case mapping은 여러 code point를 생성할 수 있으므로, 결과는 입력과 같은 길이가 아닐 수 있다. toLocaleUpperCasetoLocaleLowerCase 모두 context-sensitive 동작을 가지기 때문에, 두 함수는 대칭적이지 않다. 다시 말해, s.toLocaleUpperCase().toLocaleLowerCase()는 반드시 s.toLocaleLowerCase()와 같지 않으며, s.toLocaleLowerCase().toLocaleUpperCase()는 반드시 s.toLocaleUpperCase()와 같지 않다.

20.1.3 String.prototype.toLocaleUpperCase ( [ locales ] )

이 정의는 ECMA-262, 22.1.3.27에 제공된 정의를 대체한다.

이 함수는 ECMA-262, 6.1.4에 설명된 것처럼 String 값을 code point의 시퀀스로 해석한다. 다음 단계가 수행된다:

  1. thisValue를 ? RequireObjectCoercible(this value)로 둔다.
  2. string을 ? ToString(thisValue)로 둔다.
  3. TransformCase(string, locales, upper)를 반환한다.
Note
toLocaleUpperCase 함수는 의도적으로 generic이다. 이 함수는 자신의 this 값이 String 객체일 것을 요구하지 않는다. 따라서 메서드로 사용하기 위해 다른 종류의 객체로 옮길 수 있다.

20.2 Number Prototype 객체의 속성

다음 정의(들)는 ECMA-262, 21.1.3에 정의된 추상 연산 thisNumberValue를 참조한다.

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

이 정의는 ECMA-262, 21.1.3.4에 제공된 정의를 대체한다.

toLocaleString 메서드가 선택적 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. x를 ? ThisNumberValue(this value)로 둔다.
  2. numberFormat을 ? Construct(%Intl.NumberFormat%, « locales, options »)로 둔다.
  3. FormatNumeric(numberFormat, ! ToIntlMathematicalValue(x))를 반환한다.

20.3 BigInt Prototype 객체의 속성

다음 정의(들)는 ECMA-262, 21.2.3에 정의된 추상 연산 thisBigIntValue를 참조한다.

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

이 정의는 ECMA-262, 21.2.3.2에 제공된 정의를 대체한다.

toLocaleString 메서드가 선택적 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. x를 ? ThisBigIntValue(this value)로 둔다.
  2. numberFormat을 ? Construct(%Intl.NumberFormat%, « locales, options »)로 둔다.
  3. FormatNumeric(numberFormat, (x))를 반환한다.

20.4 Date Prototype 객체의 속성

다음 정의(들)는 ECMA-262, 21.4.4에 정의된 추상 연산 thisTimeValue를 참조한다.

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

이 정의는 ECMA-262, 21.4.4.39에 제공된 정의를 대체한다.

toLocaleString 메서드가 선택적 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])를 수행한다.
  3. xdateObj.[[DateValue]]로 둔다.
  4. xNaN이면 "Invalid Date"를 반환한다.
  5. dateFormat을 ? CreateDateTimeFormat(%Intl.DateTimeFormat%, locales, options, any, all)로 둔다.
  6. FormatDateTime(dateFormat, x)를 반환한다.

20.4.2 Date.prototype.toLocaleDateString ( [ locales [ , options ] ] )

이 정의는 Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] )에 제공된 정의를 대체한다.

toLocaleDateString 메서드가 선택적 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])를 수행한다.
  3. xdateObj.[[DateValue]]로 둔다.
  4. xNaN이면 "Invalid Date"를 반환한다.
  5. dateFormat을 ? CreateDateTimeFormat(%Intl.DateTimeFormat%, locales, options, date, date)로 둔다.
  6. FormatDateTime(dateFormat, x)를 반환한다.

20.4.3 Date.prototype.toLocaleTimeString ( [ locales [ , options ] ] )

이 정의는 Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] )에 제공된 정의를 대체한다.

toLocaleTimeString 메서드가 선택적 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. dateObjthis 값으로 둔다.
  2. RequireInternalSlot(dateObj, [[DateValue]])를 수행한다.
  3. xdateObj.[[DateValue]]로 둔다.
  4. xNaN이면 "Invalid Date"를 반환한다.
  5. timeFormat을 ? CreateDateTimeFormat(%Intl.DateTimeFormat%, locales, options, time, time)로 둔다.
  6. FormatDateTime(timeFormat, x)를 반환한다.

20.5 Array Prototype 객체의 속성

20.5.1 Array.prototype.toLocaleString ( [ locales [ , options ] ] )

이 정의는 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )에 제공된 정의를 대체한다.

toLocaleString 메서드가 선택적 인수 localesoptions와 함께 호출되면 다음 단계가 수행된다:

  1. array를 ? ToObject(this value)로 둔다.
  2. length를 ? LengthOfArrayLike(array)로 둔다.
  3. separatorhost environment의 현재 locale에 적합한 구현 정의 list-separator String 값(예: ", ")으로 둔다.
  4. result를 빈 String으로 둔다.
  5. k를 0으로 둔다.
  6. k < length인 동안 반복한다.
    1. k > 0이면,
      1. resultresultseparator의 문자열 연결로 설정한다.
    2. element를 ? Get(array, ! ToString(𝔽(k)))로 둔다.
    3. elementundefinednull도 아니면,
      1. elementString을 ? ToString(? Invoke(element, "toLocaleString", « locales, options »))로 둔다.
      2. resultresultelementString의 문자열 연결로 설정한다.
    4. kk + 1로 설정한다.
  7. result를 반환한다.
Note 1
이 알고리즘의 단계는 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )에서 수행되는 단계를 반영하지만, Invoke(nextElement, "toLocaleString")가 이제 localesoptions를 인수로 받는다는 점이 다르다.
Note 2
배열의 요소는 자신의 toLocaleString 메서드를 사용해 String으로 변환되고, 이러한 String들은 구현 정의 locale-sensitive separator String의 발생으로 구분되어 연결된다. 이 함수는 toString과 유사하지만, host environment의 현재 locale 관례에 대응하는 locale-sensitive 결과를 산출하도록 의도되었다.
Note 3
toLocaleString 함수는 의도적으로 generic이다. 이 함수는 자신의 this 값이 Array 객체일 것을 요구하지 않는다. 따라서 메서드로 사용하기 위해 다른 종류의 객체로 옮길 수 있다.

Annex A (informative) 구현에 따라 달라질 수 있는 동작

이 명세의 다음 측면들은 구현에 따라 달라질 수 있습니다:

Annex B (informative) 이전 판과의 호환성에 영향을 주는 추가 및 변경 사항

Annex C (informative) 콜로폰

이 명세서는 GitHub에서 Ecmarkup라는 평문 소스 형식으로 작성되었습니다. Ecmarkup은 HTML과 Markdown 방언으로, 평문으로 ECMAScript 명세서를 작성하고, 이 문서의 편집 규칙을 따르는 완전한 HTML 렌더링으로 처리할 수 있는 프레임워크와 도구를 제공합니다. Ecmarkup은 Grammarkdown을 사용한 구문 정의와 Ecmarkdown을 사용한 알고리즘 단계 작성 등 여러 형식과 기술을 통합하여 구축되었습니다. 이 명세서의 PDF 렌더링은 CSS Paged Media 명세를 활용하는 인쇄 스타일시트를 사용하여 PrinceXML로 변환됩니다.

이전 판의 명세서는 Word로 작성되었습니다. 이 판의 기반이 된 Ecmarkup 소스 텍스트는 ECMAScript 2015 Word 문서를 자동 변환 도구로 Ecmarkup으로 변환하여 생성되었습니다.

Copyright & Software License

Ecma International

Rue du Rhone 114

CH-1204 Geneva

Tel: +41 22 849 6000

Fax: +41 22 849 6001

Web: https://ecma-international.org/

Software License

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.