Draft ECMA-402 / February 21, 2026

ECMAScript® 2026 Internationalization API Specification

이 명세에 기여하기

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

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

소개

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

ECMAScript 2026 국제화 API 명세서 (ECMA-402 13번째 판)는 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번째 판 프로젝트 에디터

1 범위

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

2 적합성

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

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

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

3 규범적 참고문헌

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

ECMAScript 2026 언어 명세서 (ECMA-262 17번째 판 또는 후속 판).
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 로케일, 통화, 시간대, 측정 단위, 숫자 시스템, 정렬, 달력 및 패턴 문자열의 식별

이 절에서는 로케일, 통화, 시간대, 측정 단위, 숫자 시스템, 정렬, 달력 및 패턴 문자열을 식별하기 위해 이 명세에서 사용되는 String 값에 대해 설명합니다.

6.1 대소문자 민감성과 대소문자 매핑

로케일, 통화, 스크립트, 시간대를 식별하는 데 사용되는 String 값은 ASCII 대소문자 구분 없이 해석되며, 코드 유닛 0x0041~0x005A(유니코드 문자 LATIN CAPITAL LETTER A~Z)는 0x0061~0x007A(유니코드 문자 LATIN SMALL LETTER a~z)와 동일하게 취급됩니다. 다른 대소문자 변환 등가는 적용되지 않습니다.

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

ASCII-uppercase는 String 값 S에서 ASCII 소문자 코드 유닛(0x0061~0x007A)을 해당하는 ASCII 대문자 코드 유닛(0x0041~0x005A)으로 바꾸고, 다른 코드 유닛은 그대로 유지하여 얻은 String 값입니다.

ASCII-lowercase는 String 값 S에서 ASCII 대문자 코드 유닛(0x0041~0x005A)을 해당하는 ASCII 소문자 코드 유닛(0x0061~0x007A)으로 바꾸고, 다른 코드 유닛은 그대로 유지하여 얻은 String 값입니다.

String 값 A가 String 값 BASCII-case-insensitive match라면, A의 ASCII-uppercase가 B의 ASCII-uppercase와 정확히 동일한 코드 유닛 시퀀스임을 의미합니다. 유니코드 코드 포인트 시퀀스 AB와 ASCII-case-insensitive match라면, BCodePointsToString(A)와 ASCII-case-insensitive match임을 의미합니다.

6.2 언어 태그

이 명세는 Unicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance에서 정의된 Unicode BCP 47 로케일 식별자를 사용하여 로케일을 식별하며, 알고리즘은 Section 3 Unicode Language and Locale Identifiers의 문법에서 정의된 Unicode 로케일 비종단 기호를 참조합니다. 이러한 식별자는 언어 태그라고도 하며, 실제로 BCP 47에서 사용되는 언어 태그로 유효합니다. Unicode Technical Standard #35 Part 1 Core, Section 3.2.1 Canonical Unicode Locale Identifiers에서 지정된 정규형 로케일 식별자는 "Unicode 정규화된 로케일 식별자"라고 합니다.

로케일 식별자는 대소문자 구분 없는 Unicode Basic Latin 영숫자 서브태그로 구성되며, "-" (U+002D HYPHEN-MINUS) 문자로 구분됩니다. 한 글자짜리 서브태그는 "싱글톤 서브태그"라고 합니다. Unicode Technical Standard #35 Part 1 Core, Section 3.6 Unicode BCP 47 U Extension 서브태그 시퀀스가 많이 사용되며, "Unicode 로케일 확장 시퀀스"는 unicode_locale_extensions Unicode 로케일 비종단 기호로 매칭될 수 있는 언어 태그의 가장 긴 부분 문자열을 의미하며, "-x-…" 프라이빗 사용 서브태그 시퀀스에는 포함되지 않습니다. "-u-"로 시작하며, 싱글톤 서브태그가 아닌 모든 서브태그와 그 앞의 "-" 구분자를 포함합니다. 예를 들어, "en-US-u-fw-mon-x-u-ex-foobar"Unicode 로케일 확장 시퀀스"-u-fw-mon"입니다.

모든 올바른 형식의 언어 태그는 이 명세에서 정의된 API에 사용할 수 있지만, 구현체는 이를 검증하기 위해 Unicode Common Locale Data Repository(CLDR) 데이터를 사용할 필요는 없습니다. 구현체가 지원하는 로케일과 언어 태그의 집합은 구현 정의입니다. Intl 생성자는 요청된 언어 태그를 각 구현체가 지원하는 로케일로 매핑합니다.

6.2.1 IsWellFormedLanguageTag ( locale )

The abstract operation IsWellFormedLanguageTag takes argument locale (a String) and returns a Boolean. localeunicode_bcp47_locale_id의 올바른 형식 제약을 준수하는 올바른 형식의 언어 태그인지 결정합니다. locale이 의미 있는 정보를 전달하는지, 별칭 서브태그와 선호되는 대체 서브태그를 구분하는지, 정규화된 대소문자 또는 서브태그 순서를 요구하는지는 고려하지 않습니다. It performs the following steps when called:

  1. lowerLocalelocaleASCII-lowercase로 설정한다.
  2. lowerLocaleunicode_locale_id Unicode 로케일 비종단 기호로 매칭되지 않으면 false를 반환한다.
  3. lowerLocaleUnicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance에서 설명된 하위 호환 구문을 사용하면 false를 반환한다.
  4. baseNameGetLocaleBaseName(lowerLocale)로 설정한다.
  5. variantsGetLocaleVariants(baseName)로 설정한다.
  6. variantsundefined가 아니면,
  7. variants에 중복 서브태그가 있으면 false를 반환한다.
  8. extensionsbaseName 이후의 lowerLocale 접미사로 설정한다.
  9. NOTE: pu_extensions Unicode 로케일 비종단 기호로 매칭되는 "-x-…" 프라이빗 사용 서브태그 시퀀스는 무시해야 하지만, 마지막에 내용이 없는 단독 "x" 서브태그는 아래 검사에 영향을 주지 않습니다.
  10. puIndexStringIndexOf(extensions, "-x-", 0)로 설정한다.
  11. puIndexnot-found가 아니면, extensions를 0부터 puIndex까지의 부분 문자열로 설정한다.
  12. extensions가 빈 문자열이 아니면,
  13. extensions에 중복 싱글톤 서브태그가 있으면 false를 반환한다.
  14. transformExtensiontransformed_extensions Unicode 로케일 비종단 기호로 매칭되는 extensions의 가장 긴 부분 문자열로 설정한다. 그런 부분 문자열이 없으면 true를 반환한다.
  15. Assert: transformExtension의 0~3 부분 문자열은 "-t-"이다.
  16. tPrefixtransformExtension의 3부터의 부분 문자열로 설정한다.
  17. tlangtlang Unicode 로케일 비종단 기호로 매칭되는 tPrefix의 가장 긴 접두사로 설정한다. 그런 접두사가 없으면 true를 반환한다.
  18. tlangVariantsGetLocaleVariants(tlang)로 설정한다.
  19. tlangVariants에 중복 서브태그가 있으면 false를 반환한다.
  20. true를 반환한다.

6.2.2 CanonicalizeUnicodeLocaleId ( locale )

The abstract operation CanonicalizeUnicodeLocaleId takes argument locale (a language tag) and returns a Unicode canonicalized locale identifier. locale의 정규화되고 대소문자가 규칙화된 형태를 반환합니다. It performs the following steps when called:

  1. localeIdProcessing LocaleIds 알고리즘을 수행하여 Unicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalization에 따라 locale을 정규형으로 변환한 String 값으로 설정한다.
  2. localeIdUnicode 로케일 확장 시퀀스가 포함되어 있으면,
  3. extensionlocaleId 내의 Unicode 로케일 확장 시퀀스 부분 문자열로 구성된 String 값으로 설정한다.
  4. newExtension"-u"로 설정한다.
  5. componentsUnicodeExtensionComponents(extension)로 설정한다.
  6. components.[[Attributes]]의 각 요소 attr에 대해,
  7. newExtensionnewExtension, "-", attr의 문자열 연결로 설정한다.
  8. components.[[Keywords]]의 각 Record { [[Key]], [[Value]] } keyword에 대해,
  9. newExtensionnewExtension, "-", keyword.[[Key]]의 문자열 연결로 설정한다.
  10. keyword.[[Value]]가 빈 문자열이 아니면,
  11. newExtensionnewExtension, "-", keyword.[[Value]]의 문자열 연결로 설정한다.
  12. Assert: newExtension"-u"가 아니다.
  13. localeId의 첫 번째 부분 문자열 extensionnewExtension으로 교체한 복사본으로 localeId를 설정한다.
  14. localeId를 반환한다.
Note
2 단계는 반환된 언어 태그Unicode 로케일 확장 시퀀스에 대해:
  • 입력에 중복된 속성이 있으면 첫 번째 인스턴스만 포함하고,
  • 입력에 대해 주어진 키의 첫 번째 키워드만 포함합니다.

6.2.3 DefaultLocale ( )

The implementation-defined abstract operation DefaultLocale takes no arguments and returns a Unicode canonicalized locale identifier. 반환된 String 값은 호스트 환경의 현재 로케일에 대한 올바른 형식(6.2.1) 및 정규화된(6.2.2) 언어 태그를 나타냅니다. Unicode 로케일 확장 시퀀스를 포함해서는 안 됩니다.

Note
반환 값은 잠재적인 지문 추적 벡터입니다. 브라우저 환경에서는 navigator.language와 일치해야 추가적인 식별 정보를 제공하지 않습니다.

6.3 통화 코드

이 명세는 ISO 4217에서 정의된 3글자 통화 코드를 사용하여 통화를 식별합니다. 정규형은 대문자입니다.

모든 올바른 형식의 3글자 ISO 4217 통화 코드를 허용합니다. 그러나 통화 코드와 언어 태그의 조합 중 로컬라이즈된 통화 기호가 제공되는 집합은 구현에 따라 다릅니다. 로컬라이즈된 통화 기호가 없으면 ISO 4217 통화 코드가 포매팅에 사용됩니다.

6.3.1 IsWellFormedCurrencyCode ( currency )

The abstract operation IsWellFormedCurrencyCode takes argument currency (a String) and returns a Boolean. currency 인자가 올바른 형식의 3글자 ISO 4217 통화 코드인지 확인합니다. It performs the following steps when called:

  1. currency의 길이가 3이 아니면 false를 반환한다.
  2. normalizedcurrencyASCII-uppercase로 설정한다.
  3. normalized에 0x0041~0x005A(유니코드 문자 LATIN CAPITAL LETTER A~Z) 범위를 벗어난 코드 유닛이 있으면 false를 반환한다.
  4. true를 반환한다.

6.4 AvailableCanonicalCurrencies ( )

The implementation-defined abstract operation AvailableCanonicalCurrencies takes no arguments and returns a List of Strings. 반환된 List는 코드 유닛의 사전순으로 정렬되어 있으며, 고유하고 올바른 형식의 대문자 정규화된 3글자 ISO 4217 통화 코드만 포함합니다. 구현체가 Intl.DisplayNames 및 Intl.NumberFormat 객체의 기능을 제공하는 통화를 식별합니다.

6.5 IANA 시간대 데이터베이스의 사용

이 명세를 채택하는 구현체는 시간대 인식이 되어야 하며, IANA 시간대 데이터베이스 https://www.iana.org/time-zones/를 사용하여 ECMAScript 계산 및 포매팅에 사용되는 사용 가능한 명명된 시간대 식별자와 데이터를 제공해야 합니다. 이 섹션은 시간대 인식 구현체가 IANA 시간대 데이터베이스를 어떻게 사용해야 하는지 정의합니다. Zone 이름 또는 Link 이름이 아니면 사용 가능한 명명된 시간대 식별자가 될 수 없습니다. ECMAScript 내장 객체가 반환하는 사용 가능한 명명된 시간대 식별자는 IANA 시간대 데이터베이스에 있는 대소문자를 사용해야 합니다.

IANA 시간대 데이터베이스의 각 Zone은 기본 시간대 식별자여야 하며, 각 Link 이름은 해당 Zone 이름으로 해석되는 비기본 시간대 식별자여야 합니다. 다음 예외는 AvailableNamedTimeZoneIdentifiers에서 구현됩니다:

  • 역사적 이유로 "UTC"는 기본 시간대 식별자여야 합니다. "Etc/UTC", "Etc/GMT", "GMT" 및 이들로 해석되는 모든 Link 이름은 비기본 시간대 식별자로서 "UTC"로 해석되어야 합니다.
  • zone.tab 파일의 “TZ” 열에 있는 Link 이름은 기본 시간대 식별자여야 합니다. 예를 들어, "Europe/Prague""Europe/Bratislava" 모두 기본 시간대 식별자여야 합니다. 이 요구사항은 각 ISO 3166-1 Alpha-2 국가 코드마다 최소 하나의 기본 시간대 식별자를 보장하며, 한 국가의 시간대 규칙 변경이 다른 국가의 시간대에 영향을 주지 않도록 합니다(영토 경계가 변경되지 않는 한).
  • zone.tab의 “TZ” 열에 없는 Link 이름이 단일 ISO 3166-1 Alpha-2 국가 코드의 영토 내에 완전히 포함된 지리적 영역을 나타내는 경우, 해당 Link 이름은 동일한 국가 코드의 영토 내에 완전히 포함된 기본 식별자로 해석되어야 합니다. 예를 들어, "Atlantic/Jan_Mayen""Arctic/Longyearbyen"으로 해석되어야 합니다.
Note

IANA 시간대 데이터베이스는 기본 시간대 식별자가 되는 사용 가능한 명명된 시간대 식별자에 영향을 주는 빌드 옵션을 제공합니다. 기본 빌드 옵션은 서로 다른 국가의 시간대를 병합하며, 예를 들어 "Atlantic/Reykjavik""Africa/Abidjan" Zone에 대한 Link로 빌드됩니다. 지리적 및 정치적으로 구별되는 위치는 향후 IANA 시간대 데이터베이스 버전에서 시간대 규칙이 달라질 가능성이 높습니다. 위의 예외는 이러한 미래 호환성 문제를 완화하기 위한 것입니다.

Unicode Common Locale Data Repository(CLDR)는 위의 예외 대부분을 구현하여 사용 가능한 명명된 시간대 식별자가 기본 또는 비기본인지 결정합니다. 구현체 간 일관성을 위해 CLDR 데이터 사용이 권장되지만 필수는 아닙니다. CLDR 기반이 아닌 구현체도 timezone.xml의 CLDR 식별자 데이터를 사용할 수 있습니다. 구현체는 PACKRATDATA=backzone PACKRATLIST=zone.tab과 같은 빌드 옵션을 사용하여 IANA 시간대 데이터베이스를 직접 빌드할 수도 있으며, 위 요구사항을 준수하기 위한 후처리를 수행할 수 있습니다.

IANA 시간대 데이터베이스는 일반적으로 연간 5~10회 업데이트됩니다. 이러한 업데이트는 새로운 Zone 또는 Link 이름을 추가하거나, Zone을 Link로 변경하거나, 각 Zone의 UTC 오프셋 및 전환을 변경할 수 있습니다. 구현체는 IANA 시간대 데이터베이스 업데이트를 가능한 한 빨리 포함하는 것이 권장됩니다. 이렇게 하면 ECMAScript 프로그램이 시간대에 민감한 계산을 정확하게 수행하고 외부 입력이나 호스트 환경에서 제공되는 새로 추가된 사용 가능한 명명된 시간대 식별자를 사용할 수 있습니다.

IANA 시간대 데이터베이스 관리자는 안정성을 위해 노력하지만, 드물게(연 평균 1회 미만) Zone이 새로운 Zone으로 대체될 수 있습니다. 예를 들어, 2022년 "Europe/Kiev"은 새 "Europe/Kyiv" Zone으로 대체되어 Link로 폐기되었습니다. 폐기된 Link는 이름이 변경된 시간대 식별자이고, 새로 추가된 Zone은 대체 시간대 식별자입니다.

이러한 드문 변경으로 인한 혼란을 줄이기 위해, 구현체는 처음에는 각 대체 시간대 식별자를 기존 이름이 변경된 시간대 식별자로 해석되는 비기본 시간대 식별자로 추가해야 합니다. 이렇게 하면 ECMAScript 프로그램이 두 식별자를 모두 인식할 수 있지만, 아직 대체 시간대 식별자를 인식하지 못하는 다른 시스템에 해당 식별자를 보내는 가능성도 줄어듭니다. 이름 변경 대기 기간이 지난 후, 구현체는 새 Zone을 기본 시간대 식별자로 승격하고, 동시에 이름이 변경된 시간대 식별자를 비기본으로 강등해야 합니다. 다른 시스템이 업데이트될 충분한 시간을 제공하기 위해 권장되는 이름 변경 대기 기간은 2년입니다. 그러나 반드시 정확하거나 동적으로 적용할 필요는 없습니다. 대신, 구현체는 시간대 데이터 업데이트의 일반 릴리스 과정에서 대기 기간이 지난 후 대체 시간대 식별자를 기본으로 만듭니다.

대기 기간은 새 Zone이 기존 Zone을 대체할 때만 적용해야 합니다. 기존 Zone과 Link가 서로 교환된 경우, 이름 변경이 발생한 것이 아니므로 대기 기간이 필요하지 않습니다.

구현체가 에이전트의 수명 동안 시간대 정보를 수정하는 경우, 사용 가능한 명명된 시간대 식별자 목록, 각 사용 가능한 명명된 시간대 식별자에 연결된 기본 시간대 식별자, 각 사용 가능한 명명된 시간대 식별자의 UTC 오프셋 및 전환이 이전에 해당 에이전트에서 관찰된 결과와 일치해야 합니다. 이 요구사항을 지원하는 복잡성 때문에, 구현체는 각 에이전트의 수명 동안 IANA 시간대 데이터베이스의 완전히 일관된 복사본을 유지하는 것이 권장됩니다.

이 섹션은 21.4.1.19를 보완하지만 대체하지는 않습니다.

6.5.1 AvailableNamedTimeZoneIdentifiers ( )

The implementation-defined abstract operation AvailableNamedTimeZoneIdentifiers takes no arguments and returns a List of Time Zone Identifier Records. 결과는 이 구현체의 모든 사용 가능한 명명된 시간대 식별자와 각 사용 가능한 명명된 시간대 식별자에 해당하는 기본 시간대 식별자를 설명합니다. List는 각 Time Zone Identifier Record[[Identifier]] 필드에 따라 정렬됩니다.

이 정의는 21.4.1.23에서 제공된 정의를 대체합니다.

  1. identifiers를 IANA 시간대 데이터베이스의 각 Zone 또는 Link 이름의 String 값으로 구성된 List로 설정한다.
  2. Assert: identifiers의 어떤 요소도 다른 요소와 ASCII-case-insensitive match가 아니다.
  3. identifiers를 코드 유닛의 사전순으로 정렬한다.
  4. result를 새로운 빈 List로 설정한다.
  5. identifiers의 각 요소 identifier에 대해,
  6. primaryidentifier로 설정한다.
  7. identifier가 IANA 시간대 데이터베이스의 Link 이름이고 zone.tab의 “TZ” 열에 없으면,
  8. zone을 IANA 시간대 데이터베이스의 Link 이름 해석 규칙에 따라 identifier가 해석되는 Zone 이름으로 설정한다.
  9. zone"Etc/"로 시작하면,
  10. primaryzone으로 설정한다.
  11. 그렇지 않으면,
  12. identifierCountryCodeidentifier에 해당하는 지리적 영역이 포함된 ISO 3166-1 Alpha-2 국가 코드로 설정한다.
  13. zoneCountryCodezone에 해당하는 지리적 영역이 포함된 ISO 3166-1 Alpha-2 국가 코드로 설정한다.
  14. identifierCountryCodezoneCountryCode와 같으면,
  15. primaryzone으로 설정한다.
  16. 그렇지 않으면,
  17. countryCodeLineCount를 IANA 시간대 데이터베이스의 zone.tab 파일에서 “country-code” 열이 identifierCountryCode인 줄의 개수로 설정한다.
  18. countryCodeLineCount가 1이면,
  19. countryCodeLine을 “country-code” 열이 identifierCountryCodezone.tab 파일의 줄로 설정한다.
  20. primarycountryCodeLine의 “TZ” 열 내용으로 설정한다.
  21. 그렇지 않으면,
  22. backzoneundefined로 설정한다.
  23. backzoneLinkLines를 IANA 시간대 데이터베이스의 backzone 파일에서 "Link " 또는 "#PACKRATLIST zone.tab Link "로 시작하는 줄의 List로 설정한다.
  24. backzoneLinkLines의 각 요소 line에 대해,
  25. iStringIndexOf(line, "Link ", 0)로 설정한다.
  26. linei + 5부터의 부분 문자열로 설정한다.
  27. backzoneAndLinkStringSplitToList(line, " ")로 설정한다.
  28. Assert: backzoneAndLink에 최소 두 요소가 있고, backzoneAndLink[0]과 backzoneAndLink[1] 모두 사용 가능한 명명된 시간대 식별자이다.
  29. backzoneAndLink[1]이 identifier와 같으면,
  30. Assert: backzoneundefined이다.
  31. backzonebackzoneAndLink[0]으로 설정한다.
  32. Assert: backzoneundefined가 아니다.
  33. primarybackzone으로 설정한다.
  34. primary"Etc/UTC", "Etc/GMT", "GMT" 중 하나이면 primary"UTC"로 설정한다.
  35. primary대체 시간대 식별자이고 이름 변경 대기 기간이 끝나지 않았으면,
  36. renamedIdentifierprimary가 대체한 이름이 변경된 시간대 식별자로 설정한다.
  37. primaryrenamedIdentifier로 설정한다.
  38. recordTime Zone Identifier Record { [[Identifier]]: identifier, [[PrimaryIdentifier]]: primary }로 설정한다.
  39. recordresult에 추가한다.
  40. Assert: resultr가 있고, r.[[Identifier]]"UTC"이고 r.[[PrimaryIdentifier]]"UTC"이다.
  41. result를 반환한다.
Note 1

위 알고리즘은 International Components for Unicode(ICU)의 icu::TimeZone::getIanaID() 동작과 Unicode Common Locale Data Repository(CLDR)의 시간대 식별자 데이터 유지 프로세스에 대응하도록 설계되었습니다.

이 알고리즘은 ISO 3166-1 Alpha-2 국가 코드 경계를 넘지 않고, zone.tabbackzone 파일의 데이터를 사용하여 Link를 기본 시간대 식별자로 해석합니다. 국가 코드가 zone.tab에 한 줄만 있으면 그 줄의 “TZ” 열이 기본 시간대 식별자를 결정합니다. 국가 코드가 zone.tab에 여러 줄 있으면, backzone의 역사적 매핑을 사용하여 올바른 기본 시간대 식별자를 식별해야 합니다.

예를 들어, "Pacific/Truk"(국가 코드 "FM")이 IANA 시간대 데이터베이스 기본 빌드 옵션에서 "Pacific/Port_Moresby"(국가 코드 "PG")에 대한 Link로 식별된다면, zone.tab의 “country-code” 열에서 "FM"에 해당하는 줄을 확인해야 합니다. 한 줄만 있다면 그 줄의 “TZ” 열이 "Pacific/Truk"에 연결된 기본 시간대 식별자를 결정합니다. "FM"이 zone.tab에 여러 줄 있다면, backzone을 확인하고 "Link Pacific/Chuuk Pacific/Truk"과 같은 줄이 있으면 "Pacific/Chuuk"을 기본 시간대 식별자로 사용합니다.

zone.tab이 매핑 데이터의 선호 소스이며, backzone 매핑은 드물게 ISO 3166-1 Alpha-2 국가 코드 경계를 넘을 수 있습니다. 예를 들어, "Atlantic/Jan_Mayen"(국가 코드 "SJ")은 backzone에서 "Europe/Oslo"(국가 코드 "NO")로 매핑됩니다. 2024a IANA 시간대 데이터베이스 릴리스 기준으로, "Atlantic/Jan_Mayen"만 해당 사례가 있습니다.

Note 2
시간대 식별자는 IANA 시간대 데이터베이스에서 시간이 지남에 따라 변경될 수 있습니다. 최소한, 구현체는 AvailableNamedTimeZoneIdentifiers의 결과 변경을 GetAvailableNamedTimeZoneIdentifier가 허용하는 변경으로 제한하는 것이 권장됩니다. 이러한 권장사항을 지원하는 복잡성 때문에, AvailableNamedTimeZoneIdentifiers(그리고 GetAvailableNamedTimeZoneIdentifier의 결과도)는 에이전트의 수명 동안 동일하게 유지하는 것이 권장됩니다.

6.5.2 GetAvailableNamedTimeZoneIdentifier ( timeZoneIdentifier )

The abstract operation GetAvailableNamedTimeZoneIdentifier takes argument timeZoneIdentifier (a String) and returns either a Time Zone Identifier Record or empty. timeZoneIdentifier가 사용 가능한 명명된 시간대 식별자라면, AvailableNamedTimeZoneIdentifiers가 반환한 Record 중 하나를 반환합니다. 그렇지 않으면 empty를 반환합니다. It performs the following steps when called:

  1. AvailableNamedTimeZoneIdentifiers()의 각 요소 record에 대해,
  2. record.[[Identifier]]timeZoneIdentifierASCII-case-insensitive match라면 record를 반환한다.
  3. empty를 반환한다.
Note
어떤 timeZoneIdentifier든, 또는 그와 ASCII-case-insensitive match인 값이든, 결과 Time Zone Identifier Record는 에이전트의 수명 동안 동일한 필드 값을 가져야 합니다. 또한, 시간대 식별자가 에이전트의 수명 동안 동적으로 기본에서 비기본으로 변경되어서는 안 되며, timeZoneIdentifier가 이전 호출 결과의 [[PrimaryIdentifier]] 필드와 ASCII-case-insensitive match라면, GetAvailableNamedTimeZoneIdentifier(timeZoneIdentifier)는 [[Identifier]][[PrimaryIdentifier]]가 동일한 Time Zone Identifier Record를 반환해야 합니다. 이러한 요구사항을 지원하는 복잡성 때문에, AvailableNamedTimeZoneIdentifiers(그리고 GetAvailableNamedTimeZoneIdentifier의 결과도)는 에이전트의 수명 동안 동일하게 유지하는 것이 권장됩니다.

6.5.3 AvailablePrimaryTimeZoneIdentifiers ( )

The abstract operation AvailablePrimaryTimeZoneIdentifiers takes no arguments and returns a List of Strings. 반환된 List는 IANA 시간대 데이터베이스에서 지원되는 Zone 및 Link 이름의 정렬된 List입니다. It performs the following steps when called:

  1. recordsAvailableNamedTimeZoneIdentifiers()로 설정한다.
  2. result를 새로운 빈 List로 설정한다.
  3. records의 각 요소 timeZoneIdentifierRecord에 대해,
  4. timeZoneIdentifierRecord.[[Identifier]]timeZoneIdentifierRecord.[[PrimaryIdentifier]]와 같으면,
  5. timeZoneIdentifierRecord.[[Identifier]]result에 추가한다.
  6. result를 반환한다.

6.5.4 StringSplitToList ( S, separator )

The abstract operation StringSplitToList takes arguments S (a String) and separator (a String) and returns a List of Strings. 반환된 ListS에서 separator를 포함하지 않는 모든 분리된 부분 문자열을 포함하며, 각 부분 문자열은 separator 바로 앞뒤에 위치합니다. 인접한 separator 사이, S 맨 처음 separator 앞, S 맨 끝 separator 뒤에는 빈 문자열이 될 수 있지만, 그 외에는 빈 문자열이 아닙니다. It performs the following steps when called:

  1. Assert: S는 빈 문자열이 아니다.
  2. Assert: separator는 빈 문자열이 아니다.
  3. separatorLengthseparator의 길이로 설정한다.
  4. substrings를 새로운 빈 List로 설정한다.
  5. i를 0으로 설정한다.
  6. jStringIndexOf(S, separator, 0)로 설정한다.
  7. jnot-found가 아닐 때 반복한다,
  8. TSi부터 j까지의 부분 문자열로 설정한다.
  9. Tsubstrings에 추가한다.
  10. ij + separatorLength로 설정한다.
  11. jStringIndexOf(S, separator, i)로 설정한다.
  12. TSi부터의 부분 문자열로 설정한다.
  13. Tsubstrings에 추가한다.
  14. substrings를 반환한다.

6.6 측정 단위 식별자

이 명세는 Unicode Technical Standard #35 Part 2 General, Section 6.2 Unit Identifiers에서 정의된 코어 단위 식별자(또는 코어 단위 ID)를 사용하여 측정 단위를 식별합니다. 정규형은 Unicode Basic Latin 소문자(U+0061 LATIN SMALL LETTER a~z)만 포함하며, 중간에 하이픈(U+002D HYPHEN-MINUS)이 0개 이상 있을 수 있습니다.

허용된 코어 단위 식별자 집합은 제한적입니다. 허용되지 않은 코어 단위 식별자를 사용하려고 하면 RangeError가 발생합니다.

6.6.1 IsWellFormedUnitIdentifier ( unitIdentifier )

The abstract operation IsWellFormedUnitIdentifier takes argument unitIdentifier (a String) and returns a Boolean. unitIdentifier 인자가 허용된 단일 단위이거나 두 허용된 단일 단위의 나눗셈으로 구성된 올바른 형식의 코어 단위 식별자인지 확인합니다. It performs the following steps when called:

  1. IsSanctionedSingleUnitIdentifier(unitIdentifier)가 true이면,
  2. true를 반환한다.
  3. iStringIndexOf(unitIdentifier, "-per-", 0)로 설정한다.
  4. inot-found이거나 StringIndexOf(unitIdentifier, "-per-", i + 1)이 not-found가 아니면,
  5. false를 반환한다.
  6. Assert: "-per-" 5글자 부분 문자열이 unitIdentifier에 정확히 한 번, 인덱스 i에 존재한다.
  7. numerator를 0부터 i까지의 unitIdentifier 부분 문자열로 설정한다.
  8. denominatori + 5부터의 unitIdentifier 부분 문자열로 설정한다.
  9. IsSanctionedSingleUnitIdentifier(numerator)와 IsSanctionedSingleUnitIdentifier(denominator)가 모두 true이면,
  10. true를 반환한다.
  11. false를 반환한다.

6.6.2 IsSanctionedSingleUnitIdentifier ( unitIdentifier )

The abstract operation IsSanctionedSingleUnitIdentifier takes argument unitIdentifier (a String) and returns a Boolean. unitIdentifier 인자가 이 명세의 현재 버전에서 허용된 단일 단위 식별자 목록(release 38 unit validity data의 일부) 중 하나인지 확인합니다. Unicode Technical Standard #35 Part 2 General, Section 6.2 Unit Identifiers에서 논의된 바와 같이, 단일 단위 식별자는 다른 단위 식별자의 곱셈 또는 나눗셈으로 구성되지 않은 코어 단위 식별자입니다. It performs the following steps when called:

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

6.6.3 AvailableCanonicalUnits ( )

The abstract operation AvailableCanonicalUnits takes no arguments and returns a List of Strings. 반환된 List는 코드 유닛의 사전순으로 정렬되어 있으며, Table 2의 각 행(헤더 제외)에 나열된 단순 단위 식별자의 고유 값으로 구성됩니다.

6.7 숫자 시스템 식별자

이 명세는 Unicode Technical Standard #35 Part 3 Numbers, Section 1 Numbering Systems에서 참조된 이름에 해당하는 숫자 시스템 식별자를 사용하여 숫자 시스템을 식별합니다. 정규형은 Unicode Basic Latin 소문자(U+0061 LATIN SMALL LETTER a~z)만 포함합니다.

6.7.1 AvailableCanonicalNumberingSystems ( )

The implementation-defined abstract operation AvailableCanonicalNumberingSystems takes no arguments and returns a List of Strings. 반환된 List는 코드 유닛의 사전순으로 정렬되어 있으며, 구현체가 Intl.DateTimeFormat, Intl.NumberFormat, Intl.RelativeTimeFormat 객체의 기능을 제공하는 숫자 시스템을 식별하는 고유한 정규화된 숫자 시스템 식별자만 포함합니다. List에는 Table 30의 각 행(헤더 제외)의 Numbering System 값이 포함되어야 합니다.

6.8 정렬 유형

이 명세는 Unicode Technical Standard #35 Part 5 Collation, Section 3.1 Collation Types에서 정의된 정렬 유형을 사용하여 정렬을 식별합니다. 정규형은 Unicode Basic Latin 소문자(U+0061 LATIN SMALL LETTER a~z)만 포함하며, 중간에 하이픈(U+002D HYPHEN-MINUS)이 0개 이상 있을 수 있습니다.

6.8.1 AvailableCanonicalCollations ( )

The implementation-defined abstract operation AvailableCanonicalCollations takes no arguments and returns a List of Strings. 반환된 List는 코드 유닛의 사전순으로 정렬되어 있으며, 구현체가 Intl.Collator 객체의 기능을 제공하는 정렬 유형을 식별하는 고유한 정규화된 값만 포함합니다.

6.9 달력 유형

이 명세는 Unicode Technical Standard #35 Part 4 Dates, Section 2 Calendar Elements에서 정의된 달력 유형을 사용하여 달력을 식별합니다. 정규형은 Unicode Basic Latin 소문자(U+0061 LATIN SMALL LETTER a~z)만 포함하며, 중간에 하이픈(U+002D HYPHEN-MINUS)이 0개 이상 있을 수 있습니다.

6.9.1 AvailableCalendars ( )

The implementation-defined abstract operation AvailableCalendars takes no arguments and returns a List of Strings. 반환된 List는 코드 유닛의 사전순으로 정렬되어 있으며, 구현체가 Intl.DateTimeFormat 객체의 기능을 제공하는 달력을 식별하는 고유한 정규화된 달력 유형만 포함합니다(예: "islamicc""islamic-civil" 모두 포함하거나 모두 제외). List에는 "iso8601"가 포함되어야 합니다.

6.10 패턴 문자열 유형

Pattern String"{key}" 형태의 부분 문자열을 0개 이상 포함하는 String 값이며, key는 ASCII 단어 문자로만 구성된 비어 있지 않은 시퀀스일 수 있습니다. 추상 패턴 문자열의 구문은 구현 세부사항이며 ECMA-402 사용자에게 노출되지 않습니다.

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

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

8 Intl 객체

Intl 객체:

8.1 Intl 객체의 값 속성

8.1.1 Intl [ %Symbol.toStringTag% ]

%Symbol.toStringTag% 속성의 초기값은 문자열 값 "Intl"이다.

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

8.2 Intl 객체의 생성자 속성

Intl.Locale을 제외하고, 다음 생성자 각각은 서비스 생성자이며, 로케일에 민감한 서비스를 제공하는 객체를 생성한다.

8.2.1 Intl.Collator ( . . . )

10를 참조.

8.2.2 Intl.DateTimeFormat ( . . . )

11를 참조.

8.2.3 Intl.DisplayNames ( . . . )

12를 참조.

8.2.4 Intl.DurationFormat ( . . . )

13를 참조.

8.2.5 Intl.ListFormat ( . . . )

14를 참조.

8.2.6 Intl.Locale ( . . . )

15를 참조.

8.2.7 Intl.NumberFormat ( . . . )

16를 참조.

8.2.8 Intl.PluralRules ( . . . )

17를 참조.

8.2.9 Intl.RelativeTimeFormat ( . . . )

18를 참조.

8.2.10 Intl.Segmenter ( . . . )

19를 참조.

8.3 Intl 객체의 함수 속성

8.3.1 Intl.getCanonicalLocales ( locales )

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

  1. ll을 ? CanonicalizeLocaleList(locales)로 한다.
  2. CreateArrayFromList(ll)를 반환한다.

8.3.2 Intl.supportedValuesOf ( key )

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

  1. key를 ? ToString(key)로 한다.
  2. 만약 key"calendar"이면,
  3. list를 새로운 빈 List로 한다.
  4. AvailableCalendars()의 각 요소 identifier에 대해,
  5. canonical을 CanonicalizeUValue("ca", identifier)로 한다.
  6. 만약 identifiercanonical과 같으면,
  7. identifierlist에 추가한다.
  8. 그렇지 않고 key"collation"이면,
  9. listAvailableCanonicalCollations()로 한다.
  10. 그렇지 않고 key"currency"이면,
  11. listAvailableCanonicalCurrencies()로 한다.
  12. 그렇지 않고 key"numberingSystem"이면,
  13. listAvailableCanonicalNumberingSystems()로 한다.
  14. 그렇지 않고 key"timeZone"이면,
  15. listAvailablePrimaryTimeZoneIdentifiers()로 한다.
  16. 그렇지 않고 key"unit"이면,
  17. listAvailableCanonicalUnits()로 한다.
  18. 그렇지 않으면,
  19. RangeError 예외를 발생시킨다.
  20. CreateArrayFromList(list)를 반환한다.

9 로케일 및 매개변수 협상

서비스 생성자는 구현의 실제 기능과 localesoptions 인수로 표현된 요청을 협상하기 위해 공통 패턴을 사용합니다. 이러한 공통 동작은 내부 슬롯, 추상 연산, 그리고 아래에 정의된 특수 데이터 타입을 통해 설명됩니다.

사용 가능한 로케일 목록은 임의 순서의 중복 없는 언어 태그 리스트로, 각각은 정상 형식이고, 정규화되며, 유니코드 로케일 확장 시퀀스를 포함하지 않습니다. 이는 특정 컨텍스트 내에서 구현이 기능을 제공하는 모든 로케일을 나타냅니다.

언어 우선순위 목록정상 형식이고 정규화언어 태그 리스트로, 우선순위가 높은 순서대로 로케일 선호도를 나타냅니다. 이는 BCP 47RFC 4647 section 2.3에서 정의된 동일 용어와 대응되지만, "*" 요소를 금지하며 정규화된 내용만 포함합니다.

해결 옵션 디스크립터[[Key]](문자열, 일반적으로 [[RelevantExtensionKeys]] 리스트의 요소)와 [[Property]](문자열) 필드를 가진 레코드이며, 선택적으로 [[Type]](boolean 또는 string)과 [[Values]](empty 또는 ECMAScript 언어 값 리스트)도 포함할 수 있습니다. 이는 객체 생성 중 로케일 해결에 관련된 옵션을 읽는 방법을 설명합니다.

9.1 서비스 생성자의 내부 슬롯

서비스 생성자는 다음 내부 슬롯을 가집니다:

  • [[AvailableLocales]]사용 가능한 로케일 목록입니다. DefaultLocale에서 반환된 값을 반드시 포함해야 합니다. 또한, 두 개 이상의 서브태그를 가진 각 요소에 대해, 동일한 언어 서브태그와 동일한 후속 서브태그의 엄격한 부분집합(즉, 하나 이상 생략)으로 구성된 더 좁은 언어 태그도 포함해야 하며, 이는 ResolveLocale의 잠재적 폴백으로 사용됩니다. 특히, 언어 서브태그, 스크립트 서브태그, 지역 서브태그를 모두 가진 각 요소는 동일한 언어 서브태그와 지역 서브태그만 포함하고 스크립트 서브태그가 없는 또 다른 요소와 함께해야 합니다. 예를 들어,
    • [[AvailableLocales]]"de-DE"가 포함되어 있다면, "de"도 포함되어야 합니다(이는 "de-AT""de-CH"와 같은 요청된 로케일을 만족시키기 위해 선택될 수 있습니다).
    • [[AvailableLocales]]"az-Latn-AZ"가 포함되어 있다면, "az-AZ"도 포함되어야 합니다(이는 "az-Cyrl-AZ"와 같은 요청된 로케일을 만족시키기 위해 "az-Cyrl"이 사용 불가능할 때 선택될 수 있습니다).
  • [[RelevantExtensionKeys]]Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions에서 정의된, 생성된 객체의 기능에 관련된 유니코드 로케일 확장 시퀀스 키 리스트입니다.
  • [[ResolutionOptionDescriptors]]는 객체 생성 중 옵션을 읽기 위해 사용되는 해결 옵션 디스크립터 리스트입니다.
  • [[SortLocaleData]], [[SearchLocaleData]](Intl.Collator용), 그리고 [[LocaleData]](다른 모든 서비스 생성자용)는 레코드입니다. 각 서비스 생성자에 특정한 필드 외에도, 각 레코드는 [[AvailableLocales]]에 포함된 각 로케일에 대한 필드를 가집니다. 각 로케일명 필드의 값은 레코드이며, [[RelevantExtensionKeys]]의 각 요소가 해당 로케일에서 구현이 지원하는 유니코드 로케일 확장 시퀀스 키에 대한 타입 값 리스트를 나타내는 필드명을 식별합니다. 리스트의 첫 번째 요소는 해당 로케일에서 해당 키의 기본값을 제공합니다.
Note
예를 들어, DateTimeFormat 구현은 [[AvailableLocales]] 내부 슬롯에 언어 태그 "fa-IR"를 포함할 수 있으며, 11.2.3에 따라 [[RelevantExtensionKeys]] 내부 슬롯에 키 "ca", "hc", "nu"를 포함해야 합니다. 해당 로케일의 기본 달력은 일반적으로 "persian"이지만, 구현은 "gregory", "islamic", "islamic-civil"도 지원할 수 있습니다. DateTimeFormat [[LocaleData]] 내부 슬롯의 레코드는 [[fa-IR]] 필드에 { [[ca]]: « "persian", "gregory", "islamic", "islamic-civil" », [[hc]]: « … », [[nu]]: « … » }와 같은 값을 포함하며, 다른 로케일명 필드도 동일한 값 구조이지만 리스트의 요소는 다릅니다.

9.2 추상 연산

9.2.1 CanonicalizeLocaleList ( locales )

The abstract operation CanonicalizeLocaleList takes argument locales (ECMAScript 언어 값) and returns 정상 완료 시 언어 우선순위 목록 또는 throw 완료. It performs the following steps when called:

  1. localesundefined이면,
  2. 새로운 빈 리스트를 반환한다.
  3. seen을 새로운 빈 리스트로 한다.
  4. locales가 문자열이거나 locales가 객체이고 [[InitializedLocale]] 내부 슬롯을 가진 경우,
  5. OCreateArrayFromListlocales »)로 한다.
  6. 그렇지 않으면,
  7. O를 ? ToObject(locales)로 한다.
  8. len을 ? LengthOfArrayLike(O)로 한다.
  9. k를 0으로 한다.
  10. 반복, k < len 동안,
  11. Pk를 ! ToString(𝔽(k))로 한다.
  12. kPresent를 ? HasProperty(O, Pk)로 한다.
  13. kPresenttrue이면,
  14. kValue를 ? Get(O, Pk)로 한다.
  15. kValue가 문자열이 아니고 객체도 아니면 TypeError 예외를 throw한다.
  16. kValue가 객체이고 [[InitializedLocale]] 내부 슬롯을 가진 경우,
  17. tagkValue.[[Locale]]로 한다.
  18. 그렇지 않으면,
  19. tag를 ? ToString(kValue)로 한다.
  20. IsWellFormedLanguageTag(tag)가 false이면 RangeError 예외를 throw한다.
  21. canonicalizedTagCanonicalizeUnicodeLocaleId(tag)로 한다.
  22. seencanonicalizedTag가 없으면 seen에 추가한다.
  23. kk + 1로 한다.
  24. seen을 반환한다.
Note 1
비규범적 요약: 이 추상 연산은 locales 인수를 배열로 해석하고, 그 요소를 리스트에 복사하며, 요소가 정상 형식의 언어 태그인지 검증하고 정규화하며, 중복을 생략합니다.
Note 2
kValue가 문자열 또는 객체여야 한다는 요구는 숫자 값 NaN언어 태그 "nan"으로 해석되지 않음을 의미합니다. "nan"은 민난 중국어를 의미합니다.

9.2.2 CanonicalizeUValue ( ukey: Unicode Technical Standard #35 Part 1 Core Section 3.6.1 Key and Type Definitions에서 정의된 유니코드 로케일 확장 시퀀스 키, uvalue: 문자열, ): 문자열

The abstract operation UNKNOWN takes UNPARSEABLE ARGUMENTS. 반환된 문자열은 ukey의 값으로서 uvalue의 정규화 및 대소문자 규칙화된 형태입니다. It performs the following steps when called:

  1. lowerValueuvalue의 ASCII 소문자로 한다.
  2. canonicalizedUnicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalization Section 5 Canonicalizing Syntax, Processing LocaleIds에 따라 ukey의 값으로서 lowerValue를 정규화한 문자열 값으로 한다.
  3. NOTE: 구현에서는 Common Locale Data Repository(https://cldr.unicode.org/)에서 제공하는 common/bcp47의 'u' 확장 데이터를 사용하는 것이 권장됩니다.
  4. canonicalized를 반환한다.

9.2.3 LookupMatchingLocaleByPrefix ( availableLocales, requestedLocales )

The abstract operation LookupMatchingLocaleByPrefix takes arguments availableLocales (사용 가능한 로케일 목록) and requestedLocales (언어 우선순위 목록) and returns [[locale]](유니코드 정규화된 로케일 식별자)와 [[extension]](유니코드 로케일 확장 시퀀스 또는 empty) 필드를 가진 레코드 또는 undefined. 이는 BCP 47RFC 4647 section 3.4에서 정의된 lookup 알고리즘을 사용하여, 유니코드 로케일 확장 시퀀스를 무시하고 requestedLocales를 만족시키기 위한 availableLocales의 최적 요소를 결정합니다. 비기본 매치가 발견되면, availableLocales의 매칭 언어 태그requestedLocales의 해당 요소의 유니코드 로케일 확장 시퀀스를(없으면 empty) 포함하는 레코드를 반환합니다. It performs the following steps when called:

  1. requestedLocales의 각 요소 locale에 대해,
  2. extensionempty로 한다.
  3. locale에 유니코드 로케일 확장 시퀀스가 포함되어 있으면,
  4. extensionlocale의 유니코드 로케일 확장 시퀀스로 한다.
  5. locale을 유니코드 로케일 확장 시퀀스가 제거된 문자열 값으로 한다.
  6. prefixlocale으로 한다.
  7. 반복, prefix가 빈 문자열이 아닐 동안,
  8. availableLocalesprefix가 포함되어 있으면, { [[locale]]: prefix, [[extension]]: extension } 레코드를 반환한다.
  9. prefix"-" (코드 유닛 0x002D HYPHEN-MINUS)가 포함되어 있으면, posprefix에서 마지막 "-"의 인덱스로 한다; 그렇지 않으면 pos를 0으로 한다.
  10. 반복, pos ≥ 2이고 prefixpos - 2부터 pos - 1까지의 부분 문자열이 "-"일 동안,
  11. pospos - 2로 한다.
  12. prefix를 0부터 pos까지의 부분 문자열로 한다.
  13. undefined를 반환한다.
Note
요청된 로케일에 Unicode Technical Standard #35 Part 1 Core BCP 47 T Extension 서브태그 시퀀스가 포함된 경우, 이 알고리즘의 절단 과정에서 일시적으로 잘못된 언어 태그가 생성될 수 있습니다. 그러나 availableLocales에는 유효한 언어 태그만 포함되므로 반환되지 않습니다.

9.2.4 LookupMatchingLocaleByBestFit ( availableLocales, requestedLocales )

The implementation-defined abstract operation LookupMatchingLocaleByBestFit takes arguments availableLocales (사용 가능한 로케일 목록) and requestedLocales (언어 우선순위 목록) and returns [[locale]](유니코드 정규화된 로케일 식별자)와 [[extension]](유니코드 로케일 확장 시퀀스 또는 empty) 필드를 가진 레코드 또는 undefined. 이는 구현에 따라 달라지는 알고리즘으로, 유니코드 로케일 확장 시퀀스를 무시하고 requestedLocales를 만족시키기 위한 availableLocales의 최적 요소를 결정합니다. 일반 사용자가 LookupMatchingLocaleByPrefix 알고리즘보다 더 적합하다고 여길 결과를 제공해야 합니다. 비기본 매치가 발견되면, availableLocales의 매칭 언어 태그requestedLocales의 해당 요소의 유니코드 로케일 확장 시퀀스를(없으면 empty) 포함하는 레코드를 반환합니다.

9.2.5 UnicodeExtensionComponents ( extension )

The abstract operation UnicodeExtensionComponents takes argument extension (유니코드 로케일 확장 시퀀스) and returns [[Attributes]][[Keywords]] 필드를 가진 레코드. extension을 고유한 속성 리스트와 고유 키를 가진 키워드 리스트로 분해합니다. 속성이나 키워드 키가 반복될 경우 첫 번째만 사용합니다. It performs the following steps when called:

  1. Assert: extension의 ASCII 소문자가 extension과 같다.
  2. Assert: extension의 0부터 3까지의 부분 문자열이 "-u-"이다.
  3. attributes를 새로운 빈 리스트로 한다.
  4. keywords를 새로운 빈 리스트로 한다.
  5. keywordundefined로 한다.
  6. sizeextension의 길이로 한다.
  7. k를 3으로 한다.
  8. 반복, k < size 동안,
  9. eStringIndexOf(extension, "-", k)로 한다.
  10. enot-found이면 lensize - k로 한다; 그렇지 않으면 lene - k로 한다.
  11. subtagextensionk부터 k + len까지의 부분 문자열로 한다.
  12. NOTE: 키워드는 첫 번째가 길이 2인 키이고, 이후(있다면) 길이가 3~8인 서브태그가 값과 함께 "-"로 연결된 시퀀스입니다. 속성은 모든 키워드 앞에 위치한 길이 3~8의 단일 서브태그입니다.
  13. Assert: len ≥ 2.
  14. keywordundefined이고 len ≠ 2이면,
  15. subtagattributes에 없으면 추가한다.
  16. 그렇지 않고 len = 2이면,
  17. keyword를 { [[Key]]: subtag, [[Value]]: "" } 레코드로 한다.
  18. keywords[[Key]]keyword.[[Key]]인 요소가 없으면 keyword를 추가한다.
  19. 그렇지 않고 keyword.[[Value]]가 빈 문자열이면,
  20. keyword.[[Value]]subtag로 한다.
  21. 그렇지 않으면,
  22. keyword.[[Value]]keyword.[[Value]], "-", subtag의 문자열 연결로 한다.
  23. kk + len + 1로 한다.
  24. { [[Attributes]]: attributes, [[Keywords]]: keywords } 레코드를 반환한다.

9.2.6 InsertUnicodeExtensionAndCanonicalize ( locale, attributes, keywords )

The abstract operation InsertUnicodeExtensionAndCanonicalize takes arguments locale (언어 태그), attributes (문자열 리스트), and keywords (레코드 리스트) and returns 유니코드 정규화된 로케일 식별자. attributeskeywordslocale에 유니코드 로케일 확장 시퀀스로 통합하고 정규화된 결과를 반환합니다. It performs the following steps when called:

  1. Assert: locale에 유니코드 로케일 확장 시퀀스가 포함되어 있지 않다.
  2. extension"-u"로 한다.
  3. attributes의 각 요소 attr에 대해,
  4. extensionextension, "-", attr의 문자열 연결로 한다.
  5. 각 레코드 { [[Key]], [[Value]] } keyword에 대해,
  6. extensionextension, "-", keyword.[[Key]]의 문자열 연결로 한다.
  7. keyword.[[Value]]가 빈 문자열이 아니면, extensionextension, "-", keyword.[[Value]]의 문자열 연결로 한다.
  8. extension"-u"이면 CanonicalizeUnicodeLocaleId(locale)를 반환한다.
  9. privateIndexStringIndexOf(locale, "-x-", 0)로 한다.
  10. privateIndexnot-found이면,
  11. newLocalelocaleextension의 문자열 연결로 한다.
  12. 그렇지 않으면,
  13. preExtensionlocale의 0부터 privateIndex까지의 부분 문자열로 한다.
  14. postExtensionlocaleprivateIndex부터의 부분 문자열로 한다.
  15. newLocalepreExtension, extension, postExtension의 문자열 연결로 한다.
  16. Assert: IsWellFormedLanguageTag(newLocale)가 true이다.
  17. CanonicalizeUnicodeLocaleId(newLocale)를 반환한다.

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

The abstract operation ResolveLocale takes arguments availableLocales (사용 가능한 로케일 목록), requestedLocales (언어 우선순위 목록), options (레코드), relevantExtensionKeys (문자열 리스트), and localeData (레코드) and returns 레코드. 이는 BCP 47RFC 4647 section 3에서 정의된 "lookup"을 수행하며, options.[[localeMatcher]]에 따라 LookupMatchingLocaleByBestFit 또는 LookupMatchingLocaleByPrefix 알고리즘을 사용하여 유니코드 로케일 확장 시퀀스를 무시하고 requestedLocales를 만족시키기 위한 availableLocales의 최적 요소를 결정합니다. 매치된 requestedLocales 요소에 유니코드 로케일 확장 시퀀스가 포함되어 있으면, 반환된 레코드의 [[Locale]] 필드에 복사되며, keyword 유니코드 로케일 비종결 기호의 key 값이 relevantExtensionKeys에 포함되지 않거나 type 값이 options의 다른 값으로 대체된 경우 생략됩니다. It performs the following steps when called:

  1. matcheroptions.[[localeMatcher]]로 한다.
  2. matcher"lookup"이면,
  3. rLookupMatchingLocaleByPrefix(availableLocales, requestedLocales)로 한다.
  4. 그렇지 않으면,
  5. rLookupMatchingLocaleByBestFit(availableLocales, requestedLocales)로 한다.
  6. rundefined이면, r를 { [[locale]]: DefaultLocale(), [[extension]]: empty } 레코드로 한다.
  7. foundLocaler.[[locale]]로 한다.
  8. foundLocaleDatalocaleData.[[<foundLocale>]]로 한다.
  9. Assert: foundLocaleData가 레코드이다.
  10. result를 새로운 레코드로 한다.
  11. result.[[LocaleData]]foundLocaleData로 한다.
  12. r.[[extension]]empty가 아니면,
  13. componentsUnicodeExtensionComponents(r.[[extension]])로 한다.
  14. keywordscomponents.[[Keywords]]로 한다.
  15. 그렇지 않으면,
  16. keywords를 새로운 빈 리스트로 한다.
  17. supportedKeywords를 새로운 빈 리스트로 한다.
  18. relevantExtensionKeys의 각 요소 key에 대해,
  19. keyLocaleDatafoundLocaleData.[[<key>]]로 한다.
  20. Assert: keyLocaleData가 리스트이다.
  21. valuekeyLocaleData[0]로 한다.
  22. Assert: value가 문자열이거나 null이다.
  23. supportedKeywordempty로 한다.
  24. keywords[[Key]]key인 요소가 있으면,
  25. entrykeywords[[Key]]key인 요소로 한다.
  26. requestedValueentry.[[Value]]로 한다.
  27. requestedValue가 빈 문자열이 아니면,
  28. keyLocaleDatarequestedValue가 포함되어 있으면,
  29. valuerequestedValue로 한다.
  30. supportedKeyword를 { [[Key]]: key, [[Value]]: value } 레코드로 한다.
  31. 그렇지 않고 keyLocaleData"true"가 포함되어 있으면,
  32. value"true"로 한다.
  33. supportedKeyword를 { [[Key]]: key, [[Value]]: "" } 레코드로 한다.
  34. Assert: options에 [[<key>]] 필드가 있다.
  35. optionsValueoptions.[[<key>]]로 한다.
  36. Assert: optionsValue가 문자열이거나 undefined 또는 null이다.
  37. optionsValue가 문자열이면,
  38. ukeykey의 ASCII 소문자로 한다.
  39. optionsValue를 CanonicalizeUValue(ukey, optionsValue)로 한다.
  40. optionsValue가 빈 문자열이면,
  41. optionsValue"true"로 한다.
  42. SameValue(optionsValue, value)가 false이고 keyLocaleDataoptionsValue가 포함되어 있으면,
  43. valueoptionsValue로 한다.
  44. supportedKeywordempty로 한다.
  45. supportedKeywordempty가 아니면 supportedKeywords에 추가한다.
  46. result.[[<key>]]를 value로 한다.
  47. supportedKeywords가 비어 있지 않으면,
  48. supportedAttributes를 새로운 빈 리스트로 한다.
  49. foundLocaleInsertUnicodeExtensionAndCanonicalize(foundLocale, supportedAttributes, supportedKeywords)로 한다.
  50. result.[[Locale]]foundLocale로 한다.
  51. result를 반환한다.

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

The abstract operation ResolveOptions takes arguments constructor (서비스 생성자), localeData (레코드), locales (ECMAScript 언어 값), and options (ECMAScript 언어 값) and optional arguments specialBehaviours (열거형 리스트) and modifyResolutionOptions (매개변수 하나를 가진 추상 클로저) and returns 정상 완료 시 [[Options]](객체), [[ResolvedLocale]](레코드), [[ResolutionOptions]](레코드) 필드를 가진 레코드 또는 throw 완료. constructor의 입력을 읽고 로케일로 해결합니다. It performs the following steps when called:

  1. requestedLocales를 ? CanonicalizeLocaleList(locales)로 한다.
  2. specialBehaviours가 존재하고 require-options을 포함하며 optionsundefined이면 TypeError 예외를 throw한다.
  3. specialBehaviours가 존재하고 coerce-options을 포함하면 options를 ? CoerceOptionsToObject(options)로 한다. 그렇지 않으면 options를 ? GetOptionsObject(options)로 한다.
  4. matcher를 ? GetOption(options, "localeMatcher", string, « "lookup", "best fit" », "best fit")로 한다.
  5. opt를 { [[localeMatcher]]: matcher } 레코드로 한다.
  6. constructor.[[ResolutionOptionDescriptors]]의 각 해결 옵션 디스크립터 desc에 대해,
  7. desc[[Type]] 필드가 있으면 typedesc.[[Type]]으로 한다. 그렇지 않으면 typestring으로 한다.
  8. desc[[Values]] 필드가 있으면 valuesdesc.[[Values]]로 한다. 그렇지 않으면 valuesempty로 한다.
  9. value를 ? GetOption(options, desc.[[Property]], type, values, undefined)로 한다.
  10. valueundefined가 아니면,
  11. value를 ! ToString(value)로 한다.
  12. valuetype 유니코드 로케일 비종결 기호와 일치하지 않으면 RangeError 예외를 throw한다.
  13. keydesc.[[Key]]로 한다.
  14. opt.[[<key>]]를 value로 한다.
  15. modifyResolutionOptions가 존재하면 ! modifyResolutionOptions(opt)를 수행한다.
  16. resolutionResolveLocale(constructor.[[AvailableLocales]], requestedLocales, opt, constructor.[[RelevantExtensionKeys]], localeData)로 한다.
  17. { [[Options]]: options, [[ResolvedLocale]]: resolution, [[ResolutionOptions]]: opt } 레코드를 반환한다.

9.2.9 FilterLocales ( availableLocales, requestedLocales, options )

The abstract operation FilterLocales takes arguments availableLocales (사용 가능한 로케일 목록), requestedLocales (언어 우선순위 목록), and options (ECMAScript 언어 값) and returns 정상 완료 시 유니코드 정규화된 로케일 식별자 리스트 또는 throw 완료. 이는 BCP 47RFC 4647 section 3에서 정의된 "filtering"을 수행하며, options에 지정된 알고리즘에 따라 LookupMatchingLocaleByBestFit 또는 LookupMatchingLocaleByPrefix를 사용하여 availableLocales에 매칭되는 requestedLocales의 요소를 상대적 순서를 유지하며 반환합니다. It performs the following steps when called:

  1. options를 ? CoerceOptionsToObject(options)로 한다.
  2. matcher를 ? GetOption(options, "localeMatcher", string, « "lookup", "best fit" », "best fit")로 한다.
  3. subset을 새로운 빈 리스트로 한다.
  4. requestedLocales의 각 요소 locale에 대해,
  5. matcher"lookup"이면,
  6. matchLookupMatchingLocaleByPrefix(availableLocales, « locale »)로 한다.
  7. 그렇지 않으면,
  8. matchLookupMatchingLocaleByBestFit(availableLocales, « locale »)로 한다.
  9. matchundefined가 아니면 subsetlocale을 추가한다.
  10. CreateArrayFromList(subset)을 반환한다.

9.2.10 CoerceOptionsToObject ( options )

The abstract operation CoerceOptionsToObject takes argument options (ECMAScript 언어 값) and returns 정상 완료 시 객체 또는 throw 완료. optionsGetOption에 사용할 수 있는 객체로 강제 변환하며, 기본값은 빈 객체입니다. null이 아닌 원시 값을 객체로 강제 변환하므로, 새로운 기능에서는 GetOptionsObject 사용을 권장합니다. It performs the following steps when called:

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

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

The abstract operation GetOption takes arguments options (객체), property (프로퍼티 키), type (boolean 또는 string), values (empty 또는 ECMAScript 언어 값 리스트), and default (required 또는 ECMAScript 언어 값) and returns 정상 완료 시 ECMAScript 언어 값 또는 throw 완료. options의 지정된 프로퍼티 값을 추출하고, 요구된 type으로 변환하며, valuesempty가 아니면 허용되는 값인지 확인하고, 값이 undefined이면 default를 대체합니다. It performs the following steps when called:

  1. value를 ? Get(options, property)로 한다.
  2. valueundefined이면,
  3. defaultrequired이면 RangeError 예외를 throw한다.
  4. default를 반환한다.
  5. typeboolean이면,
  6. valueToBoolean(value)로 한다.
  7. 그렇지 않으면,
  8. Assert: typestring이다.
  9. value를 ? ToString(value)로 한다.
  10. valuesempty가 아니고 valuesvalue가 없으면 RangeError 예외를 throw한다.
  11. value를 반환한다.

9.2.12 GetBooleanOrStringNumberFormatOption ( options, property, stringValues, fallback )

The abstract operation GetBooleanOrStringNumberFormatOption takes arguments options (객체), property (프로퍼티 키), stringValues (문자열 리스트), and fallback (ECMAScript 언어 값) and returns 정상 완료 시 Boolean, 문자열 또는 fallback, 또는 throw 완료. options 객체에서 property 이름의 값을 추출합니다. 값이 undefined이면 fallback을 반환하고, 값이 true이면 true를 반환하며, 값이 false로 강제 변환되면 false를 반환합니다. 그렇지 않으면 값을 문자열로 강제 변환하고, stringValues에 허용된 값이면 반환합니다. It performs the following steps when called:

  1. value를 ? Get(options, property)로 한다.
  2. valueundefined이면 fallback을 반환한다.
  3. valuetrue이면 true를 반환한다.
  4. ToBoolean(value)가 false이면 false를 반환한다.
  5. value를 ? ToString(value)로 한다.
  6. stringValuesvalue가 없으면 RangeError 예외를 throw한다.
  7. value를 반환한다.

9.2.13 DefaultNumberOption ( value, minimum, maximum, fallback )

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

  1. valueundefined이면 fallback을 반환한다.
  2. value를 ? ToNumber(value)로 한다.
  3. value가 유한하지 않거나 (value) < minimum 또는 (value) > maximum이면 RangeError 예외를 throw한다.
  4. floor((value))를 반환한다.

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

The abstract operation GetNumberOption takes arguments options (객체), property (문자열), minimum (정수), maximum (정수), and fallback (정수 또는 undefined) and returns 정상 완료 시 정수 또는 undefined, 또는 throw 완료. options 객체에서 property 이름의 값을 추출하고, 정수로 변환하며, 허용 범위 내인지 확인하고, 필요시 fallback 값을 채웁니다. It performs the following steps when called:

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

9.2.15 PartitionPattern ( pattern )

The abstract operation PartitionPattern takes argument pattern (패턴 문자열) and returns [[Type]](문자열)과 [[Value]](문자열 또는 undefined) 필드를 가진 레코드 리스트. [[Type]]"literal"이면 [[Value]] 필드는 문자열 값이고, 그렇지 않으면 undefined입니다. It performs the following steps when called:

  1. result를 새로운 빈 리스트로 한다.
  2. placeholderEnd를 -1로 한다.
  3. placeholderStartStringIndexOf(pattern, "{", 0)로 한다.
  4. 반복, placeholderStartnot-found가 아닐 동안,
  5. literalpatternplaceholderEnd + 1부터 placeholderStart까지의 부분 문자열로 한다.
  6. literal이 빈 문자열이 아니면,
  7. { [[Type]]: "literal", [[Value]]: literal } 레코드를 result에 추가한다.
  8. placeholderEndStringIndexOf(pattern, "}", placeholderStart)로 한다.
  9. Assert: placeholderEndnot-found가 아니고 placeholderStart < placeholderEnd이다.
  10. placeholderNamepatternplaceholderStart + 1부터 placeholderEnd까지의 부분 문자열로 한다.
  11. { [[Type]]: placeholderName, [[Value]]: undefined } 레코드를 result에 추가한다.
  12. placeholderStartStringIndexOf(pattern, "{", placeholderEnd)로 한다.
  13. tailpatternplaceholderEnd + 1부터의 부분 문자열로 한다.
  14. tail이 빈 문자열이 아니면,
  15. { [[Type]]: "literal", [[Value]]: tail } 레코드를 result에 추가한다.
  16. 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. roptionsResolution.[[ResolvedLocale]]로 한다.
  15. collator.[[Locale]]r.[[Locale]]를 설정한다.
  16. r.[[co]]null이면, collation"default"로 한다. 그렇지 않으면 collationr.[[co]]로 한다.
  17. collator.[[Collation]]collation을 설정한다.
  18. collator.[[Numeric]]SameValue(r.[[kn]], "true")를 설정한다.
  19. collator.[[CaseFirst]]r.[[kf]]를 설정한다.
  20. resolvedLocaleDatar.[[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 값을 p로 한다.
  6. 현재 행의 Internal Slot 값에 해당하는 collator의 내부 슬롯 값을 v로 한다.
  7. 현재 행에 Extension Key 값이 있으면,
  8. extensionKey를 현재 행의 Extension Key 값으로 한다.
  9. %Intl.Collator%.[[RelevantExtensionKeys]]extensionKey가 포함되지 않으면,
  10. vundefined로 설정한다.
  11. vundefined가 아니면,
  12. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  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. F10.3.3.1에서 정의된 새로운 내장 함수 객체로 한다.
  5. F.[[Collator]]collator를 설정한다.
  6. collator.[[BoundCompare]]F를 설정한다.
  7. collator.[[BoundCompare]]를 반환한다.
Note
반환된 함수는 collator에 바인딩되어 있으므로 Array.prototype.sort나 다른 함수에 직접 전달할 수 있다.

10.3.3.1 Collator 비교 함수

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

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

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

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

10.3.3.2 CompareStrings ( collator, x, y )

The implementation-defined abstract operation CompareStrings takes arguments collator (an Intl.Collator), x (a String), and y (a String) and returns a Number, but not NaN. 반환된 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의 규범적 선택적 생성자 모드를 지원한다면,
  4. thisthis 값으로 한다.
  5. ChainDateTimeFormat(dateTimeFormat, NewTarget, this)를 반환한다.
  6. dateTimeFormat을 반환한다.

11.1.1.1 ChainDateTimeFormat ( dateTimeFormat, newTarget, this )

The abstract operation ChainDateTimeFormat takes arguments dateTimeFormat (an Intl.DateTimeFormat), newTarget (an ECMAScript language value), and this (an ECMAScript language value) and returns either a normal completion containing an Object or a throw completion. It performs the following steps when called:

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

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

The abstract operation CreateDateTimeFormat takes arguments newTarget (a constructor), locales (an ECMAScript language value), options (an ECMAScript language value), required (date, time, or any), and defaults (date, time, or all) and returns either a normal completion containing a DateTimeFormat object or a throw completion. 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. hour12undefined로 한다.
  3. modifyResolutionOptions를 (options) 파라미터를 가지며 hour12를 캡처하는 새로운 추상 클로저로 하고, 호출 시 다음 단계를 수행한다:
  4. hour12options.[[hour12]]로 설정한다.
  5. options에서 [[hour12]] 필드를 제거한다.
  6. hour12undefined가 아니면, options.[[hc]]null로 설정한다.
  7. optionsResolution을 ? ResolveOptions(%Intl.DateTimeFormat%, %Intl.DateTimeFormat%.[[LocaleData]], locales, options, « coerce-options », modifyResolutionOptions)로 한다.
  8. optionsoptionsResolution.[[Options]]로 설정한다.
  9. roptionsResolution.[[ResolvedLocale]]로 한다.
  10. dateTimeFormat.[[Locale]]r.[[Locale]]로 설정한다.
  11. resolvedCalendarr.[[ca]]로 한다.
  12. dateTimeFormat.[[Calendar]]resolvedCalendar로 설정한다.
  13. dateTimeFormat.[[NumberingSystem]]r.[[nu]]로 설정한다.
  14. resolvedLocaleDatar.[[LocaleData]]로 한다.
  15. hour12true이면,
  16. hcresolvedLocaleData.[[hourCycle12]]로 한다.
  17. hour12false이면,
  18. hcresolvedLocaleData.[[hourCycle24]]로 한다.
  19. 아니면,
  20. hour12undefined임을 단언한다.
  21. hcr.[[hc]]로 한다.
  22. hcnull이면, hcresolvedLocaleData.[[hourCycle]]로 설정한다.
  23. timeZone을 ? Get(options, "timeZone")로 한다.
  24. timeZoneundefined이면,
  25. timeZoneSystemTimeZoneIdentifier()로 설정한다.
  26. 아니면,
  27. timeZone을 ? ToString(timeZone)로 설정한다.
  28. IsTimeZoneOffsetString(timeZone)가 true이면,
  29. parseResultParseText(StringToCodePoints(timeZone), UTCOffset)로 한다.
  30. parseResultParse Node임을 단언한다.
  31. parseResultMinuteSecond Parse Node가 둘 이상 있으면, RangeError 예외를 던진다.
  32. offsetNanosecondsParseTimeZoneOffsetString(timeZone)로 한다.
  33. offsetMinutesoffsetNanoseconds / (6 × 1010)로 한다.
  34. offsetMinutes가 정수임을 단언한다.
  35. timeZoneFormatOffsetTimeZoneIdentifier(offsetMinutes)로 설정한다.
  36. 아니면,
  37. timeZoneIdentifierRecordGetAvailableNamedTimeZoneIdentifier(timeZone)로 한다.
  38. timeZoneIdentifierRecordempty이면, RangeError 예외를 던진다.
  39. timeZonetimeZoneIdentifierRecord.[[PrimaryIdentifier]]로 설정한다.
  40. dateTimeFormat.[[TimeZone]]timeZone으로 설정한다.
  41. formatOptions를 새로운 Record로 한다.
  42. formatOptions.[[hourCycle]]hc로 설정한다.
  43. hasExplicitFormatComponentsfalse로 한다.
  44. Table 16의 각 행(헤더 행 제외)을 표 순서대로 반복한다:
  45. prop를 현재 행의 Property 열에 있는 이름으로 한다.
  46. prop"fractionalSecondDigits"이면,
  47. value를 ? GetNumberOption(options, "fractionalSecondDigits", 1, 3, undefined)로 한다.
  48. 아니면,
  49. values를 현재 행의 Values 열에 있는 문자열들의 리스트로 한다.
  50. value를 ? GetOption(options, prop, string, values, undefined)로 한다.
  51. formatOptions.[[<prop>]]를 value로 설정한다.
  52. valueundefined가 아니면,
  53. hasExplicitFormatComponentstrue로 설정한다.
  54. formatMatcher를 ? GetOption(options, "formatMatcher", string, « "basic", "best fit" », "best fit")로 한다.
  55. dateStyle을 ? GetOption(options, "dateStyle", string, « "full", "long", "medium", "short" », undefined)로 한다.
  56. dateTimeFormat.[[DateStyle]]dateStyle로 설정한다.
  57. timeStyle을 ? GetOption(options, "timeStyle", string, « "full", "long", "medium", "short" », undefined)로 한다.
  58. dateTimeFormat.[[TimeStyle]]timeStyle로 설정한다.
  59. dateStyleundefined가 아니거나 timeStyleundefined가 아니면,
  60. hasExplicitFormatComponentstrue이면,
  61. TypeError 예외를 던진다.
  62. requireddate이고 timeStyleundefined가 아니면,
  63. TypeError 예외를 던진다.
  64. requiredtime이고 dateStyleundefined가 아니면,
  65. TypeError 예외를 던진다.
  66. stylesresolvedLocaleData.[[styles]].[[<resolvedCalendar>]]로 한다.
  67. bestFormatDateTimeStyleFormat(dateStyle, timeStyle, styles)로 한다.
  68. 아니면,
  69. needDefaultstrue로 한다.
  70. requireddate 또는 any이면,
  71. « "weekday", "year", "month", "day" »의 각 프로퍼티 이름 prop에 대해 반복한다:
  72. valueformatOptions.[[<prop>]]로 한다.
  73. valueundefined가 아니면, needDefaultsfalse로 설정한다.
  74. requiredtime 또는 any이면,
  75. « "dayPeriod", "hour", "minute", "second", "fractionalSecondDigits" »의 각 프로퍼티 이름 prop에 대해 반복한다:
  76. valueformatOptions.[[<prop>]]로 한다.
  77. valueundefined가 아니면, needDefaultsfalse로 설정한다.
  78. needDefaultstrue이고 defaultsdate 또는 all이면,
  79. « "year", "month", "day" »의 각 프로퍼티 이름 prop에 대해 반복한다:
  80. formatOptions.[[<prop>]]를 "numeric"으로 설정한다.
  81. needDefaultstrue이고 defaultstime 또는 all이면,
  82. « "hour", "minute", "second" »의 각 프로퍼티 이름 prop에 대해 반복한다:
  83. formatOptions.[[<prop>]]를 "numeric"으로 설정한다.
  84. formatsresolvedLocaleData.[[formats]].[[<resolvedCalendar>]]로 한다.
  85. formatMatcher"basic"이면,
  86. bestFormatBasicFormatMatcher(formatOptions, formats)로 한다.
  87. 아니면,
  88. bestFormatBestFitFormatMatcher(formatOptions, formats)로 한다.
  89. dateTimeFormat.[[DateTimeFormat]]bestFormat으로 설정한다.
  90. bestFormat[[hour]] 필드가 있으면,
  91. dateTimeFormat.[[HourCycle]]hc로 설정한다.
  92. dateTimeFormat을 반환한다.

11.1.3 FormatOffsetTimeZoneIdentifier ( offsetMinutes )

The abstract operation FormatOffsetTimeZoneIdentifier takes argument offsetMinutes (an integer) and returns a String. UTC 오프셋(분 단위)을 ±HH:MM 형식의 UTC 오프셋 문자열로 포맷한다. It performs the following steps when called:

  1. offsetMinutes ≥ 0이면, sign을 코드 유닛 0x002B (PLUS 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 생성자:

  • [[Prototype]] 내부 슬롯의 값은 %Function.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는 날짜 및 시간 포매팅에 관련된 네 가지 로케일 확장 키를 설명한다: "ca"는 달력, "hc"는 시간 주기, "nu"는 숫자 포매팅(포매팅된 숫자), "tz"는 시간대이다. DateTimeFormat은 시간대를 옵션 객체의 "timeZone" 프로퍼티로 지정해야 한다.

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

[[LocaleData]] 내부 슬롯의 값은 9.1에 명시된 제약과 다음 추가 제약 내에서 구현 정의된다. 모든 로케일 값 locale에 대해:

  • [[LocaleData]].[[<locale>]].[[nu]]"native", "traditio", "finance" 값을 포함하지 않는 리스트여야 한다.
  • [[LocaleData]].[[<locale>]].[[hc]]는 « null, "h11", "h12", "h23", "h24" »여야 한다.
  • [[LocaleData]].[[<locale>]].[[hourCycle]]"h11", "h12", "h23", "h24" 중 하나의 문자열이어야 한다.
  • [[LocaleData]].[[<locale>]].[[hourCycle12]]"h11" 또는 "h12" 중 하나의 문자열이어야 한다.
  • [[LocaleData]].[[<locale>]].[[hourCycle24]]"h23" 또는 "h24" 중 하나의 문자열이어야 한다.
  • [[LocaleData]].[[<locale>]]는 [[formats]] 필드를 가져야 한다. 이 [[formats]] 필드의 값은 각 달력 값 calendar에 대해 [[<calendar>]] 필드를 가진 레코드여야 한다. 각 [[<calendar>]] 필드의 값은 DateTime Format Record의 리스트여야 한다. 해당 리스트의 여러 레코드는 동일한 필드 집합을 사용할 수 있지만, 적어도 하나의 필드 값은 달라야 한다. 다음 집합은 각 로케일에 대해 제공되어야 한다:
    • weekday, year, month, day, hour, minute, second, fractionalSecondDigits
    • weekday, year, month, day, hour, minute, second
    • weekday, year, month, day
    • year, month, day
    • year, month
    • month, day
    • month
    • hour, minute, second, fractionalSecondDigits
    • hour, minute, second
    • hour, minute
    • dayPeriod, hour, minute, second, fractionalSecondDigits
    • dayPeriod, hour, minute, second
    • dayPeriod, hour, minute
    • dayPeriod, hour
  • [[LocaleData]].[[<locale>]]는 [[styles]] 필드를 가져야 한다. 이 [[styles]] 필드의 값은 각 달력 값 calendar에 대해 [[<calendar>]] 필드를 가진 레코드여야 한다. 각 [[<calendar>]] 필드의 값은 DateTime Styles Record여야 한다.

11.2.3.1 DateTime Format Record

DateTime Format RecordTable 5에 정의된 필드를 가진다.

Table 5: DateTime Format Record
필드 이름 값 타입 설명
[[weekday]] Table 16[[Weekday]] 옵션 필드. [[pattern]]"{weekday}"가 포함되어 있으면 존재한다.
[[era]] Table 16[[Era]] 옵션 필드. [[pattern]]"{era}"가 포함되어 있으면 존재한다.
[[year]] Table 16[[Year]] 옵션 필드. [[pattern]]"{year}", "{yearName}", "{relatedYear}" 중 하나라도 포함되어 있으면 존재한다.
[[month]] Table 16[[Month]] 옵션 필드. [[pattern]]"{month}"가 포함되어 있으면 존재한다.
[[day]] Table 16[[Day]] 옵션 필드. [[pattern]]"{day}"가 포함되어 있으면 존재한다.
[[dayPeriod]] Table 16[[DayPeriod]] 옵션 필드. [[pattern]]"{dayPeriod}"가 포함되어 있으면 존재한다.
[[hour]] Table 16[[Hour]] 옵션 필드. [[pattern]]"{hour}"가 포함되어 있으면 존재한다.
[[minute]] Table 16[[Minute]] 옵션 필드. [[pattern]]"{minute}"가 포함되어 있으면 존재한다.
[[second]] Table 16[[Second]] 옵션 필드. [[pattern]]"{second}"가 포함되어 있으면 존재한다.
[[fractionalSecondDigits]] Table 16[[FractionalSecondDigits]] 옵션 필드. [[pattern]]"{fractionalSecondDigits}"가 포함되어 있으면 존재한다.
[[timeZoneName]] Table 16[[TimeZoneName]] 옵션 필드. [[pattern]]"{timeZoneName}"가 포함되어 있으면 존재한다.
[[pattern]] 패턴 문자열 레코드의 각 날짜 및 시간 포매팅 컴포넌트 필드에 대해 "{"로 시작하고, 필드 이름, "}"로 끝나는 부분 문자열을 포함한다. [[year]] 필드가 있으면 "{yearName}", "{relatedYear}" 부분 문자열을 포함할 수 있다.
[[pattern12]] 패턴 문자열 옵션 필드. [[hour]] 필드가 있으면 존재한다. [[pattern]]의 부분 문자열 외에 "{ampm}" 또는 "{dayPeriod}" 중 하나 이상을 포함한다.
[[rangePatterns]] DateTime Range Pattern Record 이 필드의 패턴 문자열은 [[pattern]]과 유사하다.
[[rangePatterns12]] DateTime Range Pattern Record 옵션 필드. [[hour]] 필드가 있으면 존재한다. 이 필드의 패턴 문자열은 [[pattern12]]와 유사하다.

11.2.3.2 DateTime Range Pattern Record

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

Table 6: DateTime Range Pattern Record
필드 이름 값 타입 설명
[[Default]] DateTime Range Pattern Format Record 더 구체적인 범위 패턴이 없을 때 사용하는 기본 범위 패턴을 포함한다.
[[Era]] DateTime Range Pattern Format Record 옵션 필드. 시작과 끝 날짜에서 가장 큰 달력 요소가 era일 때 사용된다.
[[Year]] DateTime Range Pattern Format Record 옵션 필드. 시작과 끝 날짜에서 가장 큰 달력 요소가 year일 때 사용된다.
[[Month]] DateTime Range Pattern Format Record 옵션 필드. 시작과 끝 날짜에서 가장 큰 달력 요소가 month일 때 사용된다.
[[Day]] DateTime Range Pattern Format Record 옵션 필드. 시작과 끝 날짜에서 가장 큰 달력 요소가 day일 때 사용된다.
[[AmPm]] DateTime Range Pattern Format Record 옵션 필드. 시작과 끝 날짜에서 가장 큰 달력 요소가 ante 또는 post meridiem일 때 사용된다.
[[DayPeriod]] DateTime Range Pattern Format Record 옵션 필드. 시작과 끝 날짜에서 가장 큰 달력 요소가 day period일 때 사용된다.
[[Hour]] DateTime Range Pattern Format Record 옵션 필드. 시작과 끝 날짜에서 가장 큰 달력 요소가 hour일 때 사용된다.
[[Minute]] DateTime Range Pattern Format Record 옵션 필드. 시작과 끝 날짜에서 가장 큰 달력 요소가 minute일 때 사용된다.
[[Second]] DateTime Range Pattern Format Record 옵션 필드. 시작과 끝 날짜에서 가장 큰 달력 요소가 second일 때 사용된다.
[[FractionalSecondDigits]] DateTime Range Pattern Format Record 옵션 필드. 시작과 끝 날짜에서 가장 큰 달력 요소가 fractional seconds일 때 사용된다.

11.2.3.3 DateTime Range Pattern Format Record

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

Table 7: DateTime Range Pattern Format Record
필드 이름 값 타입 설명
[[weekday]] Table 16[[Weekday]] 옵션 필드. [[PatternParts]]의 패턴 문자열에 "{weekday}"가 포함되어 있으면 존재한다.
[[era]] Table 16[[Era]] 옵션 필드. [[PatternParts]]의 패턴 문자열에 "{era}"가 포함되어 있으면 존재한다.
[[year]] Table 16[[Year]] 옵션 필드. [[PatternParts]]의 패턴 문자열에 "{year}", "{yearName}", "{relatedYear}" 중 하나라도 포함되어 있으면 존재한다.
[[month]] Table 16[[Month]] 옵션 필드. [[PatternParts]]의 패턴 문자열에 "{month}"가 포함되어 있으면 존재한다.
[[day]] Table 16[[Day]] 옵션 필드. [[PatternParts]]의 패턴 문자열에 "{day}"가 포함되어 있으면 존재한다.
[[dayPeriod]] Table 16[[DayPeriod]] 옵션 필드. [[PatternParts]]의 패턴 문자열에 "{dayPeriod}"가 포함되어 있으면 존재한다.
[[hour]] Table 16[[Hour]] 옵션 필드. [[PatternParts]]의 패턴 문자열에 "{hour}"가 포함되어 있으면 존재한다.
[[minute]] Table 16[[Minute]] 옵션 필드. [[PatternParts]]의 패턴 문자열에 "{minute}"가 포함되어 있으면 존재한다.
[[second]] Table 16[[Second]] 옵션 필드. [[PatternParts]]의 패턴 문자열에 "{second}"가 포함되어 있으면 존재한다.
[[fractionalSecondDigits]] Table 16[[FractionalSecondDigits]] 옵션 필드. [[PatternParts]]의 패턴 문자열에 "{fractionalSecondDigits}"가 포함되어 있으면 존재한다.
[[timeZoneName]] Table 16[[TimeZoneName]] 옵션 필드. [[PatternParts]]의 패턴 문자열에 "{timeZoneName}"가 포함되어 있으면 존재한다.
[[PatternParts]] DateTime Range Pattern Part Record의 리스트 각 레코드는 범위 패턴의 일부를 나타낸다.

11.2.3.4 DateTime Range Pattern Part Record

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

Table 8: DateTime Range Pattern Part Record
필드 이름 값 타입 설명
[[Source]] "shared", "startRange", "endRange" 중 하나 범위의 어느 날짜가 [[Pattern]] 필드의 값을 사용해 포매팅되어야 하는지 나타낸다.
[[Pattern]] 패턴 문자열 일반 날짜 패턴 문자열과 동일한 형식의 문자열이다.

11.2.3.5 DateTime Styles Record

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 Record

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

Table 10: DateTime Style Record
필드 이름 값 타입 설명
[[full]] DateTime Format Record "full" 스타일의 포매팅 레코드.
[[long]] DateTime Format Record "long" 스타일의 포매팅 레코드.
[[medium]] DateTime Format Record "medium" 스타일의 포매팅 레코드.
[[short]] DateTime Format Record "short" 스타일의 포매팅 레코드.

11.2.3.7 DateTime Connector Record

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

Table 11: DateTime Connector Record
필드 이름 값 타입 설명
[[full]] 패턴 문자열 날짜 스타일이 "full"일 때의 커넥터 패턴.
[[long]] 패턴 문자열 날짜 스타일이 "long"일 때의 커넥터 패턴.
[[medium]] 패턴 문자열 날짜 스타일이 "medium"일 때의 커넥터 패턴.
[[short]] 패턴 문자열 날짜 스타일이 "short"일 때의 커넥터 패턴.

11.2.3.8 DateTime Date Range Record

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

Table 12: DateTime Date Range Record
필드 이름 값 타입 설명
[[full]] DateTime Time Range Record 날짜 스타일이 "full"일 때 사용된다.
[[long]] DateTime Time Range Record 날짜 스타일이 "long"일 때 사용된다.
[[medium]] DateTime Time Range Record 날짜 스타일이 "medium"일 때 사용된다.
[[short]] DateTime Time Range Record 날짜 스타일이 "short"일 때 사용된다.

11.2.3.9 DateTime Time Range Record

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

Table 13: DateTime Time Range Record
필드 이름 값 타입 설명
[[full]] DateTime Style Range Record 시간 스타일이 "full"일 때 사용된다.
[[long]] DateTime Style Range Record 시간 스타일이 "long"일 때 사용된다.
[[medium]] DateTime Style Range Record 시간 스타일이 "medium"일 때 사용된다.
[[short]] DateTime Style Range Record 시간 스타일이 "short"일 때 사용된다.

11.2.3.10 DateTime Style Range Record

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

Table 14: DateTime Style Range Record
필드 이름 값 타입 설명
[[rangePatterns]] DateTime Range Pattern Record 날짜와 시간 스타일을 결합하는 범위 패턴.
[[rangePatterns12]] DateTime Range Pattern Record 옵션 필드. 12시간 포맷용 범위 패턴.
Note 2
예를 들어, 구현체는 영어 로케일 데이터의 일부로 다음 레코드를 포함할 수 있다:
  • [[hour]]: "numeric"
  • [[minute]]: "numeric"
  • [[pattern]]: "{hour}:{minute}"
  • [[pattern12]]: "{hour}:{minute} {ampm}"
  • [[rangePatterns]]:
    • [[Hour]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
    • [[Minute]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
    • [[Default]]:
      • [[year]]: "2-digit"
      • [[month]]: "numeric"
      • [[day]]: "numeric"
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute}"}
  • [[rangePatterns12]]:
    • [[Hour]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " {ampm}"}
    • [[Minute]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " {ampm}"}
    • [[Default]]:
      • [[year]]: "2-digit"
      • [[month]]: "numeric"
      • [[day]]: "numeric"
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute} {ampm}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute} {ampm}"}
Note 3
구현체는 https://cldr.unicode.org/에서 제공되는 Common Locale Data Repository의 로케일 데이터를 사용하는 것이 권장된다.

11.3 Intl.DateTimeFormat 프로토타입 객체의 프로퍼티

Intl.DateTimeFormat 프로토타입 객체:

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

11.3.1 Intl.DateTimeFormat.prototype.constructor

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

11.3.2 Intl.DateTimeFormat.prototype.resolvedOptions ( )

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

  1. dtfthis 값으로 한다.
  2. 구현이 4.3 Note 1의 규범적 선택적 생성자 모드를 지원한다면,
  3. dtf를 ? UnwrapDateTimeFormat(dtf)로 설정한다.
  4. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]])를 수행한다.
  5. optionsOrdinaryObjectCreate(%Object.prototype%)로 한다.
  6. Table 15의 각 행(헤더 행 제외)을 표 순서대로 반복한다:
  7. p를 현재 행의 Property 값으로 한다.
  8. 현재 행에 Internal Slot 값이 있으면,
  9. vdtf의 해당 내부 슬롯 값으로 한다.
  10. 아니면,
  11. formatdtf.[[DateTimeFormat]]로 한다.
  12. format에 [[<p>]] 필드가 있고 dtf.[[DateStyle]]dtf.[[TimeStyle]]undefined이면,
  13. vformat.[[<p>]]로 한다.
  14. 아니면,
  15. vundefined로 한다.
  16. vundefined가 아니면,
  17. 현재 행에 Conversion 값이 있으면,
  18. conversion을 현재 행의 Conversion 값으로 한다.
  19. conversionhour12이면,
  20. v"h11" 또는 "h12"이면 true로, 아니면 false로 설정한다.
  21. 아니면,
  22. conversionnumber임을 단언한다.
  23. v𝔽(v)로 설정한다.
  24. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  25. options를 반환한다.
Table 15: DateTimeFormat 인스턴스의 resolvedOptions
Internal Slot Property Conversion
[[Locale]] "locale"
[[Calendar]] "calendar"
[[NumberingSystem]] "numberingSystem"
[[TimeZone]] "timeZone"
[[HourCycle]] "hourCycle"
[[HourCycle]] "hour12" hour12
"weekday"
"era"
"year"
"month"
"day"
"dayPeriod"
"hour"
"minute"
"second"
"fractionalSecondDigits" number
"timeZoneName"
[[DateStyle]] "dateStyle"
[[TimeStyle]] "timeStyle"

웹 호환성을 위해 "hourCycle" 프로퍼티가 설정된 경우, "hourCycle""h11" 또는 "h12"이면 "hour12" 프로퍼티를 true로, "h23" 또는 "h24"이면 false로 설정해야 한다.

Note 1
이 버전의 API에서는, 옵션 객체에 "timeZone" 프로퍼티가 제공되지 않은 경우 "timeZone" 프로퍼티는 호스트 환경의 시간대 식별자가 된다. 첫 번째 판에서는 이 경우 "timeZone" 프로퍼티가 undefined였다.
Note 2
5판 이전 버전과의 호환성을 위해 "hourCycle" 프로퍼티와 함께 "hour12" 프로퍼티도 설정된다.

11.3.3 get Intl.DateTimeFormat.prototype.format

Intl.DateTimeFormat.prototype.format은 접근자 프로퍼티이며 set 접근자 함수는 undefined이다. get 접근자 함수는 다음 단계를 수행한다:

  1. dtfthis 값으로 한다.
  2. 구현이 4.3 Note 1의 규범적 선택적 생성자 모드를 지원한다면,
  3. dtf를 ? UnwrapDateTimeFormat(dtf)로 설정한다.
  4. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]])를 수행한다.
  5. dtf.[[BoundFormat]]undefined이면,
  6. F를 DateTime Format Functions (11.5.4)에 정의된 새로운 내장 함수 객체로 한다.
  7. F.[[DateTimeFormat]]dtf로 설정한다.
  8. dtf.[[BoundFormat]]F로 설정한다.
  9. 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. startDate 또는 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. startDate 또는 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이면,
  4. x를 ! Call(%Date.now%, undefined)로 한다.
  5. 아니면,
  6. x를 ? ToNumber(date)로 한다.
  7. FormatDateTimeToParts(dtf, x)를 반환한다.

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

%Symbol.toStringTag% 프로퍼티의 초기값은 문자열 값 "Intl.DateTimeFormat"이다.

이 프로퍼티의 속성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }이다.

11.4 Intl.DateTimeFormat 인스턴스의 프로퍼티

Intl.DateTimeFormat 인스턴스는 %Intl.DateTimeFormat.prototype%에서 프로퍼티를 상속받는 일반 객체입니다.

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

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

  • [[Locale]]는 포매팅에 사용되는 로케일의 언어 태그를 가진 문자열 값입니다.
  • [[Calendar]]는 포매팅에 사용되는 유니코드 달력 식별자를 나타내는 문자열 값입니다.
  • [[NumberingSystem]]은 포매팅에 사용되는 유니코드 숫자 시스템 식별자를 나타내는 문자열 값입니다.
  • [[TimeZone]]은 포매팅에 사용되는 문자열 값으로, 사용 가능한 명명된 시간대 식별자 또는 오프셋 시간대 식별자입니다.
  • [[HourCycle]]은 12시간 형식("h11", "h12") 또는 24시간 형식("h23", "h24") 중 어느 것이 사용되어야 하는지 나타내는 문자열 값입니다. "h11""h23"은 각각 0부터 11, 0부터 23까지 시작합니다. "h12""h24"는 각각 1부터 12, 1부터 24까지 시작합니다. [[HourCycle]][[DateTimeFormat]][[hour]] 필드가 있을 때만 사용됩니다.
  • [[DateStyle]], [[TimeStyle]]은 각각 undefined이거나, "full", "long", "medium", "short" 값 중 하나의 문자열 값입니다.
  • [[DateTimeFormat]]DateTime Format Record입니다.

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

11.5 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:

  1. Assert: dateStyleundefined가 아니거나 timeStyleundefined가 아니다.
  2. timeStyleundefined가 아니면,
  3. Assert: timeStyle"full", "long", "medium", "short" 중 하나임을 단언한다.
  4. timeFormatstyles.[[Time]].[[<timeStyle>]]로 한다.
  5. dateStyleundefined가 아니면,
  6. Assert: dateStyle"full", "long", "medium", "short" 중 하나임을 단언한다.
  7. dateFormatstyles.[[Date]].[[<dateStyle>]]로 한다.
  8. dateStyletimeStyle이 모두 undefined가 아니면,
  9. format을 새로운 DateTime Format Record로 한다.
  10. formatdateFormat의 모든 필드를 [[pattern]], [[rangePatterns]] 제외하고 추가한다.
  11. formattimeFormat의 모든 필드를 [[pattern]], [[rangePatterns]], [[pattern12]], [[rangePatterns12]](있으면) 제외하고 추가한다.
  12. connectorstyles.[[Connector]].[[<dateStyle>]]로 한다.
  13. patternconnector에서 "{0}"timeFormat.[[pattern]]으로, "{1}"dateFormat.[[pattern]]으로 대체한 문자열로 한다.
  14. format.[[pattern]]pattern을 설정한다.
  15. timeFormat[[pattern12]] 필드가 있으면,
  16. pattern12connector에서 "{0}"timeFormat.[[pattern12]]로, "{1}"dateFormat.[[pattern]]으로 대체한 문자열로 한다.
  17. format.[[pattern12]]pattern12를 설정한다.
  18. dateTimeRangeFormatstyles.[[DateTimeRangeFormat]].[[<dateStyle>]].[[<timeStyle>]]로 한다.
  19. format.[[rangePatterns]]dateTimeRangeFormat.[[rangePatterns]]를 설정한다.
  20. dateTimeRangeFormat[[rangePatterns12]] 필드가 있으면,
  21. format.[[rangePatterns12]]dateTimeRangeFormat.[[rangePatterns12]]를 설정한다.
  22. format을 반환한다.
  23. timeStyleundefined가 아니면,
  24. timeFormat을 반환한다.
  25. Assert: dateStyleundefined가 아님을 단언한다.
  26. dateFormat을 반환한다.

11.5.2 BasicFormatMatcher ( options, formats )

The abstract operation BasicFormatMatcher takes arguments options (Record) and formats (DateTime Format Record 리스트) 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에 대해 반복한다:
  11. score를 0으로 한다.
  12. Table 16의 각 행(헤더 행 제외)을 표 순서대로 반복한다:
  13. property를 현재 행의 Property 열의 이름으로 한다.
  14. options에 [[<property>]] 필드가 있으면 optionsPropoptions.[[<property>]]로, 없으면 undefined로 한다.
  15. format에 [[<property>]] 필드가 있으면 formatPropformat.[[<property>]]로, 없으면 undefined로 한다.
  16. optionsPropundefined이고 formatPropundefined가 아니면,
  17. scorescore - additionPenalty로 설정한다.
  18. optionsPropundefined가 아니고 formatPropundefined이면,
  19. scorescore - removalPenalty로 설정한다.
  20. property"timeZoneName"이면,
  21. optionsProp"short" 또는 "shortGeneric"이면,
  22. formatProp"shortOffset"이면 scorescore - offsetPenalty로 설정한다.
  23. formatProp"longOffset"이면 scorescore - (offsetPenalty + shortMorePenalty)로 설정한다.
  24. optionsProp"short"이고 formatProp"long"이면 scorescore - shortMorePenalty로 설정한다.
  25. optionsProp"shortGeneric"이고 formatProp"longGeneric"이면 scorescore - shortMorePenalty로 설정한다.
  26. optionsPropformatProp이면 scorescore - removalPenalty로 설정한다.
  27. optionsProp"shortOffset"이고 formatProp"longOffset"이면,
  28. scorescore - shortMorePenalty로 설정한다.
  29. optionsProp"long" 또는 "longGeneric"이면,
  30. formatProp"longOffset"이면 scorescore - offsetPenalty로 설정한다.
  31. formatProp"shortOffset"이면 scorescore - (offsetPenalty + longLessPenalty)로 설정한다.
  32. optionsProp"long"이고 formatProp"short"이면 scorescore - longLessPenalty로 설정한다.
  33. optionsProp"longGeneric"이고 formatProp"shortGeneric"이면 scorescore - longLessPenalty로 설정한다.
  34. optionsPropformatProp이면 scorescore - removalPenalty로 설정한다.
  35. optionsProp"longOffset"이고 formatProp"shortOffset"이면,
  36. scorescore - longLessPenalty로 설정한다.
  37. optionsPropformatProp이면,
  38. scorescore - removalPenalty로 설정한다.
  39. optionsPropformatProp이면,
  40. property"fractionalSecondDigits"이면,
  41. values를 « 1, 2, 3 »로 한다.
  42. 아니면,
  43. values를 « "2-digit", "numeric", "narrow", "short", "long" »로 한다.
  44. optionsPropIndexvalues에서 optionsProp의 인덱스로 한다.
  45. formatPropIndexvalues에서 formatProp의 인덱스로 한다.
  46. deltamax(min(formatPropIndex - optionsPropIndex, 2), -2)로 한다.
  47. delta = 2이면 scorescore - longMorePenalty로 설정한다.
  48. delta = 1이면 scorescore - shortMorePenalty로 설정한다.
  49. delta = -1이면 scorescore - shortLessPenalty로 설정한다.
  50. delta = -2이면 scorescore - longLessPenalty로 설정한다.
  51. score > bestScore이면,
  52. bestScorescore로 설정한다.
  53. bestFormatformat으로 설정한다.
  54. bestFormat을 반환한다.

11.5.3 BestFitFormatMatcher ( options, formats )

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

11.5.4 DateTime 포맷 함수

DateTime 포맷 함수는 [[DateTimeFormat]] 내부 슬롯을 가진 익명 내장 함수입니다.

DateTime 포맷 함수 F가 선택적 인자 date와 함께 호출될 때, 다음 단계가 수행됩니다:

  1. dtfF.[[DateTimeFormat]]로 한다.
  2. Assert: dtf는 객체이며 [[InitializedDateTimeFormat]] 내부 슬롯을 가진다.
  3. date가 제공되지 않았거나 undefined이면,
  4. x를 ! Call(%Date.now%, undefined)로 한다.
  5. 아니면,
  6. x를 ? ToNumber(date)로 한다.
  7. FormatDateTime(dtf, x)를 반환한다.

DateTime 포맷 함수의 "length" 프로퍼티 값은 1𝔽입니다.

11.5.5 FormatDateTimePattern ( dateTimeFormat, format, pattern, epochNanoseconds )

The abstract operation FormatDateTimePattern takes arguments dateTimeFormat (Intl.DateTimeFormat), format (DateTime Format Record 또는 DateTime Range Pattern Format Record), pattern (패턴 문자열), and epochNanoseconds (BigInt) and returns [[Type]](문자열), [[Value]](문자열) 필드를 가진 Record 리스트. 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]] 필드가 있으면,
  12. fractionalSecondDigitsformat.[[fractionalSecondDigits]]로 한다.
  13. nf3OptionsOrdinaryObjectCreate(null)로 한다.
  14. CreateDataPropertyOrThrow(nf3Options, "minimumIntegerDigits", 𝔽(fractionalSecondDigits))를 수행한다.
  15. CreateDataPropertyOrThrow(nf3Options, "numberingSystem", dateTimeFormat.[[NumberingSystem]])를 수행한다.
  16. CreateDataPropertyOrThrow(nf3Options, "useGrouping", false)를 수행한다.
  17. nf3를 ! Construct(%Intl.NumberFormat%, « locale, nf3Options »)로 한다.
  18. tmToLocalTime(epochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]])로 한다.
  19. patternPartsPartitionPattern(pattern)으로 한다.
  20. result를 새로운 빈 리스트로 한다.
  21. Record { [[Type]], [[Value]] } patternPart에 대해 반복한다:
  22. ppatternPart.[[Type]]로 한다.
  23. p"literal"이면,
  24. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }를 result에 추가한다.
  25. p"fractionalSecondDigits"이면,
  26. Assert: format[[fractionalSecondDigits]] 필드가 있다.
  27. vtm.[[Millisecond]]로 한다.
  28. vfloor(v × 10( fractionalSecondDigits - 3 ))로 설정한다.
  29. fvFormatNumeric(nf3, v)로 한다.
  30. Record { [[Type]]: "fractionalSecond", [[Value]]: fv }를 result에 추가한다.
  31. p"dayPeriod"이면,
  32. Assert: format[[dayPeriod]] 필드가 있다.
  33. fformat.[[dayPeriod]]로 한다.
  34. fvtm의 day period를 f 형식으로 나타내는 문자열 값으로 한다. 이 값은 구현 및 dateTimeFormat의 로케일에 따라 달라진다.
  35. Record { [[Type]]: p, [[Value]]: fv }를 result에 추가한다.
  36. p"timeZoneName"이면,
  37. Assert: format[[timeZoneName]] 필드가 있다.
  38. fformat.[[timeZoneName]]로 한다.
  39. vdateTimeFormat.[[TimeZone]]로 한다.
  40. fvvf 형식으로 나타내는 문자열 값으로 한다. 이 값은 구현 및 dateTimeFormat의 로케일에 따라 달라진다. 또한 f"short", "long", "shortOffset", "longOffset"일 때 tm[[InDST]] 값에 따라 달라질 수 있다. 구현에 해당 로컬라이즈된 표현이 없으면 v의 문자열 값을 사용한다.
  41. Record { [[Type]]: p, [[Value]]: fv }를 result에 추가한다.
  42. pTable 16의 Property 열과 일치하면,
  43. Assert: format에 [[<p>]] 필드가 있다.
  44. fformat.[[<p>]]로 한다.
  45. vtm의 해당 내부 슬롯 이름의 필드 값으로 한다.
  46. p"year"이고 v ≤ 0이면 v를 1 - v로 설정한다.
  47. p"month"이면 vv + 1로 설정한다.
  48. p"hour"이고 dateTimeFormat.[[HourCycle]]"h11" 또는 "h12"이면,
  49. vv modulo 12로 설정한다.
  50. v가 0이고 dateTimeFormat.[[HourCycle]]"h12"이면 v를 12로 설정한다.
  51. p"hour"이고 dateTimeFormat.[[HourCycle]]"h24"이면,
  52. v가 0이면 v를 24로 설정한다.
  53. f"numeric"이면,
  54. fvFormatNumeric(nf, v)로 한다.
  55. f"2-digit"이면,
  56. fvFormatNumeric(nf2, v)로 한다.
  57. codePointsStringToCodePoints(fv)로 한다.
  58. countcodePoints의 요소 개수로 한다.
  59. count > 2이면,
  60. tenscodePoints[count - 2]로 한다.
  61. onescodePoints[count - 1]로 한다.
  62. fvCodePointsToStringtens, ones »)로 설정한다.
  63. f"narrow", "short", "long"이면,
  64. fvf 형식으로 v를 나타내는 문자열 값으로 한다. 이 값은 구현, 로케일, 달력에 따라 달라진다. p"month"이면 format.[[day]]의 존재 여부에 따라 값이 달라질 수 있다. 구현에 해당 로컬라이즈된 표현이 없으면 v의 문자열 값을 사용한다.
  65. Record { [[Type]]: p, [[Value]]: fv }를 result에 추가한다.
  66. p"ampm"이면,
  67. vtm.[[Hour]]로 한다.
  68. v > 11이면,
  69. fv"post meridiem"을 나타내는 ILD 문자열 값으로 한다.
  70. 아니면,
  71. fv"ante meridiem"을 나타내는 ILD 문자열 값으로 한다.
  72. Record { [[Type]]: "dayPeriod", [[Value]]: fv }를 result에 추가한다.
  73. p"relatedYear"이면,
  74. vtm.[[RelatedYear]]로 한다.
  75. fvFormatNumeric(nf, v)로 한다.
  76. Record { [[Type]]: "relatedYear", [[Value]]: fv }를 result에 추가한다.
  77. p"yearName"이면,
  78. vtm.[[YearName]]로 한다.
  79. fvv를 나타내는 ILD 문자열 값으로 한다.
  80. Record { [[Type]]: "yearName", [[Value]]: fv }를 result에 추가한다.
  81. 아니면,
  82. unknown을 구현, 로케일, 숫자 시스템에 따라 epochNanosecondsp 기반의 문자열로 한다.
  83. Record { [[Type]]: "unknown", [[Value]]: unknown }를 result에 추가한다.
  84. result를 반환한다.
Note
구현체는 Common Locale Data Repository(https://cldr.unicode.org/)에서 제공하는 로케일 및 달력별 문자열을 사용하는 것이 권장됩니다. DateTimeFormat "short" 문자열에는 CLDR "abbreviated" 문자열을, "long"에는 CLDR "wide" 문자열을 사용하는 것이 좋습니다.

11.5.6 PartitionDateTimePattern ( dateTimeFormat, x )

The abstract operation PartitionDateTimePattern takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (숫자) and returns 정상 완료 시 [[Type]](문자열), [[Value]](문자열) 필드를 가진 Record 리스트 또는 throw completion. 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"이면,
  6. patternformat.[[pattern12]]로 한다.
  7. 아니면,
  8. patternformat.[[pattern]]로 한다.
  9. resultFormatDateTimePattern(dateTimeFormat, format, pattern, epochNanoseconds)로 한다.
  10. result를 반환한다.

11.5.7 FormatDateTime ( dateTimeFormat, x )

The abstract operation FormatDateTime takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (숫자) and returns 정상 완료 시 문자열 또는 throw completion. It performs the following steps when called:

  1. parts를 ? PartitionDateTimePattern(dateTimeFormat, x)로 한다.
  2. result를 빈 문자열로 한다.
  3. Record { [[Type]], [[Value]] } part에 대해 반복한다:
  4. resultresultpart.[[Value]]의 문자열 연결로 설정한다.
  5. result를 반환한다.

11.5.8 FormatDateTimeToParts ( dateTimeFormat, x )

The abstract operation FormatDateTimeToParts takes arguments dateTimeFormat (Intl.DateTimeFormat) and x (숫자) and returns 정상 완료 시 배열 또는 throw completion. It performs the following steps when called:

  1. parts를 ? PartitionDateTimePattern(dateTimeFormat, x)로 한다.
  2. result를 ! ArrayCreate(0)로 한다.
  3. n을 0으로 한다.
  4. Record { [[Type]], [[Value]] } part에 대해 반복한다:
  5. OOrdinaryObjectCreate(%Object.prototype%)로 한다.
  6. CreateDataPropertyOrThrow(O, "type", part.[[Type]])를 수행한다.
  7. CreateDataPropertyOrThrow(O, "value", part.[[Value]])를 수행한다.
  8. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), O)를 수행한다.
  9. n을 1 증가시킨다.
  10. result를 반환한다.

11.5.9 PartitionDateTimeRangePattern ( dateTimeFormat, x, y )

The abstract operation PartitionDateTimeRangePattern takes arguments dateTimeFormat (Intl.DateTimeFormat), x (숫자), and y (숫자) and returns 정상 완료 시 [[Type]](문자열), [[Value]](문자열), [[Source]](문자열) 필드를 가진 Record 리스트 또는 throw completion. 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. tm1ToLocalTime(xEpochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]])로 한다.
  8. tm2ToLocalTime(yEpochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]])로 한다.
  9. formatdateTimeFormat.[[DateTimeFormat]]로 한다.
  10. dateTimeFormat.[[HourCycle]]"h11" 또는 "h12"이면,
  11. patternformat.[[pattern12]]로 한다.
  12. rangePatternsformat.[[rangePatterns12]]로 한다.
  13. 아니면,
  14. patternformat.[[pattern]]로 한다.
  15. rangePatternsformat.[[rangePatterns]]로 한다.
  16. selectedRangePatternundefined로 한다.
  17. relevantFieldsEqualtrue로 한다.
  18. checkMoreFieldstrue로 한다.
  19. Table 6의 각 행(헤더 행 제외)을 표 순서대로 반복한다:
  20. fieldName을 현재 행의 Field Name 열의 이름으로 한다.
  21. rangePatternsfieldName 이름의 필드가 있으면 rangePattern을 해당 필드로, 없으면 undefined로 한다.
  22. selectedRangePatternundefined가 아니고 rangePatternundefined이면,
  23. NOTE: 이 필드 이하의 차이에 대한 범위 패턴이 없으므로 더 이상 체크하지 않는다.
  24. checkMoreFieldsfalse로 한다.
  25. fieldName[[Default]]와 다르고 relevantFieldsEqualtrue이고 checkMoreFieldstrue이면,
  26. selectedRangePatternrangePattern으로 설정한다.
  27. fieldName[[AmPm]]이면,
  28. tm1.[[Hour]] < 12이면 v1"am"으로, 아니면 "pm"으로 한다. 1. tm2.[[Hour]] < 12이면 v2"am"으로, 아니면 "pm"으로 한다. 1. fieldName[[DayPeriod]]이면, 1. v1tm1의 day period를 나타내는 문자열 값으로 한다. 이 값은 구현 및 dateTimeFormat의 로케일에 따라 달라진다. 1. v2tm2의 day period를 나타내는 문자열 값으로 한다. 이 값은 구현 및 dateTimeFormat의 로케일에 따라 달라진다. 1. fieldName[[FractionalSecondDigits]]이면, 1. format[[fractionalSecondDigits]] 필드가 있으면, 1. fractionalSecondDigitsformat.[[fractionalSecondDigits]]로 한다. 1. 아니면, 1. fractionalSecondDigits를 3으로 한다. 1. expfractionalSecondDigits - 3으로 한다. 1. v1floor(tm1.[[Millisecond]] × 10exp)로 한다.
    1. v2floor(tm2.[[Millisecond]] × 10exp)로 한다.
    2. 아니면,
    3. v1tm1fieldName 필드 값으로 한다.
    4. v2tm2fieldName 필드 값으로 한다.
    5. v1v2이면,
    6. relevantFieldsEqualfalse로 한다.
    7. relevantFieldsEqualtrue이면,
    8. collapsedResult를 새로운 빈 리스트로 한다.
    9. resultPartsFormatDateTimePattern(dateTimeFormat, format, pattern, xEpochNanoseconds)로 한다.
    10. Record { [[Type]], [[Value]] } r에 대해 반복한다:
    11. Record { [[Type]]: r.[[Type]], [[Value]]: r.[[Value]], [[Source]]: "shared" }를 collapsedResult에 추가한다.
    12. collapsedResult를 반환한다.
    13. rangeResult를 새로운 빈 리스트로 한다.
    14. selectedRangePatternundefined이면,
    15. selectedRangePatternrangePatterns.[[Default]]로 설정한다.
    16. selectedRangePattern.[[PatternParts]]의 각 Record { [[Pattern]], [[Source]] } rangePatternPart에 대해 반복한다:
    17. patternrangePatternPart.[[Pattern]]로 한다.
    18. sourcerangePatternPart.[[Source]]로 한다.
    19. source"startRange" 또는 "shared"이면,
    20. zxEpochNanoseconds로 한다.
    21. 아니면,
    22. zyEpochNanoseconds로 한다.
    23. resultPartsFormatDateTimePattern(dateTimeFormat, selectedRangePattern, pattern, z)로 한다.
    24. Record { [[Type]], [[Value]] } r에 대해 반복한다:
    25. Record { [[Type]]: r.[[Type]], [[Value]]: r.[[Value]], [[Source]]: source }를 rangeResult에 추가한다.
    26. rangeResult를 반환한다.

11.5.10 FormatDateTimeRange ( dateTimeFormat, x, y )

The abstract operation FormatDateTimeRange takes arguments dateTimeFormat (Intl.DateTimeFormat), x (숫자), and y (숫자) and returns 정상 완료 시 문자열 또는 throw completion. It performs the following steps when called:

  1. parts를 ? PartitionDateTimeRangePattern(dateTimeFormat, x, y)로 한다.
  2. result를 빈 문자열로 한다.
  3. Record { [[Type]], [[Value]], [[Source]] } part에 대해 반복한다:
  4. resultresultpart.[[Value]]의 문자열 연결로 설정한다.
  5. result를 반환한다.

11.5.11 FormatDateTimeRangeToParts ( dateTimeFormat, x, y )

The abstract operation FormatDateTimeRangeToParts takes arguments dateTimeFormat (Intl.DateTimeFormat), x (숫자), and y (숫자) and returns 정상 완료 시 배열 또는 throw completion. It performs the following steps when called:

  1. parts를 ? PartitionDateTimeRangePattern(dateTimeFormat, x, y)로 한다.
  2. result를 ! ArrayCreate(0)로 한다.
  3. n을 0으로 한다.
  4. Record { [[Type]], [[Value]], [[Source]] } part에 대해 반복한다:
  5. OOrdinaryObjectCreate(%Object.prototype%)로 한다.
  6. CreateDataPropertyOrThrow(O, "type", part.[[Type]])를 수행한다.
  7. CreateDataPropertyOrThrow(O, "value", part.[[Value]])를 수행한다.
  8. CreateDataPropertyOrThrow(O, "source", part.[[Source]])를 수행한다.
  9. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), O)를 수행한다.
  10. n을 1 증가시킨다.
  11. result를 반환한다.

11.5.12 ToLocalTime ( epochNs, calendar, timeZoneIdentifier )

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

  1. IsTimeZoneOffsetString(timeZoneIdentifier)가 true이면,
  2. offsetNsParseTimeZoneOffsetString(timeZoneIdentifier)로 한다.
  3. 아니면,
  4. Assert: GetAvailableNamedTimeZoneIdentifier(timeZoneIdentifier)가 empty가 아님을 단언한다.
  5. offsetNsGetNamedTimeZoneOffsetNanoseconds(timeZoneIdentifier, epochNs)로 한다.
  6. tz(epochNs) + offsetNs로 한다.
  7. calendar"gregory"이면,
  8. Table 17에 따라 tz에서 계산된 필드로 ToLocalTime Record를 반환한다.
  9. 아니면,
  10. 주어진 calendar에 대해 tz에서 계산된 필드로 ToLocalTime Record를 반환한다. 계산은 지정된 calendar에 대한 최선의 정보를 사용해야 한다.

11.5.13 ToLocalTime Record

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

Table 17: ToLocalTime에서 반환되는 Record
필드 이름 값 타입 그레고리안 달력 계산 값
[[Weekday]] 정수 (WeekDay(𝔽(floor(tz / 106))))
[[Era]] 문자열 yearYearFromTime(𝔽(floor(tz / 106)))로 한다. year < 1𝔽이면 "BC", 아니면 "AD"를 반환한다.
[[Year]] 정수 (YearFromTime(𝔽(floor(tz / 106))))
[[RelatedYear]] 정수 또는 undefined undefined
[[YearName]] 문자열 또는 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]] 불리언 calendar, timeZoneIdentifier에 대한 최선의 정보를 사용하여 true 또는 false를 계산한다. 여기에는 IANA Time Zone Database의 현재 및 과거 시간대 오프셋, 일광절약시간 규칙 정보가 포함된다.

11.5.14 UnwrapDateTimeFormat ( dtf )

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

  1. dtf가 객체가 아니면 TypeError 예외를 던진다.
  2. dtf[[InitializedDateTimeFormat]] 내부 슬롯이 없고 ? OrdinaryHasInstance(%Intl.DateTimeFormat%, dtf)가 true이면,
  3. Get(dtf, %Intl%.[[FallbackSymbol]])를 반환한다.
  4. 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. roptionsResolution.[[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" », undefined)로 한다.
  9. typeundefined이면, TypeError 예외를 발생시킨다.
  10. displayNames.[[Type]]type을 설정한다.
  11. fallback을 ? GetOption(options, "fallback", string, « "code", "none" », "code")로 한다.
  12. displayNames.[[Fallback]]fallback을 설정한다.
  13. displayNames.[[Locale]]r.[[Locale]]를 설정한다.
  14. resolvedLocaleDatar.[[LocaleData]]로 한다.
  15. typesresolvedLocaleData.[[types]]로 한다.
  16. Assert: typesRecord이다 (12.2.3 참조).
  17. languageDisplay를 ? GetOption(options, "languageDisplay", string, « "dialect", "standard" », "dialect")로 한다.
  18. typeFieldstypes.[[<type>]]로 한다.
  19. Assert: typeFieldsRecord이다 (12.2.3 참조).
  20. type"language"이면,
  21. displayNames.[[LanguageDisplay]]languageDisplay를 설정한다.
  22. typeFieldstypeFields.[[<languageDisplay>]]로 한다.
  23. Assert: typeFieldsRecord이다 (12.2.3 참조).
  24. styleFieldstypeFields.[[<style>]]로 한다.
  25. Assert: styleFieldsRecord이다 (12.2.3 참조).
  26. displayNames.[[Fields]]styleFields를 설정한다.
  27. displayNames를 반환한다.

12.2 Intl.DisplayNames 생성자의 속성

Intl.DisplayNames 생성자:

12.2.1 Intl.DisplayNames.prototype

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

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

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

supportedLocalesOf 메서드가 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에 대해 [[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".
  • display name type "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에 매칭될 수 있는 언어 코드에 해당하는 키를 가진 Record이어야 한다. 이 필드의 값은 문자열이어야 한다.
  • display name type "region" 아래의 display name style 필드는 지역 코드에 해당하는 키를 가진 Record이어야 한다. 이 필드의 값은 문자열이어야 한다.
  • display name type "script" 아래의 display name style 필드는 스크립트 코드에 해당하는 키를 가진 Record이어야 한다. 이 필드의 값은 문자열이어야 한다.
  • display name type "currency" 아래의 display name style 필드는 통화 코드에 해당하는 키를 가진 Record이어야 한다. 이 필드의 값은 문자열이어야 한다.
  • display name type "calendar" 아래의 display name style 필드는 type Unicode locale nonterminal에 매칭될 수 있는 캘린더 식별자에 해당하는 키를 가진 Record이어야 한다. 이 필드의 값은 문자열이어야 한다.
  • display name type "dateTimeField" 아래의 display name style 필드는 Table 19에 나열된 코드에 해당하는 키를 가진 Record이어야 한다. 이 필드의 값은 문자열이어야 한다.
Note
구현에서는 Common Locale Data Repository(https://cldr.unicode.org/ 제공)를 사용하는 것이 권장된다.

12.3 Intl.DisplayNames 프로토타입 객체의 속성

Intl.DisplayNames 프로토타입 객체:

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

12.3.1 Intl.DisplayNames.prototype.constructor

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

12.3.2 Intl.DisplayNames.prototype.resolvedOptions ( )

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

  1. displayNamesthis 값으로 한다.
  2. RequireInternalSlot(displayNames, [[InitializedDisplayNames]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 한다.
  4. Table 18의 각 행(헤더 행 제외)을 테이블 순서대로 반복하여,
  5. 현재 행의 Property 값을 p로 한다.
  6. 현재 행의 Internal Slot 이름에 해당하는 displayNames의 내부 슬롯 값을 v로 한다.
  7. vundefined가 아니면,
  8. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  9. 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.ofcode 인자를 받아 호출될 때, 다음 단계가 수행된다:

  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% 속성의 초기값은 문자열 값 "Intl.DisplayNames"이다.

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

12.4 Intl.DisplayNames 인스턴스의 속성

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

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

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

  • [[Locale]]는 포매팅에 사용되는 로케일의 언어 태그를 가진 문자열 값이다.
  • [[Style]]는 사용되는 display name style을 식별하는 "narrow", "short", "long" 중 하나의 문자열 값이다.
  • [[Type]]는 요청된 display name의 타입을 식별하는 "language", "region", "script", "currency", "calendar", "dateTimeField" 중 하나의 문자열 값이다.
  • [[Fallback]]은 시스템에 요청된 display name이 없을 때 반환되는 값을 식별하는 "code" 또는 "none" 중 하나의 문자열 값이다.
  • [[LanguageDisplay]]는 언어 display 종류를 식별하는 "dialect" 또는 "standard" 중 하나의 문자열 값이다. [[Type]]"language" 값일 때만 사용된다.
  • [[Fields]]는 (12.2.3 참조) [[Style]], [[Type]], [[LanguageDisplay]]에 따라 코드에 해당하는 키를 가진 Record이다.

12.5 DisplayNames 객체의 추상 연산

12.5.1 CanonicalCodeForDisplayNames ( type, code )

The abstract operation CanonicalCodeForDisplayNames takes arguments type (a String) and code (a String) and returns either a normal completion containing a String or a throw completion. codetype에 따라 올바른 코드임을 검증하고, code의 대소문자를 정규화된 형태로 반환한다. It performs the following steps when called:

  1. type"language"이면,
  2. codeunicode_language_id Unicode locale nonterminal에 매칭되지 않으면, RangeError 예외를 발생시킨다.
  3. IsWellFormedLanguageTag(code)가 false이면, RangeError 예외를 발생시킨다.
  4. CanonicalizeUnicodeLocaleId(code)를 반환한다.
  5. type"region"이면,
  6. codeunicode_region_subtag Unicode locale nonterminal에 매칭되지 않으면, RangeError 예외를 발생시킨다.
  7. codeASCII-uppercase를 반환한다.
  8. type"script"이면,
  9. codeunicode_script_subtag Unicode locale nonterminal에 매칭되지 않으면, RangeError 예외를 발생시킨다.
  10. Assert: code의 길이는 4이고, code의 모든 코드 유닛은 ASCII 문자(0x0041~0x005A, 0x0061~0x007A)이다.
  11. firstcode의 0~1 부분의 ASCII-uppercase로 한다.
  12. restcode의 1 이후 부분의 ASCII-lowercase로 한다.
  13. firstrest를 연결한 문자열을 반환한다.
  14. type"calendar"이면,
  15. codetype Unicode locale nonterminal에 매칭되지 않으면, RangeError 예외를 발생시킨다.
  16. codeUnicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance에 설명된 하위 호환 구문을 사용하면, RangeError 예외를 발생시킨다.
  17. codeASCII-lowercase를 반환한다.
  18. type"dateTimeField"이면,
  19. IsValidDateTimeFieldCode(code)의 결과가 false이면, RangeError 예외를 발생시킨다.
  20. code를 반환한다.
  21. Assert: type"currency"이다.
  22. IsWellFormedCurrencyCode(code)가 false이면, RangeError 예외를 발생시킨다.
  23. codeASCII-uppercase를 반환한다.

12.5.2 IsValidDateTimeFieldCode ( field )

The abstract operation IsValidDateTimeFieldCode takes argument field (a String) and returns a Boolean. field 인자가 유효한 날짜/시간 필드 코드임을 검증한다. It performs the following steps when called:

  1. fieldTable 19의 Code 열에 나열되어 있으면, true를 반환한다.
  2. false를 반환한다.
Table 19: DisplayNames의 날짜/시간 필드 코드
Code Description
"era" 시대(예: 그레고리안 또는 율리우스 달력의 AD 또는 BC)를 나타내는 필드.
"year" 연도(시대 내)를 나타내는 필드.
"quarter" 분기(예: Q2, 2분기 등)를 나타내는 필드.
"month" 월(예: Sep, September 등)을 나타내는 필드.
"weekOfYear" 연도 내 주 번호를 나타내는 필드.
"weekday" 요일(예: Tue, Tuesday 등)을 나타내는 필드.
"day" 월 내 일자를 나타내는 필드.
"dayPeriod" 주기(예: am, pm 또는 noon, evening 등)를 나타내는 필드.
"hour" 시간을 나타내는 필드.
"minute" 분을 나타내는 필드.
"second" 초를 나타내는 필드.
"timeZoneName" 시간대 이름(예: PDT, Pacific Daylight Time 등)을 나타내는 필드.

13 DurationFormat 객체

13.1 Intl.DurationFormat 생성자

Intl.DurationFormat 생성자:

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

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

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

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

  1. NewTarget이 undefined이면, TypeError 예외를 throw한다.
  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. roptionsResolution.[[ResolvedLocale]]로 한다.
  6. durationFormat.[[Locale]]r.[[Locale]]를 설정한다.
  7. resolvedLocaleDatar.[[LocaleData]]로 한다.
  8. digitalFormatresolvedLocaleData.[[DigitalFormat]]로 한다.
  9. durationFormat.[[HourMinuteSeparator]]digitalFormat.[[HourMinuteSeparator]]를 설정한다.
  10. durationFormat.[[MinuteSecondSeparator]]digitalFormat.[[MinuteSecondSeparator]]를 설정한다.
  11. durationFormat.[[NumberingSystem]]r.[[nu]]를 설정한다.
  12. style을 ? GetOption(options, "style", string, « "long", "short", "narrow", "digital" », "short")로 한다.
  13. durationFormat.[[Style]]style을 설정한다.
  14. prevStyle을 빈 문자열로 한다.
  15. Table 20의 각 행(헤더 행 제외)을 표 순서대로 반복하여,
  16. slot을 현재 행의 Internal Slot 값으로 한다.
  17. unit을 현재 행의 Unit 값으로 한다.
  18. styles를 현재 행의 Styles 값으로 한다.
  19. digitalBase를 현재 행의 Digital Default 값으로 한다.
  20. unitOptions을 ? GetDurationUnitOptions(unit, options, style, styles, digitalBase, prevStyle, digitalFormat.[[TwoDigitHours]])로 한다.
  21. durationFormat의 내부 슬롯 slotunitOptions를 설정한다.
  22. unit"hours", "minutes", "seconds", "milliseconds", 또는 "microseconds" 중 하나이면,
  23. prevStyleunitOptions.[[Style]]로 설정한다.
  24. durationFormat.[[FractionalDigits]]에 ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined)를 설정한다.
  25. durationFormat을 반환한다.
Table 20: DurationFormat 인스턴스의 내부 슬롯 및 속성 이름
Internal Slot Unit Styles Digital Default
[[YearsOptions]] "years" « "long", "short", "narrow" » "short"
[[MonthsOptions]] "months" « "long", "short", "narrow" » "short"
[[WeeksOptions]] "weeks" « "long", "short", "narrow" » "short"
[[DaysOptions]] "days" « "long", "short", "narrow" » "short"
[[HoursOptions]] "hours" « "long", "short", "narrow", "numeric", "2-digit" » "numeric"
[[MinutesOptions]] "minutes" « "long", "short", "narrow", "numeric", "2-digit" » "numeric"
[[SecondsOptions]] "seconds" « "long", "short", "narrow", "numeric", "2-digit" » "numeric"
[[MillisecondsOptions]] "milliseconds" « "long", "short", "narrow", "numeric" » "numeric"
[[MicrosecondsOptions]] "microseconds" « "long", "short", "narrow", "numeric" » "numeric"
[[NanosecondsOptions]] "nanoseconds" « "long", "short", "narrow", "numeric" » "numeric"

13.2 Intl.DurationFormat 생성자의 속성

Intl.DurationFormat 생성자:

13.2.1 Intl.DurationFormat.prototype

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

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

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

supportedLocalesOf 메서드가 인자 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에 대해 다음 추가 제약을 가진다:

  • [[LocaleData]].[[<locale>]]는 [[nu]][[DigitalFormat]] 필드를 가진 Record여야 한다.
  • [[LocaleData]].[[<locale>]].[[nu]]16.2.3에 명시된 대로 List여야 하며, 값 "native", "traditio", 또는 "finance"를 포함해서는 안 된다.
  • [[LocaleData]].[[<locale>]].[[DigitalFormat]]는 해당 로케일에서 사용 가능한 각 숫자 시스템에 대응하는 키를 가진 Record여야 한다. 각 키에 연결된 값은 다음 필드를 포함하는 Record여야 한다:
    • [[HourMinuteSeparator]]는 스타일 "numeric" 또는 "2-digit"을 사용할 때 해당 로케일과 숫자 시스템 조합에 적합한 시간과 분 사이의 구분자 문자열이어야 한다.
    • [[MinuteSecondSeparator]]는 스타일 "numeric" 또는 "2-digit"을 사용할 때 해당 로케일과 숫자 시스템 조합에 적합한 분과 초 사이의 구분자 문자열이어야 한다.
    • [[TwoDigitHours]]는 스타일 "numeric"을 사용할 때 항상 두 자리로 시간 표시 여부를 나타내는 Boolean 값이어야 한다.
Note
구현에서는 Common Locale Data Repository(http://cldr.unicode.org/)에서 제공하는 로케일 데이터를 사용하는 것이 권장된다.

13.3 Intl.DurationFormat 프로토타입 객체의 속성

Intl.DurationFormat 프로토타입 객체:

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

13.3.1 Intl.DurationFormat.prototype.constructor

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

13.3.2 Intl.DurationFormat.prototype.resolvedOptions ( )

이 함수는 객체 초기화 시 계산된 로케일과 옵션에 접근할 수 있도록 한다.

  1. dfthis 값으로 한다.
  2. RequireInternalSlot(df, [[InitializedDurationFormat]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 한다.
  4. Table 21의 각 행(헤더 행 제외)을 표 순서대로 반복하여,
  5. p를 현재 행의 Property 값으로 한다.
  6. vdf의 내부 슬롯 중 현재 행의 Internal Slot 이름에 해당하는 값으로 한다.
  7. vundefined가 아니면,
  8. 현재 행에 Conversion 값이 있으면 conversion을 그 값으로, 없으면 empty로 한다.
  9. conversionnumber이면,
  10. v𝔽(v)로 설정한다.
  11. conversionempty가 아니면,
  12. Assert: conversionstyle+display이고 vDuration Unit Options Record이다.
  13. NOTE: v.[[Style]]p(복수 Temporal 단위) 이름의 속성으로 표현되고, v.[[Display]]p"Display"를 접미한 이름의 속성으로 표현된다.
  14. stylev.[[Style]]로 한다.
  15. style"fractional"이면,
  16. Assert: IsFractionalSecondUnitName(p)가 true이다.
  17. style"numeric"으로 설정한다.
  18. CreateDataPropertyOrThrow(options, p, style)를 수행한다.
  19. p"Display"를 접미하여 설정한다.
  20. vv.[[Display]]로 설정한다.
  21. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  22. options를 반환한다.
Table 21: DurationFormat 인스턴스의 resolvedOptions 속성
Internal Slot Property Conversion
[[Locale]] "locale"
[[NumberingSystem]] "numberingSystem"
[[Style]] "style"
[[YearsOptions]] "years" style+display
[[MonthsOptions]] "months" style+display
[[WeeksOptions]] "weeks" style+display
[[DaysOptions]] "days" style+display
[[HoursOptions]] "hours" style+display
[[MinutesOptions]] "minutes" style+display
[[SecondsOptions]] "seconds" style+display
[[MillisecondsOptions]] "milliseconds" style+display
[[MicrosecondsOptions]] "microseconds" style+display
[[NanosecondsOptions]] "nanoseconds" style+display
[[FractionalDigits]] "fractionalDigits" number

13.3.3 Intl.DurationFormat.prototype.format ( duration )

format 메서드가 인자 duration과 함께 호출될 때, 다음 단계가 수행된다:

  1. dfthis 값으로 한다.
  2. RequireInternalSlot(df, [[InitializedDurationFormat]])를 수행한다.
  3. record를 ? ToDurationRecord(duration)로 한다.
  4. partsPartitionDurationFormatPattern(df, record)로 한다.
  5. result를 빈 문자열로 한다.
  6. Record { [[Type]], [[Value]], [[Unit]] } part에 대해,
  7. resultpart.[[Value]]를 이어붙인다.
  8. 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. Record { [[Type]], [[Value]], [[Unit]] } part에 대해,
  8. objOrdinaryObjectCreate(%Object.prototype%)로 한다.
  9. CreateDataPropertyOrThrow(obj, "type", part.[[Type]])를 수행한다.
  10. CreateDataPropertyOrThrow(obj, "value", part.[[Value]])를 수행한다.
  11. part.[[Unit]]empty가 아니면, ! CreateDataPropertyOrThrow(obj, "unit", part.[[Unit]])를 수행한다.
  12. CreateDataPropertyOrThrow(result, ! ToString(n), obj)를 수행한다.
  13. nn + 1로 한다.
  14. result를 반환한다.

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

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

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

13.4 Intl.DurationFormat 인스턴스의 속성

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

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

Intl.DurationFormat 인스턴스는 Intl.DurationFormat 생성자에서 계산된 여러 내부 슬롯도 가진다:

  • [[Locale]]는 포매팅에 사용되는 로케일의 언어 태그를 가진 문자열 값이다.
  • [[NumberingSystem]]은 포매팅에 사용되는 유니코드 숫자 시스템 식별자를 나타내는 문자열 값이다.
  • [[Style]]은 사용되는 duration 포매팅 스타일을 나타내는 "long", "short", "narrow", "digital" 중 하나의 문자열 값이다.
  • [[YearsOptions]]Duration Record[[Years]] 필드에 대한 포매팅 스타일과 표시 기준을 나타내는 Duration Unit Options Record이다.
  • [[MonthsOptions]]Duration Record[[Months]] 필드에 대한 포매팅 스타일과 표시 기준을 나타내는 Duration Unit Options Record이다.
  • [[WeeksOptions]]Duration Record[[Weeks]] 필드에 대한 포매팅 스타일과 표시 기준을 나타내는 Duration Unit Options Record이다.
  • [[DaysOptions]]Duration Record[[Days]] 필드에 대한 포매팅 스타일과 표시 기준을 나타내는 Duration Unit Options Record이다.
  • [[HoursOptions]]Duration Record[[Hours]] 필드에 대한 포매팅 스타일과 표시 기준을 나타내는 Duration Unit Options Record이다.
  • [[MinutesOptions]]Duration Record[[Minutes]] 필드에 대한 포매팅 스타일과 표시 기준을 나타내는 Duration Unit Options Record이다.
  • [[SecondsOptions]]Duration Record[[Seconds]] 필드에 대한 포매팅 스타일과 표시 기준을 나타내는 Duration Unit Options Record이다.
  • [[MillisecondsOptions]]Duration Record[[Milliseconds]] 필드에 대한 포매팅 스타일과 표시 기준을 나타내는 Duration Unit Options Record이다.
  • [[MicrosecondsOptions]]Duration Record[[Microseconds]] 필드에 대한 포매팅 스타일과 표시 기준을 나타내는 Duration Unit Options Record이다.
  • [[NanosecondsOptions]]Duration Record[[Nanoseconds]] 필드에 대한 포매팅 스타일과 표시 기준을 나타내는 Duration Unit Options Record이다.
  • [[HourMinuteSeparator]]는 시간과 분이 모두 표시되고 모두 숫자 스타일로 포매팅될 때 사용할 시간과 분 사이의 구분자 문자열 값이다.
  • [[MinuteSecondSeparator]]는 분과 초가 모두 표시되고 모두 숫자 스타일로 포매팅될 때 사용할 분과 초 사이의 구분자 문자열 값이다.
  • [[FractionalDigits]]undefined이거나 숫자 스타일에 사용할 소수 자릿수를 나타내는 0 이상의 정수이다.

13.5 DurationFormat 객체의 추상 연산

13.5.1 Duration Record

Duration Record는 Duration을 나타내기 위해 사용되는 Record 값이다.

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

Table 22: Duration Record 필드
Field 의미
[[Years]] duration의 연도 수
[[Months]] duration의 월 수
[[Weeks]] duration의 주 수
[[Days]] duration의 일 수
[[Hours]] duration의 시간 수
[[Minutes]] duration의 분 수
[[Seconds]] duration의 초 수
[[Milliseconds]] duration의 밀리초 수
[[Microseconds]] duration의 마이크로초 수
[[Nanoseconds]] duration의 나노초 수

13.5.2 ToIntegerIfIntegral ( argument )

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

  1. number를 ? ToNumber(argument)로 한다.
  2. number가 정수 Number가 아니면, RangeError 예외를 throw한다.
  3. (number)를 반환한다.

13.5.3 ToDurationRecord ( input )

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

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

13.5.4 DurationSign ( duration )

The abstract operation DurationSign takes argument duration (Duration Record) and returns -1, 0, 또는 1. 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에 대해,
  2. v < 0이면 -1을 반환한다.
  3. v > 0이면 1을 반환한다.
  4. 0을 반환한다.

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

The abstract operation IsValidDuration takes arguments years (정수), months (정수), weeks (정수), days (정수), hours (정수), minutes (정수), seconds (정수), milliseconds (정수), microseconds (정수), and nanoseconds (정수) and returns Boolean. It performs the following steps when called:

  1. sign을 0으로 한다.
  2. « years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds »의 각 값 v에 대해,
  3. 𝔽(v)가 유한하지 않으면 false를 반환한다.
  4. v < 0이면,
  5. sign > 0이면 false를 반환한다.
  6. sign을 -1로 설정한다.
  7. 그렇지 않고 v > 0이면,
  8. sign < 0이면 false를 반환한다.
  9. sign을 1로 설정한다.
  10. abs(years) ≥ 232이면 false를 반환한다.
  11. abs(months) ≥ 232이면 false를 반환한다.
  12. abs(weeks) ≥ 232이면 false를 반환한다.
  13. normalizedSecondsdays × 86,400 + hours × 3600 + minutes × 60 + seconds + (𝔽(milliseconds)) × 10-3 + (𝔽(microseconds)) × 10-6 + (𝔽(nanoseconds)) × 10-9로 한다.
  14. NOTE: 위 단계는 부동소수점 연산으로 직접 구현할 수 없다. 10-3, 10-6, 10-9로 곱하는 것은 milliseconds, microseconds, nanoseconds가 unsafe integer일 때 부정확할 수 있다. C++에서는 충분한 비트의 quotient를 가진 std::remquo() 구현으로 가능하다. 문자열 조작도 정확한 결과를 준다.
  15. abs(normalizedSeconds) ≥ 253이면 false를 반환한다.
  16. 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 완료. It performs the following steps when called:

  1. style을 ? GetOption(options, unit, string, stylesList, undefined)로 한다.
  2. displayDefault"always"로 한다.
  3. styleundefined이면,
  4. baseStyle"digital"이면,
  5. styledigitalBase로 설정한다.
  6. unit"hours", "minutes", "seconds" 중 하나가 아니면 displayDefault"auto"로 설정한다.
  7. 그렇지 않고 prevStyle"fractional", "numeric", "2-digit" 중 하나이면,
  8. style"numeric"으로 설정한다.
  9. unit"minutes", "seconds"가 아니면 displayDefault"auto"로 설정한다.
  10. 그렇지 않으면,
  11. stylebaseStyle로 설정한다.
  12. displayDefault"auto"로 설정한다.
  13. style"numeric"이고 IsFractionalSecondUnitName(unit)이 true이면,
  14. style"fractional"로 설정한다.
  15. displayDefault"auto"로 설정한다.
  16. displayFieldunit"Display"를 이어붙인 문자열로 한다.
  17. display를 ? GetOption(options, displayField, string, « "auto", "always" », displayDefault)로 한다.
  18. ValidateDurationUnitStyle(unit, style, display, prevStyle)를 수행한다.
  19. unit"hours"이고 twoDigitHourstrue이면 style"2-digit"로 설정한다.
  20. unit"minutes", "seconds"이고 prevStyle"numeric", "2-digit" 중 하나이면 style"2-digit"로 설정한다.
  21. 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 예외를 throw한다.
  2. prevStyle"fractional"이고 style"fractional"이 아니면 RangeError 예외를 throw한다.
  3. prevStyle"numeric", "2-digit"이고 style"fractional", "numeric", "2-digit" 중 하나가 아니면 RangeError 예외를 throw한다.
  4. unused을 반환한다.
Note
unit은 위 알고리즘에서 참조되지 않지만, 구현에서는 예외 메시지 생성 시 사용할 것을 권장한다.

13.5.7 ComputeFractionalDigits ( durationFormat, duration )

The abstract operation ComputeFractionalDigits takes arguments durationFormat (DurationFormat 객체) and duration (Duration Record) and returns 수학적 값. It performs the following steps when called:

  1. result를 0으로 한다.
  2. exponent를 3으로 한다.
  3. Table 24의 각 행(헤더 행 제외)을 표 순서대로 반복하여,
  4. unitOptionsdurationFormat의 내부 슬롯 중 현재 행의 Internal Slot 이름에 해당하는 값으로 한다.
  5. unitOptions.[[Style]]"fractional"이면,
  6. unit을 현재 행의 Unit 값으로 한다.
  7. Assert: IsFractionalSecondUnitName(unit)가 true이다.
  8. valueduration의 필드 중 현재 행의 Value Field 이름에 해당하는 값으로 한다.
  9. resultresult + (value / 10exponent)로 설정한다.
  10. exponentexponent + 3으로 설정한다.
  11. result를 반환한다.

13.5.8 NextUnitFractional ( durationFormat, unit )

The abstract operation NextUnitFractional takes arguments durationFormat (DurationFormat 객체) and unit (문자열) and returns Boolean. It performs the following steps when called:

  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. It performs the following steps when called:

  1. result를 새로운 빈 List로 한다.
  2. hoursStyledurationFormat.[[HoursOptions]].[[Style]]로 한다.
  3. Assert: hoursStyle"numeric" 또는 "2-digit"이다.
  4. nfOptsOrdinaryObjectCreate(null)로 한다.
  5. numberingSystemdurationFormat.[[NumberingSystem]]로 한다.
  6. CreateDataPropertyOrThrow(nfOpts, "numberingSystem", numberingSystem)를 수행한다.
  7. hoursStyle"2-digit"이면,
  8. CreateDataPropertyOrThrow(nfOpts, "minimumIntegerDigits", 2𝔽)를 수행한다.
  9. signDisplayedfalse이면,
  10. CreateDataPropertyOrThrow(nfOpts, "signDisplay", "never")를 수행한다.
  11. CreateDataPropertyOrThrow(nfOpts, "useGrouping", false)를 수행한다.
  12. nf를 ! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOpts »)로 한다.
  13. hoursPartsPartitionNumberPattern(nf, hoursValue)로 한다.
  14. Record { [[Type]], [[Value]] } part에 대해,
  15. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: "hour" }를 result에 추가한다.
  16. result를 반환한다.

13.5.10 FormatNumericMinutes ( durationFormat, minutesValue, hoursDisplayed, signDisplayed )

The abstract operation FormatNumericMinutes takes arguments durationFormat (DurationFormat 객체), minutesValue (정수), hoursDisplayed (Boolean), and signDisplayed (Boolean) and returns RecordList. It performs the following steps when called:

  1. result를 새로운 빈 List로 한다.
  2. hoursDisplayedtrue이면,
  3. separatordurationFormat.[[HourMinuteSeparator]]로 한다.
  4. Record { [[Type]]: "literal", [[Value]]: separator, [[Unit]]: empty }를 result에 추가한다.
  5. minutesStyledurationFormat.[[MinutesOptions]].[[Style]]로 한다.
  6. Assert: minutesStyle"numeric" 또는 "2-digit"이다.
  7. nfOptsOrdinaryObjectCreate(null)로 한다.
  8. numberingSystemdurationFormat.[[NumberingSystem]]로 한다.
  9. CreateDataPropertyOrThrow(nfOpts, "numberingSystem", numberingSystem)를 수행한다.
  10. minutesStyle"2-digit"이면,
  11. CreateDataPropertyOrThrow(nfOpts, "minimumIntegerDigits", 2𝔽)를 수행한다.
  12. signDisplayedfalse이면,
  13. CreateDataPropertyOrThrow(nfOpts, "signDisplay", "never")를 수행한다.
  14. CreateDataPropertyOrThrow(nfOpts, "useGrouping", false)를 수행한다.
  15. nf를 ! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOpts »)로 한다.
  16. minutesPartsPartitionNumberPattern(nf, minutesValue)로 한다.
  17. Record { [[Type]], [[Value]] } part에 대해,
  18. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: "minute" }를 result에 추가한다.
  19. result를 반환한다.

13.5.11 FormatNumericSeconds ( durationFormat, secondsValue, minutesDisplayed, signDisplayed )

The abstract operation FormatNumericSeconds takes arguments durationFormat (DurationFormat 객체), secondsValue (수학적 값), minutesDisplayed (Boolean), and signDisplayed (Boolean) and returns RecordList. It performs the following steps when called:

  1. result를 새로운 빈 List로 한다.
  2. minutesDisplayedtrue이면,
  3. separatordurationFormat.[[MinuteSecondSeparator]]로 한다.
  4. Record { [[Type]]: "literal", [[Value]]: separator, [[Unit]]: empty }를 result에 추가한다.
  5. secondsStyledurationFormat.[[SecondsOptions]].[[Style]]로 한다.
  6. Assert: secondsStyle"numeric" 또는 "2-digit"이다.
  7. nfOptsOrdinaryObjectCreate(null)로 한다.
  8. numberingSystemdurationFormat.[[NumberingSystem]]로 한다.
  9. CreateDataPropertyOrThrow(nfOpts, "numberingSystem", numberingSystem)를 수행한다.
  10. secondsStyle"2-digit"이면,
  11. CreateDataPropertyOrThrow(nfOpts, "minimumIntegerDigits", 2𝔽)를 수행한다.
  12. signDisplayedfalse이면,
  13. CreateDataPropertyOrThrow(nfOpts, "signDisplay", "never")를 수행한다.
  14. CreateDataPropertyOrThrow(nfOpts, "useGrouping", false)를 수행한다.
  15. fractionDigitsdurationFormat.[[FractionalDigits]]로 한다.
  16. fractionDigitsundefined이면,
  17. CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", 9𝔽)를 수행한다.
  18. CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", +0𝔽)를 수행한다.
  19. 그렇지 않으면,
  20. CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", fractionDigits)를 수행한다.
  21. CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", fractionDigits)를 수행한다.
  22. CreateDataPropertyOrThrow(nfOpts, "roundingMode", "trunc")를 수행한다.
  23. nf를 ! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOpts »)로 한다.
  24. secondsPartsPartitionNumberPattern(nf, secondsValue)로 한다.
  25. Record { [[Type]], [[Value]] } part에 대해,
  26. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: "second" }를 result에 추가한다.
  27. result를 반환한다.

13.5.12 FormatNumericUnits ( durationFormat, duration, firstNumericUnit, signDisplayed )

The abstract operation FormatNumericUnits takes arguments durationFormat (DurationFormat 객체), duration (Duration Record), firstNumericUnit (문자열), and signDisplayed (Boolean) and returns RecordList. 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이 아니면,
  9. secondsValueComputeFractionalDigits(durationFormat, duration)를 더한다.
  10. secondsDisplaydurationFormat.[[SecondsOptions]].[[Display]]로 한다.
  11. hoursFormattedfalse로 한다.
  12. firstNumericUnit"hours"이면,
  13. hoursValue가 0이 아니거나 hoursDisplay"always"이면,
  14. hoursFormattedtrue로 설정한다.
  15. secondsValue가 0이 아니거나 secondsDisplay"always"이면,
  16. secondsFormattedtrue로 한다.
  17. 그렇지 않으면,
  18. secondsFormattedfalse로 한다.
  19. minutesFormattedfalse로 한다.
  20. firstNumericUnit"hours" 또는 "minutes"이면,
  21. hoursFormattedtrue이고 secondsFormattedtrue이면,
  22. minutesFormattedtrue로 설정한다.
  23. 그렇지 않고 minutesValue가 0이 아니거나 minutesDisplay"always"이면,
  24. minutesFormattedtrue로 설정한다.
  25. hoursFormattedtrue이면,
  26. signDisplayedtrue이면,
  27. hoursValue가 0이고 DurationSign(duration)이 -1이면,
  28. hoursValuenegative-zero로 설정한다.
  29. hoursPartsFormatNumericHours(durationFormat, hoursValue, signDisplayed)로 한다.
  30. numericPartsListhoursParts를 이어붙인다.
  31. signDisplayedfalse로 설정한다.
  32. minutesFormattedtrue이면,
  33. signDisplayedtrue이면,
  34. minutesValue가 0이고 DurationSign(duration)이 -1이면,
  35. minutesValuenegative-zero로 설정한다.
  36. minutesPartsFormatNumericMinutes(durationFormat, minutesValue, hoursFormatted, signDisplayed)로 한다.
  37. numericPartsListminutesParts를 이어붙인다.
  38. signDisplayedfalse로 설정한다.
  39. secondsFormattedtrue이면,
  40. secondsPartsFormatNumericSeconds(durationFormat, secondsValue, minutesFormatted, signDisplayed)로 한다.
  41. numericPartsListsecondsParts를 이어붙인다.
  42. numericPartsList를 반환한다.

13.5.13 IsFractionalSecondUnitName ( unit )

The abstract operation IsFractionalSecondUnitName takes argument unit (문자열) 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 객체) and partitionedPartsList (RecordListList) and returns List. It performs the following steps when called:

  1. lfOptsOrdinaryObjectCreate(null)로 한다.
  2. CreateDataPropertyOrThrow(lfOpts, "type", "unit")를 수행한다.
  3. listStyledurationFormat.[[Style]]로 한다.
  4. listStyle"digital"이면,
  5. listStyle"short"로 설정한다.
  6. CreateDataPropertyOrThrow(lfOpts, "style", listStyle)를 수행한다.
  7. lf를 ! Construct(%Intl.ListFormat%, « durationFormat.[[Locale]], lfOpts »)로 한다.
  8. strings를 새로운 빈 List로 한다.
  9. partitionedPartsList의 각 요소 parts에 대해,
  10. string을 빈 문자열로 한다.
  11. parts의 각 Record { [[Type]], [[Value]], [[Unit]] } part에 대해,
  12. stringpart.[[Value]]를 이어붙인다.
  13. stringsstring을 추가한다.
  14. formattedPartsListCreatePartsFromList(lf, strings)로 한다.
  15. partitionedPartsIndex를 0으로 한다.
  16. partitionedLengthpartitionedPartsList의 요소 개수로 한다.
  17. flattenedPartsList를 새로운 빈 List로 한다.
  18. formattedPartsList의 각 Record { [[Type]], [[Value]] } listPart에 대해,
  19. listPart.[[Type]]"element"이면,
  20. Assert: partitionedPartsIndex < partitionedLength.
  21. partspartitionedPartsList[partitionedPartsIndex]로 한다.
  22. parts의 각 Record { [[Type]], [[Value]], [[Unit]] } part에 대해,
  23. flattenedPartsListpart를 추가한다.
  24. partitionedPartsIndexpartitionedPartsIndex + 1로 한다.
  25. 그렇지 않으면,
  26. Assert: listPart.[[Type]]"literal"이다.
  27. Record { [[Type]]: "literal", [[Value]]: listPart.[[Value]], [[Unit]]: empty }를 flattenedPartsList에 추가한다.
  28. flattenedPartsList를 반환한다.

13.5.15 PartitionDurationFormatPattern ( durationFormat, duration )

The abstract operation PartitionDurationFormatPattern takes arguments durationFormat (DurationFormat 객체) and duration (Duration Record) and returns List. It performs the following steps when called:

  1. result를 새로운 빈 List로 한다.
  2. signDisplayedtrue로 한다.
  3. numericUnitFoundfalse로 한다.
  4. Table 24의 각 행(헤더 행 제외)을 표 순서대로 반복하면서, numericUnitFoundfalse인 동안 반복한다:
  5. valueduration의 필드 중 현재 행의 Value Field 이름에 해당하는 값으로 한다.
  6. unitOptionsdurationFormat의 내부 슬롯 중 현재 행의 Internal Slot 이름에 해당하는 값으로 한다.
  7. styleunitOptions.[[Style]]로 한다.
  8. displayunitOptions.[[Display]]로 한다.
  9. unit을 현재 행의 Unit 값으로 한다.
  10. numberFormatUnit을 현재 행의 NumberFormat Unit 값으로 한다.
  11. style"numeric" 또는 "2-digit"이면,
  12. numericPartsListFormatNumericUnits(durationFormat, duration, unit, signDisplayed)로 한다.
  13. numericPartsList가 비어있지 않으면 resultnumericPartsList를 추가한다.
  14. numericUnitFoundtrue로 설정한다.
  15. 그렇지 않으면,
  16. nfOptsOrdinaryObjectCreate(null)로 한다.
  17. NextUnitFractional(durationFormat, unit)이 true이면,
  18. valueComputeFractionalDigits(durationFormat, duration)를 더한다.
  19. fractionDigitsdurationFormat.[[FractionalDigits]]로 한다.
  20. fractionDigitsundefined이면,
  21. CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", 9𝔽)를 수행한다.
  22. CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", +0𝔽)를 수행한다.
  23. 그렇지 않으면,
  24. CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", fractionDigits)를 수행한다.
  25. CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", fractionDigits)를 수행한다.
  26. CreateDataPropertyOrThrow(nfOpts, "roundingMode", "trunc")를 수행한다.
  27. numericUnitFoundtrue로 설정한다.
  28. display"always"이거나 value가 0이 아니면,
  29. CreateDataPropertyOrThrow(nfOpts, "numberingSystem", durationFormat.[[NumberingSystem]])를 수행한다.
  30. signDisplayedtrue이면,
  31. signDisplayedfalse로 설정한다.
  32. value가 0이고 DurationSign(duration)이 -1이면 valuenegative-zero로 설정한다.
  33. 그렇지 않으면,
  34. CreateDataPropertyOrThrow(nfOpts, "signDisplay", "never")를 수행한다.
  35. CreateDataPropertyOrThrow(nfOpts, "style", "unit")를 수행한다.
  36. CreateDataPropertyOrThrow(nfOpts, "unit", numberFormatUnit)를 수행한다.
  37. CreateDataPropertyOrThrow(nfOpts, "unitDisplay", style)를 수행한다.
  38. nf를 ! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOpts »)로 한다.
  39. partsPartitionNumberPattern(nf, value)로 한다.
  40. list를 새로운 빈 List로 한다.
  41. parts의 각 Record { [[Type]], [[Value]] } part에 대해,
  42. Record { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: numberFormatUnit }를 list에 추가한다.
  43. listresult에 추가한다.
  44. 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 예외를 throw한다.
  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. roptionsResolution.[[ResolvedLocale]]로 한다.
  6. listFormat.[[Locale]]r.[[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. resolvedLocaleDatar.[[LocaleData]]로 한다.
  12. dataLocaleTypesresolvedLocaleData.[[<type>]]로 한다.
  13. listFormat.[[Templates]]dataLocaleTypes.[[<style>]]로 설정한다.
  14. listFormat을 반환한다.

14.2 Intl.ListFormat 생성자의 속성

Intl.ListFormat 생성자:

14.2.1 Intl.ListFormat.prototype

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

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

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

supportedLocalesOf 메서드가 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은 관련 확장 키를 가지지 않는다.

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

  • [[LocaleData]].[[<locale>]]는 세 필드 [[conjunction]], [[disjunction]], [[unit]]를 가지는 Record이다. 각각은 세 가지 포매팅 스타일 이름 [[long]], [[short]], [[narrow]]를 가지는 Record이어야 한다.
  • 각 필드는 ListFormat 템플릿 집합으로 간주되며, LDML List Format Rules에 명시된 템플릿 문자열을 가지는 [[Pair]], [[Start]], [[Middle]], [[End]] 필드가 있는 Record의 리스트여야 한다. 각 템플릿 문자열은 "{0}""{1}"를 정확히 한 번씩 포함해야 한다. "{0}""{1}"보다 앞에 위치해야 한다.
Note 2
구현에서는 Common Locale Data Repository (https://cldr.unicode.org/)에서 제공하는 로케일 데이터를 사용하는 것이 권장된다. LDML의 listPattern에서 conjunction은 "standard", disjunction은 "or", unit은 "unit"에 해당한다.
Note 3
리스트 타입 중에서 conjunction은 "and" 기반 리스트(예: "A, B, 그리고 C"), disjunction은 "or" 기반 리스트(예: "A, B, 또는 C"), unit은 단위가 있는 값 리스트(예: "5 파운드, 12 온스")를 의미한다.

14.3 Intl.ListFormat 프로토타입 객체의 속성

Intl.ListFormat 프로토타입 객체:

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

14.3.1 Intl.ListFormat.prototype.constructor

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

14.3.2 Intl.ListFormat.prototype.resolvedOptions ( )

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

  1. lfthis 값으로 한다.
  2. RequireInternalSlot(lf, [[InitializedListFormat]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 한다.
  4. Table 25의 각 행(헤더 행 제외)을 테이블 순서대로 반복한다.
  5. p를 현재 행의 Property 값으로 한다.
  6. vlf의 내부 슬롯 중 현재 행의 Internal Slot 값으로 한다.
  7. Assert: vundefined가 아니다.
  8. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  9. 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% 속성의 초기값은 문자열 값 "Intl.ListFormat"이다.

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

14.4 Intl.ListFormat 인스턴스의 속성

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

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

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

  • [[Locale]]는 리스트 포매트 스타일에 사용되는 로케일의 언어 태그를 가진 문자열 값이다.
  • [[Type]]"conjunction", "disjunction", "unit" 중 하나의 문자열 값으로, 사용된 리스트 타입을 식별한다.
  • [[Style]]"long", "short", "narrow" 중 하나의 문자열 값으로, 사용된 리스트 포매팅 스타일을 식별한다.
  • [[Templates]]ListFormat 템플릿 집합이다.

14.5 ListFormat 객체의 추상 연산

14.5.1 DeconstructPattern ( pattern, placeables )

The abstract operation DeconstructPattern takes arguments pattern (패턴 문자열) and placeables (Record) and returns 리스트. It performs the following steps when called:

  1. patternPartsPartitionPattern(pattern)으로 한다.
  2. result를 새로운 빈 리스트로 한다.
  3. Record { [[Type]], [[Value]] } patternPart에 대해,
  4. partpatternPart.[[Type]]로 한다.
  5. part"literal"이면,
  6. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }를 result에 추가한다.
  7. 그렇지 않으면,
  8. Assert: placeables는 [[<part>]] 필드를 가진다.
  9. substplaceables.[[<part>]]로 한다.
  10. subst가 리스트이면,
  11. 각 요소 s에 대해,
  12. sresult에 추가한다.
  13. 그렇지 않으면,
  14. substresult에 추가한다.
  15. result를 반환한다.

14.5.2 CreatePartsFromList ( listFormat, list )

The abstract operation CreatePartsFromList takes arguments listFormat (Intl.ListFormat) and list (문자열 리스트) and returns [[Type]] ("element" 또는 "literal")와 [[Value]](문자열)를 가지는 Record 리스트. It performs the following steps when called:

  1. sizelist의 요소 개수로 한다.
  2. size가 0이면,
  3. 새로운 빈 리스트를 반환한다.
  4. size가 2이면,
  5. nlistFormat.[[Templates]]에서 listFormat.[[Locale]], list[0], list[1]에 기반한 인덱스로 한다.
  6. patternlistFormat.[[Templates]][n].[[Pair]]로 한다.
  7. firstRecord { [[Type]]: "element", [[Value]]: list[0] }로 한다.
  8. secondRecord { [[Type]]: "element", [[Value]]: list[1] }로 한다.
  9. placeablesRecord { [[0]]: first, [[1]]: second }로 한다.
  10. DeconstructPattern(pattern, placeables)를 반환한다.
  11. lastRecord { [[Type]]: "element", [[Value]]: list[size - 1] }로 한다.
  12. parts를 « last »로 한다.
  13. isize - 2로 한다.
  14. i ≥ 0인 동안 반복한다,
  15. headRecord { [[Type]]: "element", [[Value]]: list[i] }로 한다.
  16. nlistFormat.[[Templates]]에서 listFormat.[[Locale]], head, parts에 기반한 구현 정의 인덱스로 한다.
  17. i가 0이면,
  18. patternlistFormat.[[Templates]][n].[[Start]]로 한다.
  19. isize - 2보다 작으면,
  20. patternlistFormat.[[Templates]][n].[[Middle]]로 한다.
  21. 그렇지 않으면,
  22. patternlistFormat.[[Templates]][n].[[End]]로 한다.
  23. placeablesRecord { [[0]]: head, [[1]]: parts }로 한다.
  24. partsDeconstructPattern(pattern, placeables)로 설정한다.
  25. i를 1 감소시킨다.
  26. parts를 반환한다.
Note
여러 템플릿 중 인덱스 n을 선택하는 것은 스페인어처럼 다음 단어에 따라 "y" 또는 "e"를 선택하는 등 접속사가 문맥에 따라 달라질 수 있도록 한다.

14.5.3 FormatList ( listFormat, list )

The abstract operation FormatList takes arguments listFormat (Intl.ListFormat) and list (문자열 리스트) and returns 문자열. It performs the following steps when called:

  1. partsCreatePartsFromList(listFormat, list)로 한다.
  2. result를 빈 문자열로 한다.
  3. Record { [[Type]], [[Value]] } part에 대해,
  4. resultresultpart.[[Value]]의 문자열 연결로 설정한다.
  5. result를 반환한다.

14.5.4 FormatListToParts ( listFormat, list )

The abstract operation FormatListToParts takes arguments listFormat (Intl.ListFormat) and list (문자열 리스트) and returns 배열. It performs the following steps when called:

  1. partsCreatePartsFromList(listFormat, list)로 한다.
  2. result를 ! ArrayCreate(0)로 한다.
  3. n을 0으로 한다.
  4. Record { [[Type]], [[Value]] } part에 대해,
  5. OOrdinaryObjectCreate(%Object.prototype%)로 한다.
  6. CreateDataPropertyOrThrow(O, "type", part.[[Type]])를 수행한다.
  7. CreateDataPropertyOrThrow(O, "value", part.[[Value]])를 수행한다.
  8. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), O)를 수행한다.
  9. n을 1 증가시킨다.
  10. result를 반환한다.

14.5.5 StringListFromIterable ( iterable )

The abstract operation StringListFromIterable takes argument iterable (ECMAScript 언어 값) and returns 문자열 리스트 또는 throw completion. It performs the following steps when called:

  1. iterableundefined이면,
  2. 새로운 빈 리스트를 반환한다.
  3. iteratorRecord를 ? GetIterator(iterable, sync)로 한다.
  4. list를 새로운 빈 리스트로 한다.
  5. 반복한다,
  6. next를 ? IteratorStepValue(iteratorRecord)로 한다.
  7. nextdone이면,
  8. list를 반환한다.
  9. next가 문자열이 아니면,
  10. error를 새로 생성된 TypeError 객체로 ThrowCompletion한다.
  11. IteratorClose(iteratorRecord, error)를 반환한다.
  12. nextlist에 추가한다.
Note

이 알고리즘은 문자열이 아닌 값을 만나면 예외를 발생시키는데, 임의의 값에 대해 명확한 로케일 인식 변환이 없기 때문이다.

15 로케일 객체

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* 예외를 throw한다.
        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* 예외를 throw한다.
        1. _tag_가 Object이고 [[InitializedLocale]] 내부 슬롯이 있으면,
        1. _tag_를 _tag_.[[Locale]]로 한다.
        1. 그렇지 않으면,
        1. _tag_를 ? ToString(_tag_)로 한다.
        1. _options_를 ? CoerceOptionsToObject(_options_)로 한다.
        1. IsWellFormedLanguageTag(_tag_)가 *false*이면, *RangeError* 예외를 throw한다.
        1. NOTE: LanguageId canonicalizationsupplementalMetadata.xml의
        Alias Rules에 따라 _tag_를 임의로 변경할 수 있으므로, _options_에서 오버라이드를 적용하기 전에 이러한 canonicalization을 수행해야 한다.
        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 nonterminal에 매칭되지 않으면, *RangeError* 예외를 throw한다.
        1. _opt_.[[ca]]를 _calendar_로 한다.
        1. _collation_을 ? GetOption(_options_, *"collation"*, ~string~, ~empty~, *undefined*)로 한다.
        1. _collation_이 *undefined*가 아니면,
        1. _collation_이 type Unicode locale nonterminal에 매칭되지 않으면, *RangeError* 예외를 throw한다.
        1. _opt_.[[co]]를 _collation_으로 한다.
        1. _fw_를 ? GetOption(_options_, *"firstDayOfWeek"*, ~string~, ~empty~, *undefined*)로 한다.
        1. _fw_가 *undefined*가 아니면,
        1. _fw_를 WeekdayToUValue(_fw_)로 한다.
        1. _fw_가 type Unicode locale nonterminal에 매칭되지 않으면, *RangeError* 예외를 throw한다.
        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 nonterminal에 매칭되지 않으면, *RangeError* 예외를 throw한다.
        1. _opt_.[[nu]]를 _numberingSystem_으로 한다.
        1. _r_를 MakeLocaleRecord(_tag_, _opt_, _localeExtensionKeys_)로 한다.
        1. _locale_.[[Locale]]를 _r_.[[locale]]로 한다.
        1. _locale_.[[Calendar]]를 _r_.[[ca]]로 한다.
        1. _locale_.[[Collation]]을 _r_.[[co]]로 한다.
        1. _locale_.[[FirstDayOfWeek]]를 _r_.[[fw]]로 한다.
        1. _locale_.[[HourCycle]]를 _r_.[[hc]]로 한다.
        1. _localeExtensionKeys_에 *"kf"*가 포함되어 있으면,
        1. _locale_.[[CaseFirst]]를 _r_.[[kf]]로 한다.
        1. _localeExtensionKeys_에 *"kn"*가 포함되어 있으면,
        1. SameValue(_r_.[[kn]], *"true"*)가 *true*이거나 _r_.[[kn]]이 빈 문자열이면,
        1. _locale_.[[Numeric]]을 *true*로 한다.
        1. 그렇지 않으면,
        1. _locale_.[[Numeric]]을 *false*로 한다.
        1. _locale_.[[NumberingSystem]]을 _r_.[[nu]]로 한다.
        1. _locale_를 반환한다.
      

15.1.2 UpdateLanguageId ( tag, options )

The abstract operation UpdateLanguageId takes arguments tag (well-formed language tag) and options (Object) and returns 정상 완료 시 well-formed language tag 또는 throw completion. 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 예외를 throw한다.
  4. script를 ? GetOption(options, "script", string, empty, GetLocaleScript(baseName))로 한다.
  5. scriptundefined가 아니면,
  6. scriptunicode_script_subtag Unicode locale nonterminal에 매칭되지 않으면, RangeError 예외를 throw한다.
  7. region을 ? GetOption(options, "region", string, empty, GetLocaleRegion(baseName))로 한다.
  8. regionundefined가 아니면,
  9. regionunicode_region_subtag Unicode locale nonterminal에 매칭되지 않으면, RangeError 예외를 throw한다.
  10. variants를 ? GetOption(options, "variants", string, empty, GetLocaleVariants(baseName))로 한다.
  11. variantsundefined가 아니면,
  12. variants가 빈 문자열이면, RangeError 예외를 throw한다.
  13. lowerVariantsvariants의 ASCII 소문자로 한다.
  14. variantSubtagsStringSplitToList(lowerVariants, "-")로 한다.
  15. variantSubtags의 요소 variant에 대해,
  16. variantunicode_variant_subtag Unicode locale nonterminal에 매칭되지 않으면, RangeError 예외를 throw한다.
  17. variantSubtags에 중복 요소가 있으면, RangeError 예외를 throw한다.
  18. allExtensionstag에서 baseName 이후의 접미사로 한다.
  19. newTaglanguage로 한다.
  20. scriptundefined가 아니면, newTagnewTag, "-", script의 문자열 연결로 한다.
  21. regionundefined가 아니면, newTagnewTag, "-", region의 문자열 연결로 한다.
  22. variantsundefined가 아니면, newTagnewTag, "-", variants의 문자열 연결로 한다.
  23. newTagnewTagallExtensions의 문자열 연결로 한다.
  24. newTag를 반환한다.

15.1.3 MakeLocaleRecord ( tag, options, localeExtensionKeys )

The abstract operation MakeLocaleRecord takes arguments tag (language tag), options (Record), and localeExtensionKeys (String 리스트) and returns Record. It performs the following steps when called:

  1. tagsubstring이 Unicode locale extension sequence이면,
  2. extensiontag 내 Unicode locale extension sequence의 substring의 String 값으로 한다.
  3. componentsUnicodeExtensionComponents(extension)로 한다.
  4. attributescomponents.[[Attributes]]로 한다.
  5. keywordscomponents.[[Keywords]]로 한다.
  6. 그렇지 않으면,
  7. attributes를 새 빈 리스트로 한다.
  8. keywords를 새 빈 리스트로 한다.
  9. result를 새 Record로 한다.
  10. localeExtensionKeys의 각 key에 대해,
  11. keywords[[Key]]key인 요소가 있으면,
  12. entrykeywords[[Key]]key인 요소로 한다.
  13. valueentry.[[Value]]로 한다.
  14. 그렇지 않으면,
  15. entryempty로 한다.
  16. valueundefined로 한다.
  17. Assert: options에 [[<key>]] 필드가 있다.
  18. overrideValueoptions.[[<key>]]로 한다.
  19. overrideValueundefined가 아니면,
  20. value를 CanonicalizeUValue(key, overrideValue)로 한다.
  21. entryempty가 아니면,
  22. entry.[[Value]]value로 한다.
  23. 그렇지 않으면,
  24. Record { [[Key]]: key, [[Value]]: value }를 keywords에 추가한다.
  25. result.[[<key>]]를 value로 한다.
  26. localetag에서 Unicode locale extension sequence를 제거한 String 값으로 한다.
  27. attributes가 비어있지 않거나 keywords가 비어있지 않으면,
  28. result.[[locale]]InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords)로 한다.
  29. 그렇지 않으면,
  30. result.[[locale]]CanonicalizeUnicodeLocaleId(locale)로 한다.
  31. result를 반환한다.

15.2 Intl.Locale 생성자의 속성

Intl.Locale 생성자:

15.2.1 Intl.Locale.prototype

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

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

15.2.2 내부 슬롯

[[LocaleExtensionKeys]] 내부 슬롯의 값은 « "ca", "co", "fw", "hc", "nu" »의 모든 요소를 포함해야 하며, %Intl.Collator%.[[RelevantExtensionKeys]]의 요소 중 « "kf", "kn" »의 요소도 추가로 포함해야 하며, 다른 요소는 포함하지 않아야 한다.

15.3 Intl.Locale 프로토타입 객체의 속성

Intl.Locale 프로토타입 객체:

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

15.3.1 Intl.Locale.prototype.constructor

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

15.3.2 get Intl.Locale.prototype.baseName

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

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

15.3.3 get Intl.Locale.prototype.calendar

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

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

15.3.4 get Intl.Locale.prototype.caseFirst

이 속성은 %Intl.Locale%.[[LocaleExtensionKeys]]"kf"가 포함되어 있을 때만 존재한다.

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

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

15.3.5 get Intl.Locale.prototype.collation

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

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

15.3.6 get Intl.Locale.prototype.firstDayOfWeek

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

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

15.3.7 get Intl.Locale.prototype.hourCycle

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

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

15.3.8 get Intl.Locale.prototype.language

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

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

15.3.9 Intl.Locale.prototype.maximize ( )

  1. locthis 값으로 한다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. maximalAdd Likely Subtags 알고리즘을 loc.[[Locale]]에 적용한 결과로 한다. 오류가 발생하면 maximalloc.[[Locale]]로 한다.
  4. Construct(%Intl.Locale%, maximal)을 반환한다.

15.3.10 Intl.Locale.prototype.minimize ( )

  1. locthis 값으로 한다.
  2. RequireInternalSlot(loc, [[InitializedLocale]])를 수행한다.
  3. minimalRemove Likely Subtags 알고리즘을 loc.[[Locale]]에 적용한 결과로 한다. 오류가 발생하면 minimalloc.[[Locale]]로 한다.
  4. Construct(%Intl.Locale%, minimal)을 반환한다.

15.3.11 get Intl.Locale.prototype.numberingSystem

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

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

15.3.12 get Intl.Locale.prototype.numeric

이 속성은 %Intl.Locale%.[[LocaleExtensionKeys]]"kn"가 포함되어 있을 때만 존재한다.

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

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

15.3.13 get Intl.Locale.prototype.region

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

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

15.3.14 get Intl.Locale.prototype.script

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

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

15.3.15 Intl.Locale.prototype.toString ( )

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

15.3.16 Intl.Locale.prototype.getCalendars ( )

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

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

15.3.17 Intl.Locale.prototype.getCollations ( )

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

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

15.3.18 Intl.Locale.prototype.getHourCycles ( )

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

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

15.3.19 Intl.Locale.prototype.getNumberingSystems ( )

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

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

15.3.20 Intl.Locale.prototype.getTimeZones ( )

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

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

15.3.21 Intl.Locale.prototype.getTextInfo ( )

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

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

15.3.22 Intl.Locale.prototype.getWeekInfo ( )

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

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

15.3.23 get Intl.Locale.prototype.variants

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

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

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

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

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

15.4 Intl.Locale 인스턴스의 속성

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

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

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

  • [[Locale]]는 로케일의 언어 태그를 가진 String 값으로, 포매팅에 사용되는 로케일을 나타낸다.
  • [[Calendar]]undefined이거나, Unicode Calendar Identifier의 canonical form인 String 값이다.
  • [[Collation]]undefined이거나, Unicode Collation Identifier의 canonical form인 String 값이다.
  • [[FirstDayOfWeek]]undefined이거나, Unicode First Day Identifier의 canonical form인 String 값이다.
  • [[HourCycle]]undefined이거나, Unicode Hour Cycle Identifier의 canonical form인 String 값이다.
  • [[NumberingSystem]]undefined이거나, Unicode Number System Identifier의 canonical form인 String 값이다.
  • [[CaseFirst]]undefined이거나, String 값 "upper", "lower", "false" 중 하나이다. 이 내부 슬롯은 %Intl.Locale%[[LocaleExtensionKeys]] 내부 슬롯에 "kf"가 포함되어 있을 때만 존재한다.
  • [[Numeric]]undefined이거나, 로케일에서 숫자 정렬 사용 여부를 나타내는 Boolean 값이다. 이 내부 슬롯은 %Intl.Locale%[[LocaleExtensionKeys]] 내부 슬롯에 "kn"가 포함되어 있을 때만 존재한다.

15.5 로케일 객체의 추상 연산

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. locale에서 unicode_language_id Unicode locale nonterminal에 매칭되는 가장 긴 접두사를 반환한다.

15.5.2 GetLocaleLanguage ( locale )

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

  1. baseNameGetLocaleBaseName(locale)로 한다.
  2. Assert: baseName의 첫 번째 서브태그unicode_language_subtag Unicode locale nonterminal에 매칭될 수 있다.
  3. baseName의 첫 번째 서브태그를 반환한다.

15.5.3 GetLocaleScript ( locale )

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

  1. baseNameGetLocaleBaseName(locale)로 한다.
  2. Assert: baseName에는 unicode_script_subtag Unicode locale nonterminal에 매칭되는 서브태그가 최대 하나만 포함된다.
  3. baseNameunicode_script_subtag Unicode locale nonterminal에 매칭되는 서브태그가 있으면, 그 서브태그를 반환한다.
  4. undefined를 반환한다.

15.5.4 GetLocaleRegion ( locale )

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

  1. baseNameGetLocaleBaseName(locale)로 한다.
  2. NOTE: unicode_region_subtag 서브태그는 초기 unicode_language_subtag 서브태그 바로 뒤에만 유효하며, 그 사이에 unicode_script_subtag 서브태그가 하나 있을 수 있다. 해당 위치에서 unicode_region_subtag는 다른 유효 서브태그와 혼동되지 않는다.
  3. Assert: baseName의 첫 번째 서브태그unicode_language_subtag Unicode locale nonterminal에 매칭될 수 있다.
  4. baseNameTailbaseName의 첫 번째 서브태그 이후의 접미사로 한다.
  5. Assert: baseNameTail에는 unicode_region_subtag Unicode locale nonterminal에 매칭되는 서브태그가 최대 하나만 포함된다.
  6. baseNameTailunicode_region_subtag Unicode locale nonterminal에 매칭되는 서브태그가 있으면, 그 서브태그를 반환한다.
  7. undefined를 반환한다.

15.5.5 GetLocaleVariants ( locale )

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

  1. baseNameGetLocaleBaseName(locale)로 한다.
  2. NOTE: baseName에서 "-"로 시작하는 각 서브태그unicode_script_subtag, unicode_region_subtag, unicode_variant_subtag 중 하나이며, unicode_variant_subtag에 매칭되는 substring은 다른 production에 매칭될 수 있는 접두사보다 엄격하게 더 길다.
  3. variantsbaseName의 가장 긴 접미사 중 "-"로 시작하고 unicode_variant_subtag Unicode locale nonterminal에 매칭되는 substring이 있는 경우로 한다. 그런 접미사가 없으면 undefined를 반환한다.
  4. variants의 1부터의 substring을 반환한다.

15.5.6 UnicodeExtensionValue ( locale, key )

The abstract operation UnicodeExtensionValue takes arguments locale (Unicode 정규화된 로케일 식별자) and key (String) and returns String 또는 empty. It performs the following steps when called:

  1. localeUnicode 로케일 확장 시퀀스가 포함되어 있으면,
  2. extensionlocaleUnicode 로케일 확장 시퀀스로 한다.
  3. componentsUnicodeExtensionComponents(extension)로 한다.
  4. keywordscomponents.[[Keywords]]로 한다.
  5. keywords의 요소 중 entry.[[Key]]key인 요소가 있으면, entry.[[Value]]를 반환한다.
  6. empty를 반환한다.

15.5.7 CanonicalUnicodeSubdivision ( locale, key )

The abstract operation CanonicalUnicodeSubdivision takes arguments locale (Unicode 정규화된 로케일 식별자) and key ("rg" 또는 "sd") and returns String 또는 undefined. It performs the following steps when called:

  1. subdivisionUnicodeExtensionValue(locale, key)로 한다.
  2. subdivisionempty이면, undefined를 반환한다.
  3. subdivisionunicode_subdivision_id Unicode 로케일 nonterminal에 매칭되지 않으면, undefined를 반환한다.
  4. regionsubdivision에서 unicode_region_subtag Unicode 로케일 nonterminal에 매칭되는 가장 긴 접두사로 한다.
  5. regionLocale"und-"region의 문자열 연결로 한다.
  6. regionLocaleCanonicalizeUnicodeLocaleId(regionLocale)로 한다.
  7. GetLocaleRegion(regionLocale)를 반환한다.

15.5.8 RegionPreference ( locale )

The abstract operation RegionPreference takes argument locale (Unicode 정규화된 로케일 식별자) and returns Record, 필드 [[Region]](String), [[RegionOverride]](String 또는 undefined). It performs the following steps when called:

  1. regionGetLocaleRegion(locale)로 한다.
  2. regionundefined이면,
  3. regionCanonicalUnicodeSubdivision(locale, "sd")로 한다.
  4. regionundefined이면,
  5. maximalLikely Subtags 추가 알고리즘을 locale에 적용한 결과로 한다. 오류가 발생하면 maximallocale로 한다.
  6. maximalCanonicalizeUnicodeLocaleId(maximal)로 한다.
  7. regionGetLocaleRegion(maximal)로 한다.
  8. regionundefined이면,
  9. region"001"로 한다.
  10. regionOverrideCanonicalUnicodeSubdivision(locale, "rg")로 한다.
  11. { [[Region]]: region, [[RegionOverride]]: regionOverride }를 반환한다.

15.5.9 CalendarsOfLocale ( loc )

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

  1. loc.[[Calendar]]undefined가 아니면,
  2. CreateArrayFromListloc.[[Calendar]] »)를 반환한다.
  3. preferenceRegionPreference(loc.[[Locale]])로 한다.
  4. regionpreference.[[Region]]로 한다.
  5. regionOverridepreference.[[RegionOverride]]로 한다.
  6. regionOverrideundefined가 아니고 regionOverride에 대한 calendar preference data가 있으면,
  7. lookupRegionregionOverride로 한다.
  8. 그렇지 않으면,
  9. lookupRegionregion으로 한다.
  10. list6.9의 canonical form으로 정렬된 고유 calendar type 리스트로 한다. lookupRegion에서 날짜 및 시간 포매팅에 일반적으로 사용되는 calendar type만 포함한다. lookupRegion에 대한 calendar preference data가 없으면 리스트는 비어 있다.
  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가 아니면,
  2. CreateArrayFromListloc.[[Collation]] »)를 반환한다.
  3. languageGetLocaleLanguage(loc.[[Locale]])로 한다.
  4. language"und"가 아니면,
  5. rLookupMatchingLocaleByPrefix(%Intl.Collator%.[[AvailableLocales]], « loc.[[Locale]] »)로 한다.
  6. rundefined가 아니면,
  7. foundLocaler.[[locale]]로 한다.
  8. 그렇지 않으면,
  9. foundLocaleDefaultLocale()로 한다.
  10. foundLocaleData%Intl.Collator%.[[SortLocaleData]].[[<foundLocale>]]로 한다.
  11. listfoundLocaleData.[[co]]의 복사본으로 한다.
  12. Assert: list[0]은 null이다.
  13. 첫 번째 요소를 list에서 제거한다.
  14. 그렇지 않으면,
  15. list를 « "emoji", "eor" »로 한다.
  16. sortedlist의 복사본으로, 코드 유닛 순서로 정렬한다.
  17. CreateArrayFromList(sorted)를 반환한다.

15.5.11 HourCyclesOfLocale ( loc )

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

  1. loc.[[HourCycle]]undefined가 아니면,
  2. CreateArrayFromListloc.[[HourCycle]] »)를 반환한다.
  3. preferenceRegionPreference(loc.[[Locale]])로 한다.
  4. regionpreference.[[Region]]로 한다.
  5. regionOverridepreference.[[RegionOverride]]로 한다.
  6. regionOverrideundefined가 아니고 regionOverride에 대한 time data가 있으면,
  7. lookupRegionregionOverride로 한다.
  8. 그렇지 않으면,
  9. lookupRegionregion으로 한다.
  10. list를 고유 hour cycle 식별자 리스트로 한다. 각 식별자는 소문자 String 값이며, 12시간 형식("h11", "h12") 또는 24시간 형식("h23", "h24") 중 하나이다. lookupRegion에서 날짜 및 시간 포매팅에 일반적으로 사용되는 hour cycle만 포함하며, 코드 유닛 순서로 정렬한다. lookupRegion에 대한 time data가 없으면 리스트는 비어 있다.
  11. list가 비어 있으면, list를 « "h23" »로 한다.
  12. 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가 아니면,
  2. CreateArrayFromListloc.[[NumberingSystem]] »)를 반환한다.
  3. rLookupMatchingLocaleByPrefix(%Intl.NumberFormat%.[[AvailableLocales]], « loc.[[Locale]] »)로 한다.
  4. rundefined가 아니면,
  5. foundLocaler.[[locale]]로 한다.
  6. foundLocaleData%Intl.NumberFormat%.[[LocaleData]].[[<foundLocale>]]로 한다.
  7. numberingSystemsfoundLocaleData.[[nu]]로 한다.
  8. list를 « numberingSystems[0] »로 한다.
  9. 그렇지 않으면,
  10. list를 « "latn" »로 한다.
  11. CreateArrayFromList(list)를 반환한다.

15.5.13 TimeZonesOfLocale ( loc )

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

  1. regionGetLocaleRegion(loc.[[Locale]])로 한다.
  2. regionundefined이면, undefined를 반환한다.
  3. listregion에서 일반적으로 사용되는 고유 canonical time zone identifier의 리스트로 한다. 각 식별자는 IANA Time Zone Database의 canonical Zone 이름을 나타내는 String 값이어야 한다. 리스트가 비어 있으면 해당 지역에서 일반적으로 사용되는 time zone이 없음을 의미한다. 리스트는 코드 유닛 순서로 정렬된다.
  4. CreateArrayFromList(list)를 반환한다.

15.5.14 TextDirectionOfLocale ( loc )

The implementation-defined abstract operation TextDirectionOfLocale takes argument loc (an Intl.Locale) and returns a String or undefined. It performs the following steps when called:

  1. localeloc.[[Locale]]로 한다.
  2. scriptGetLocaleScript(locale)로 한다.
  3. scriptundefined이면,
  4. maximalLikely Subtags 추가 알고리즘을 locale에 적용한 결과로 한다. 오류가 발생하면 undefined를 반환한다.
  5. scriptGetLocaleScript(maximal)로 한다.
  6. scriptundefined이면, undefined를 반환한다.
  7. script에서 줄 내 문자들의 기본 일반 정렬 방향이 오른쪽에서 왼쪽이면, "rtl"을 반환한다.
  8. script에서 줄 내 문자들의 기본 일반 정렬 방향이 왼쪽에서 오른쪽이면, "ltr"을 반환한다.
  9. undefined를 반환한다.
Note 1
script에서 줄 내 문자들의 기본 일반 정렬 방향을 결정할 수 없거나, 방향이 오른쪽에서 왼쪽 또는 왼쪽에서 오른쪽이 아닌 경우에는 undefined가 반환된다.
Note 2
한 언어의 텍스트는 둘 이상의 방향을 가질 수 있다. 한 언어가 한 스크립트로 작성될 때에도 둘 이상의 방향이 있을 수 있다. 따라서 텍스트에 연결된 메타데이터에 방향 정보가 포함되어 있다면, 그 방향 정보가 우선적으로 신뢰되어야 한다. TextDirectionOfLocale에서 반환되는 정보는 텍스트에 방향 정보가 없고 언어 정보만 알려진 경우에만 보조적으로 사용해야 한다. 웹 개발자는 텍스트의 방향을 결정할 때 이 API에 지나치게 의존해서는 안 된다.

15.5.15 WeekdayToUValue ( fw )

The abstract operation WeekdayToUValue takes argument fw (a String) and returns a String. It performs the following steps when called:

  1. Table 26의 각 행(헤더 행 제외)을 테이블 순서대로 반복하여,
  2. 현재 행의 Weekday 값을 w로 한다.
  3. 현재 행의 String 값을 s로 한다.
  4. fww와 같으면, s를 반환한다.
  5. fw를 반환한다.
Table 26: 요일 문자열과 값
Weekday String Value
"0" "sun" 7𝔽
"1" "mon" 1𝔽
"2" "tue" 2𝔽
"3" "wed" 3𝔽
"4" "thu" 4𝔽
"5" "fri" 5𝔽
"6" "sat" 6𝔽
"7" "sun" 7𝔽

15.5.16 WeekdayUValueToNumber ( fw )

The abstract operation WeekdayUValueToNumber takes argument fw (a String) and returns an integral Number or undefined. It performs the following steps when called:

  1. Table 26의 각 행(헤더 행 제외)을 테이블 순서대로 반복하여,
  2. 현재 행의 String 값을 s로 한다.
  3. 현재 행의 Value 값을 v로 한다.
  4. fws와 같으면, v를 반환한다.
  5. undefined를 반환한다.

15.5.17 WeekInfoOfLocale ( loc )

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

  1. localeloc.[[Locale]]로 한다.
  2. Table 27에 정의된 필드를 가지는 Record r를 생성하며, 값은 locale에 따라 결정한다.
  3. fwsloc.[[FirstDayOfWeek]]로 한다.
  4. fwWeekdayUValueToNumber(fws)로 한다.
  5. fwundefined가 아니면,
  6. r.[[FirstDay]]fw로 설정한다.
  7. r를 반환한다.
Note
반환되는 Record의 값은 Unicode 기술 표준 #35 Part 4 Dates, Week DataFirst Day Overrides에 따라 locale에 의해 결정된다.
Table 27: WeekInfo Record 필드
Field Name Value Meaning
[[FirstDay]] ISO 8601 calendar day of week의 1-based ordinal 값으로, 월요일이 1𝔽이고 일요일이 7𝔽인 주의 요일 순서 내 위치를 나타낸다. 달력에서 “첫째 날”로 간주되는 요일.
[[Weekend]] 월요일(1𝔽)부터 일요일(7𝔽)까지의 ISO 8601 calendar day of week 정수 값 리스트로, 오름차순으로 정렬된다. 달력에서 “주말”로 간주되는 요일의 리스트. 주말의 요일 수는 로케일마다 다를 수 있으며, 연속적이지 않을 수도 있다.

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이면, newTarget을 활성 함수 객체로 하고, 아니면 newTarget을 NewTarget으로 한다.
  2. numberFormat을 ? OrdinaryCreateFromConstructor(newTarget, "%Intl.NumberFormat.prototype%", « [[InitializedNumberFormat]], [[Locale]], [[LocaleData]], [[NumberingSystem]], [[Style]], [[Unit]], [[UnitDisplay]], [[Currency]], [[CurrencyDisplay]], [[CurrencySign]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[RoundingType]], [[Notation]], [[CompactDisplay]], [[UseGrouping]], [[SignDisplay]], [[RoundingIncrement]], [[RoundingMode]], [[ComputedRoundingPriority]], [[TrailingZeroDisplay]], [[BoundFormat]] »)로 한다.
  3. optionsResolution을 ? ResolveOptions(%Intl.NumberFormat%, %Intl.NumberFormat%.[[LocaleData]], locales, options, « coerce-options »)로 한다.
  4. optionsoptionsResolution.[[Options]]로 설정한다.
  5. roptionsResolution.[[ResolvedLocale]]로 한다.
  6. numberFormat.[[Locale]]r.[[Locale]]로 설정한다.
  7. numberFormat.[[LocaleData]]r.[[LocaleData]]로 설정한다.
  8. numberFormat.[[NumberingSystem]]r.[[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"이면,
  14. currencynumberFormat.[[Currency]]로 한다.
  15. cDigitsCurrencyDigits(currency)로 한다.
  16. mnfdDefaultcDigits로 한다.
  17. mxfdDefaultcDigits로 한다.
  18. 아니면,
  19. mnfdDefault를 0으로 한다.
  20. style"percent"이면,
  21. mxfdDefault를 0으로 한다.
  22. 아니면,
  23. mxfdDefault를 3으로 한다.
  24. SetNumberFormatDigitOptions(numberFormat, options, mnfdDefault, mxfdDefault, notation)를 수행한다.
  25. compactDisplay를 ? GetOption(options, "compactDisplay", string, « "short", "long" », "short")로 한다.
  26. defaultUseGrouping"auto"로 한다.
  27. notation"compact"이면,
  28. numberFormat.[[CompactDisplay]]compactDisplay로 설정한다.
  29. defaultUseGrouping"min2"로 설정한다.
  30. 참고: 역사적 이유로, 문자열 "true""false"는 허용되며 기본값으로 대체된다.
  31. useGrouping을 ? GetBooleanOrStringNumberFormatOption(options, "useGrouping", « "min2", "auto", "always", "true", "false" », defaultUseGrouping)로 한다.
  32. useGrouping"true" 또는 "false"이면, useGroupingdefaultUseGrouping으로 설정한다.
  33. useGroupingtrue이면, useGrouping"always"로 설정한다.
  34. numberFormat.[[UseGrouping]]useGrouping으로 설정한다.
  35. signDisplay를 ? GetOption(options, "signDisplay", string, « "auto", "never", "always", "exceptZero", "negative" », "auto")로 한다.
  36. numberFormat.[[SignDisplay]]signDisplay로 설정한다.
  37. 구현이 4.3 Note 1의 규범적 선택적 생성자 모드를 지원한다면,
  38. thisthis 값으로 한다.
  39. ChainNumberFormat(numberFormat, NewTarget, this)를 반환한다.
  40. numberFormat을 반환한다.

16.1.1.1 ChainNumberFormat ( numberFormat, newTarget, this )

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

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

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

The abstract operation SetNumberFormatDigitOptions takes arguments intlObj (객체), options (객체), mnfdDefault (정수), mxfdDefault (정수), and notation (문자열) and returns 정상 완료 시 unused 또는 throw 완료. It performs the following steps when called:

  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 예외를 throw한다.
  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. 참고: SetNumberFormatDigitOptions에서 필요한 모든 필드는 options에서 읽었다. 이후 AO는 옵션을 해석하며 예외를 throw할 수 있다.
  13. roundingIncrement가 1이 아니면, mxfdDefaultmnfdDefault로 설정한다.
  14. intlObj.[[RoundingIncrement]]roundingIncrement로 설정한다.
  15. intlObj.[[RoundingMode]]roundingMode로 설정한다.
  16. intlObj.[[TrailingZeroDisplay]]trailingZeroDisplay로 설정한다.
  17. mnsdmxsdundefined이면 hasSdfalse로, 아니면 true로 한다.
  18. mnfdmxfdundefined이면 hasFdfalse로, 아니면 true로 한다.
  19. needSdtrue로 한다.
  20. needFdtrue로 한다.
  21. roundingPriority"auto"이면,
  22. needSdhasSd로 설정한다.
  23. needSdtrue이거나, hasFdfalse이고 notation"compact"이면,
  24. needFdfalse로 설정한다.
  25. needSdtrue이면,
  26. hasSdtrue이면,
  27. intlObj.[[MinimumSignificantDigits]]를 ? DefaultNumberOption(mnsd, 1, 21, 1)로 설정한다.
  28. intlObj.[[MaximumSignificantDigits]]를 ? DefaultNumberOption(mxsd, intlObj.[[MinimumSignificantDigits]], 21, 21)로 설정한다.
  29. 아니면,
  30. intlObj.[[MinimumSignificantDigits]]를 1로 설정한다.
  31. intlObj.[[MaximumSignificantDigits]]를 21로 설정한다.
  32. needFdtrue이면,
  33. hasFdtrue이면,
  34. mnfd를 ? DefaultNumberOption(mnfd, 0, 100, undefined)로 설정한다.
  35. mxfd를 ? DefaultNumberOption(mxfd, 0, 100, undefined)로 설정한다.
  36. mnfdundefined이면, mnfdmin(mnfdDefault, mxfd)로 설정한다.
  37. 아니면 mxfdundefined이면, mxfdmax(mxfdDefault, mnfd)로 설정한다.
  38. 아니면 mnfdmxfd보다 크면, RangeError 예외를 throw한다.
  39. intlObj.[[MinimumFractionDigits]]mnfd로 설정한다.
  40. intlObj.[[MaximumFractionDigits]]mxfd로 설정한다.
  41. 아니면,
  42. intlObj.[[MinimumFractionDigits]]mnfdDefault로 설정한다.
  43. intlObj.[[MaximumFractionDigits]]mxfdDefault로 설정한다.
  44. needSdneedFd가 모두 false이면,
  45. intlObj.[[MinimumFractionDigits]]를 0으로 설정한다.
  46. intlObj.[[MaximumFractionDigits]]를 0으로 설정한다.
  47. intlObj.[[MinimumSignificantDigits]]를 1로 설정한다.
  48. intlObj.[[MaximumSignificantDigits]]를 2로 설정한다.
  49. intlObj.[[RoundingType]]more-precision으로 설정한다.
  50. intlObj.[[ComputedRoundingPriority]]"morePrecision"으로 설정한다.
  51. 아니면 roundingPriority"morePrecision"이면,
  52. intlObj.[[RoundingType]]more-precision으로 설정한다.
  53. intlObj.[[ComputedRoundingPriority]]"morePrecision"으로 설정한다.
  54. 아니면 roundingPriority"lessPrecision"이면,
  55. intlObj.[[RoundingType]]less-precision으로 설정한다.
  56. intlObj.[[ComputedRoundingPriority]]"lessPrecision"으로 설정한다.
  57. 아니면 hasSdtrue이면,
  58. intlObj.[[RoundingType]]significant-digits로 설정한다.
  59. intlObj.[[ComputedRoundingPriority]]"auto"로 설정한다.
  60. 아니면,
  61. intlObj.[[RoundingType]]fraction-digits로 설정한다.
  62. intlObj.[[ComputedRoundingPriority]]"auto"로 설정한다.
  63. roundingIncrement가 1이 아니면,
  64. intlObj.[[RoundingType]]fraction-digits가 아니면, TypeError 예외를 throw한다.
  65. intlObj.[[MaximumFractionDigits]]intlObj.[[MinimumFractionDigits]]와 다르면, RangeError 예외를 throw한다.
  66. unused를 반환한다.

16.1.3 SetNumberFormatUnitOptions ( intlObj, options )

The abstract operation SetNumberFormatUnitOptions takes arguments intlObj (Intl.NumberFormat) and options (객체) and returns 정상 완료 시 unused 또는 throw 완료. It performs the following steps when called:

  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이면,
  5. style"currency"이면, TypeError 예외를 throw한다.
  6. 아니면,
  7. IsWellFormedCurrencyCode(currency)가 false이면, RangeError 예외를 throw한다.
  8. currencyDisplay를 ? GetOption(options, "currencyDisplay", string, « "code", "symbol", "narrowSymbol", "name" », "symbol")로 한다.
  9. currencySign을 ? GetOption(options, "currencySign", string, « "standard", "accounting" », "standard")로 한다.
  10. unit을 ? GetOption(options, "unit", string, empty, undefined)로 한다.
  11. unitundefined이면,
  12. style"unit"이면, TypeError 예외를 throw한다.
  13. 아니면,
  14. IsWellFormedUnitIdentifier(unit)가 false이면, RangeError 예외를 throw한다.
  15. unitDisplay를 ? GetOption(options, "unitDisplay", string, « "short", "narrow", "long" », "short")로 한다.
  16. style"currency"이면,
  17. intlObj.[[Currency]]currency의 ASCII 대문자로 설정한다.
  18. intlObj.[[CurrencyDisplay]]currencyDisplay로 설정한다.
  19. intlObj.[[CurrencySign]]currencySign으로 설정한다.
  20. style"unit"이면,
  21. intlObj.[[Unit]]unit으로 설정한다.
  22. intlObj.[[UnitDisplay]]unitDisplay로 설정한다.
  23. unused를 반환한다.

16.2 Intl.NumberFormat 생성자의 속성

Intl.NumberFormat 생성자:

16.2.1 Intl.NumberFormat.prototype

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

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

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

supportedLocalesOf 메서드가 인자 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는 숫자 포매팅에 관련된 세 가지 로케일 확장 키를 설명한다: "cu"는 통화, "cf"는 통화 포맷 스타일, "nu"는 숫자 시스템. 그러나 Intl.NumberFormat은 통화 포맷의 통화는 옵션 객체의 currency 속성으로, 통화 포맷 스타일은 currencySign 속성으로 지정해야 한다.

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

  • 어떤 로케일 필드의 "nu" 필드 값이 « "native", "traditio", "finance" » 값을 포함해서는 안 된다.
  • [[LocaleData]].[[<locale>]]는 모든 로케일 값 locale에 대해 [[patterns]] 필드를 가져야 한다. 이 필드의 값은 Record이며, 네 가지 숫자 포맷 스타일 이름: "decimal", "percent", "currency", "unit"을 필드로 가져야 한다.
  • 위에서 언급한 "currency""unit" 필드는 최소 하나의 필드 "fallback"을 가진 Record여야 한다. "currency"6.3에 따라 통화 코드 키를 추가로 가질 수 있다. 각 "currency" 필드는 "code", "symbol", "narrowSymbol", "name"의 currencyDisplay 값에 해당하는 필드를 가진 Record여야 한다. 각 필드는 "standard" 또는 "accounting"의 currencySign 값에 해당하는 필드를 가진 Record여야 한다. "unit" 필드는 6.6에 따라 코어 측정 단위 식별자 키를 추가로 가질 수 있다. 각 "unit" 필드는 "narrow", "short", "long"의 unitDisplay 값에 해당하는 필드를 가진 Record여야 한다.
  • 지금까지 설명된 패턴 트리의 리프 필드("decimal", "percent", "currency"의 증손자, "unit"의 손자)는 "positivePattern", "zeroPattern", "negativePattern" 키를 가진 Record여야 한다.
  • 위 필드의 값(부호 의존 패턴 필드)은 반드시 "{number}" 서브스트링을 포함해야 한다. "positivePattern""{plusSign}"을 포함하고 "{minusSign}"은 포함하지 않아야 한다; "negativePattern""{minusSign}"을 포함하고 "{plusSign}"은 포함하지 않아야 한다; "zeroPattern""{plusSign}"이나 "{minusSign}"을 포함하지 않아야 한다. 또한 "percent" 필드 내 값은 "{percentSign}"을 포함해야 하며, "currency" 필드 내 값은 "{currencyCode}", "{currencyPrefix}", "{currencySuffix}" 중 하나 이상을 포함해야 하며, "unit" 필드 내 값은 "{unitPrefix}" 또는 "{unitSuffix}" 중 하나 이상을 포함해야 한다. 패턴 문자열은 ECMA-262의 UTF-16 인코딩 코드 포인트 시퀀스로 해석할 때, Unicode Standard의 General Category "Number, decimal digit" 코드 포인트를 포함해서는 안 된다.
  • [[LocaleData]].[[<locale>]]는 모든 로케일 값 locale에 대해 [[notationSubPatterns]] 필드를 가져야 한다. 이 필드의 값은 Record이며, [[scientific]][[compact]] 두 필드를 가져야 한다. [[scientific]] 필드는 "{number}", "{scientificSeparator}", "{scientificExponent}" 서브스트링을 포함하는 문자열이어야 한다. [[compact]] 필드는 "short""long" 두 필드를 가진 Record여야 한다. 각 필드는 구현이 지원하는 모든 compact notation의 discrete magnitude에 해당하는 정수 키를 가진 Record여야 한다. 각 필드는 "{number}" 서브스트링을 포함할 수 있다. "short"에서 내려온 문자열은 "{compactSymbol}"을, "long"에서 내려온 문자열은 "{compactName}"을 포함해야 한다.
Note 2
구현은 https://cldr.unicode.org/에서 제공되는 Common Locale Data Repository의 로케일 데이터를 사용하는 것이 권장된다.

16.3 Intl.NumberFormat 프로토타입 객체의 속성

Intl.NumberFormat 프로토타입 객체:

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

16.3.1 Intl.NumberFormat.prototype.constructor

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

16.3.2 Intl.NumberFormat.prototype.resolvedOptions ( )

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

  1. nfthis 값으로 한다.
  2. 구현이 4.3 Note 1의 규범적 선택적 생성자 모드를 지원한다면,
  3. nf를 ? UnwrapNumberFormat(nf)로 설정한다.
  4. RequireInternalSlot(nf, [[InitializedNumberFormat]])를 수행한다.
  5. optionsOrdinaryObjectCreate(%Object.prototype%)로 한다.
  6. Table 28의 각 행(헤더 행 제외)을 테이블 순서대로 반복한다:
  7. 현재 행의 Property 값을 p로 한다.
  8. 현재 행의 Internal Slot 이름에 해당하는 nf의 내부 슬롯 값을 v로 한다.
  9. vundefined가 아니면,
  10. 현재 행에 Conversion 값이 있으면,
  11. 현재 행의 Conversion 값이 number임을 단언한다.
  12. v𝔽(v)로 설정한다.
  13. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  14. 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 접근자 함수는 undefined이다. get 접근자 함수는 다음 단계를 수행한다:

  1. nfthis 값으로 한다.
  2. 구현이 4.3 Note 1의 규범적 선택적 생성자 모드를 지원한다면,
  3. nf를 ? UnwrapNumberFormat(nf)로 설정한다.
  4. RequireInternalSlot(nf, [[InitializedNumberFormat]])를 수행한다.
  5. nf.[[BoundFormat]]undefined이면,
  6. F를 Number Format Functions (16.5.2)에 정의된 새로운 내장 함수 객체로 한다.
  7. F.[[NumberFormat]]nf로 설정한다.
  8. nf.[[BoundFormat]]F로 설정한다.
  9. nf.[[BoundFormat]]를 반환한다.
Note
반환된 함수는 nf에 바인딩되어 있으므로 Array.prototype.map이나 다른 함수에 직접 전달할 수 있다. 이는 더 이상 새로운 기능에 적용되지 않는 관습의 역사적 유물로 간주되지만, 기존 프로그램과의 호환성을 유지하기 위해 보존된다.

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

formatRange 메서드가 인자 startend와 함께 호출될 때, 다음 단계가 수행된다:

  1. nfthis 값으로 한다.
  2. RequireInternalSlot(nf, [[InitializedNumberFormat]])를 수행한다.
  3. startundefined이거나 endundefined이면, TypeError 예외를 throw한다.
  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 예외를 throw한다.
  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% 프로퍼티의 초기값은 문자열 값 "Intl.NumberFormat"이다.

이 프로퍼티의 특성은 { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }이다.

16.4 Intl.NumberFormat 인스턴스의 속성

Intl.NumberFormat 인스턴스는 %Intl.NumberFormat.prototype%에서 프로퍼티를 상속받는 일반 객체이다.

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

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

  • [[Locale]]는 포매팅에 사용되는 로케일의 언어 태그를 가진 문자열 값이다.
  • [[LocaleData]]는 포매팅에 대해 구현이 사용할 수 있는 데이터를 나타내는 Record이다. 이는 [[Locale]] 값 또는 그 접두사에 연결된 %Intl.NumberFormat%.[[LocaleData]]의 엔트리 값이다.
  • [[NumberingSystem]]은 포매팅에 사용되는 Unicode Number System Identifier를 나타내는 문자열 값이다.
  • [[Style]]"decimal", "currency", "percent", "unit" 중 하나의 문자열 값으로, 측정되는 수량의 유형을 식별한다.
  • [[Currency]]"currency" 단위 유형으로 포매팅할 때 사용할 통화를 식별하는 통화 코드 문자열 값이다. [[Style]]"currency"일 때만 사용된다.
  • [[CurrencyDisplay]]"code", "symbol", "narrowSymbol", "name" 중 하나의 문자열 값으로, "currency" 스타일로 포매팅할 때 통화를 ISO 4217 알파벳 통화 코드, 로컬라이즈된 통화 기호, 또는 로컬라이즈된 통화 이름으로 표시할지 지정한다. [[Style]]"currency"일 때만 사용된다.
  • [[CurrencySign]]"standard" 또는 "accounting" 중 하나의 문자열 값으로, 음수 숫자를 회계 포맷(종종 괄호로 표시)으로 렌더링할지 지정한다. [[Style]]"currency"이고 [[SignDisplay]]"never"가 아닐 때만 사용된다.
  • [[Unit]]코어 단위 식별자이다. [[Style]]"unit"일 때만 사용된다.
  • [[UnitDisplay]]"short", "narrow", "long" 중 하나의 문자열 값으로, "unit" 스타일로 포매팅할 때 단위를 기호, 좁은 기호, 또는 로컬라이즈된 긴 이름으로 표시할지 지정한다. [[Style]]"unit"일 때만 사용된다.
  • [[MinimumIntegerDigits]]는 사용할 최소 정수 자릿수를 나타내는 0 이상의 정수이다. 필요하면 숫자는 앞에 0을 추가하여 패딩된다.
  • [[MinimumFractionDigits]][[MaximumFractionDigits]]는 사용할 최소 및 최대 소수 자릿수를 나타내는 0 이상의 정수이다. 필요하면 숫자는 반올림되거나 뒤에 0을 추가하여 패딩된다. 이 속성들은 [[RoundingType]]fraction-digits, more-precision, less-precision일 때만 사용된다.
  • [[MinimumSignificantDigits]][[MaximumSignificantDigits]]는 표시할 최소 및 최대 유효 자릿수를 나타내는 1 이상의 정수이다. 만약 존재한다면, 포매터는 지정된 유효 자릿수를 표시하기 위해 필요한 만큼 소수 자릿수를 사용한다. 이 속성들은 [[RoundingType]]significant-digits, more-precision, less-precision일 때만 사용된다.
  • [[UseGrouping]]은 그룹 구분자를 사용할 조건을 나타내는 Boolean 또는 문자열 값이다. 그룹 구분자의 위치와 표시 여부는 구현 정의이다. "always" 값은 가능하다면 그룹 구분자를 표시하도록 구현에 힌트를 준다; "min2"는 그룹에 최소 2자리 숫자가 있을 때; "auto"는 로케일이 포매팅된 숫자에 그룹 구분자를 선호할 때. false 값은 그룹 구분자를 비활성화한다.
  • [[RoundingType]]fraction-digits, significant-digits, more-precision, less-precision 중 하나의 값으로, 어떤 반올림 전략을 사용할지 나타낸다. fraction-digits이면, 포매팅된 숫자는 [[MinimumFractionDigits]][[MaximumFractionDigits]]에 따라 반올림된다. significant-digits이면, 포매팅된 숫자는 [[MinimumSignificantDigits]][[MaximumSignificantDigits]]에 따라 반올림된다. more-precision 또는 less-precision이면, 네 가지 설정 모두 사용되며, 어느 것을 사용할지 구분하는 특정 규칙이 있다. [[RoundingType]]"roundingPriority" 옵션에서 파생된다.
  • [[ComputedRoundingPriority]]"auto", "morePrecision", "lessPrecision" 중 하나의 문자열 값이다. 이는 16.3.2에서 [[RoundingType]]를 유효한 "roundingPriority" 옵션으로 다시 변환할 때만 사용된다.
  • [[Notation]]"standard", "scientific", "engineering", "compact" 중 하나의 문자열 값으로, 포매팅된 숫자를 스케일 없이 표시할지, 과학적 표기법의 10의 거듭제곱으로 스케일할지, 엔지니어링 표기법의 가장 가까운 천 단위로 스케일할지, 또는 로케일의 compact decimal notation power of ten으로 스케일할지 지정한다.
  • [[CompactDisplay]]"short" 또는 "long" 중 하나의 문자열 값으로, "compact" 표기법으로 포매팅할 때 compact notation 접미사를 짧은 형태("5K") 또는 긴 형태("5 thousand")로 표시할지 지정한다. [[Notation]]"compact"일 때만 사용된다.
  • [[SignDisplay]]"auto", "always", "never", "exceptZero", "negative" 중 하나의 문자열 값으로, 언제 부호를 포함할지 지정한다(비 "auto" 옵션은 각각 항상, 절대 포함하지 않음, 0이 아닌 숫자에만, 또는 0이 아닌 음수에만 포함). 과학적 표기법에서는 이 슬롯이 가수의 부호 표시에는 영향을 주지만 지수에는 영향을 주지 않는다.
  • [[RoundingIncrement]]는 10, 100, 1000, 10000을 10분의 1, 5분의 1, 4분의 1, 2분의 1로 정확히 나누는 정수이다. 이는 계산된 반올림 크기와 관련하여 반올림이 이루어질 증가값을 나타낸다. 예를 들어, [[MaximumFractionDigits]]가 2이고 [[RoundingIncrement]]가 5이면, 포매팅된 숫자는 가장 가까운 0.05("nickel rounding")로 반올림된다.
  • [[RoundingMode]]반올림 모드이며, Table 29의 Identifier 열에 있는 문자열 값 중 하나이다.
  • [[TrailingZeroDisplay]]"auto" 또는 "stripIfInteger" 중 하나의 문자열 값으로, 포매팅된 숫자가 정수(즉, 0이 아닌 소수 자릿수가 없는 경우)일 때 뒤의 0을 제거할지 지정한다.
Table 29: Intl.NumberFormat의 반올림 모드
식별자 설명 예시: 0 소수 자릿수로 반올림
-1.5 0.4 0.5 0.6 1.5
"ceil" 양의 무한대로 ⬆️ [-1] ⬆️ [1] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"floor" 음의 무한대로 ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬇️ [0] ⬇️ [1]
"expand" 0에서 멀어지게 ⬇️ [-2] ⬆️ [1] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"trunc" 0으로 가까워지게 ⬆️ [-1] ⬇️ [0] ⬇️ [0] ⬇️ [0] ⬇️ [1]
"halfCeil" 동점은 양의 무한대로 ⬆️ [-1] ⬇️ [0] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"halfFloor" 동점은 음의 무한대로 ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬇️ [1]
"halfExpand" 동점은 0에서 멀어지게 ⬇️ [-2] ⬇️ [0] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"halfTrunc" 동점은 0으로 가까워지게 ⬆️ [-1] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬇️ [1]
"halfEven" 동점은 짝수 반올림 증가값 배수로 ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬆️ [1] ⬆️ [2]
Note
예시는 각 옵션의 고유한 동작을 보여줍니다. ⬆️는 "양의 무한대로 해결됨"을, ⬇️는 "음의 무한대로 해결됨"을 의미합니다.

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

16.5 NumberFormat 객체의 추상 연산

16.5.1 CurrencyDigits ( currency )

The implementation-defined abstract operation CurrencyDigits takes argument currency (문자열) and returns 0 이상의 정수. It performs the following steps when called:

  1. Assert: IsWellFormedCurrencyCode(currency)가 true임을 단언한다.
  2. currency에 해당하는 통화의 수량을 포매팅할 때 사용할 소수 자릿수의 개수를 나타내는 0 이상의 정수를 반환한다. 사용할 자릿수에 대한 정보가 없으면 2를 반환한다.

16.5.2 숫자 포매팅 함수

숫자 포매팅 함수는 [[NumberFormat]] 내부 슬롯을 가진 익명 내장 함수이다.

숫자 포매팅 함수 F가 선택적 인자 value와 함께 호출될 때, 다음 단계가 수행된다:

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

숫자 포매팅 함수의 "length" 프로퍼티 값은 1𝔽이다.

16.5.3 FormatNumericToString ( intlObject, x )

The abstract operation FormatNumericToString takes arguments intlObject (객체) and x (수학적 값 또는 negative-zero) and returns [[RoundedNumber]](수학적 값 또는 negative-zero), [[FormattedString]](문자열) 필드를 가진 Record. It performs the following steps when called:

  1. Assert: intlObject[[RoundingMode]], [[RoundingType]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[RoundingIncrement]], [[TrailingZeroDisplay]] 내부 슬롯을 가진다.
  2. xnegative-zero이면,
  3. signnegative로 한다.
  4. x를 0으로 설정한다.
  5. 아니면,
  6. Assert: x는 수학적 값이다.
  7. x < 0이면 signnegative로, 아니면 positive로 한다.
  8. signnegative이면,
  9. x를 -x로 설정한다.
  10. unsignedRoundingModeGetUnsignedRoundingMode(intlObject.[[RoundingMode]], sign)로 한다.
  11. intlObject.[[RoundingType]]significant-digits이면,
  12. result를 ToRawPrecision(x, intlObject.[[MinimumSignificantDigits]], intlObject.[[MaximumSignificantDigits]], unsignedRoundingMode)로 한다.
  13. 아니면 intlObject.[[RoundingType]]fraction-digits이면,
  14. result를 ToRawFixed(x, intlObject.[[MinimumFractionDigits]], intlObject.[[MaximumFractionDigits]], intlObject.[[RoundingIncrement]], unsignedRoundingMode)로 한다.
  15. 아니면,
  16. sResult를 ToRawPrecision(x, intlObject.[[MinimumSignificantDigits]], intlObject.[[MaximumSignificantDigits]], unsignedRoundingMode)로 한다.
  17. fResult를 ToRawFixed(x, intlObject.[[MinimumFractionDigits]], intlObject.[[MaximumFractionDigits]], intlObject.[[RoundingIncrement]], unsignedRoundingMode)로 한다.
  18. fResult.[[RoundingMagnitude]] < sResult.[[RoundingMagnitude]]이면 fixedIsMorePrecisetrue로, 아니면 false로 한다.
  19. intlObject.[[RoundingType]]more-precision이고 fixedIsMorePrecisetrue이면,
  20. resultfResult로 한다.
  21. 아니면 intlObject.[[RoundingType]]less-precision이고 fixedIsMorePrecisefalse이면,
  22. resultfResult로 한다.
  23. 아니면,
  24. resultsResult로 한다.
  25. xresult.[[RoundedNumber]]로 설정한다.
  26. stringresult.[[FormattedString]]로 한다.
  27. intlObject.[[TrailingZeroDisplay]]"stripIfInteger"이고 x modulo 1 = 0이면,
  28. iStringIndexOf(string, ".", 0)로 한다.
  29. inot-found가 아니면, string을 0부터 i까지의 부분 문자열로 설정한다.
  30. intresult.[[IntegerDigitsCount]]로 한다.
  31. minIntegerintlObject.[[MinimumIntegerDigits]]로 한다.
  32. int < minInteger이면,
  33. forwardZeros를 0x0030(DIGIT ZERO) 코드 유닛을 minInteger - int번 반복한 문자열로 한다.
  34. stringforwardZerosstring을 연결한 문자열로 설정한다.
  35. signnegative이면,
  36. x가 0이면 xnegative-zero로, 아니면 x를 -x로 설정한다.
  37. Record { [[RoundedNumber]]: x, [[FormattedString]]: string }를 반환한다.

16.5.4 PartitionNumberPattern ( numberFormat, x )

The abstract operation PartitionNumberPattern takes arguments numberFormat (NumberFormat으로 초기화된 객체) and x (Intl 수학적 값) and returns [[Type]](문자열), [[Value]](문자열) 필드를 가진 Record의 리스트. It performs the following steps when called:

  1. exponent를 0으로 한다.
  2. xnot-a-number이면,
  3. nILD 문자열 값으로 NaN을 나타내는 값으로 한다.
  4. 아니면 xpositive-infinity이면,
  5. nILD 문자열 값으로 양의 무한대를 나타내는 값으로 한다.
  6. 아니면 xnegative-infinity이면,
  7. nILD 문자열 값으로 음의 무한대를 나타내는 값으로 한다.
  8. 아니면,
  9. xnegative-zero가 아니면,
  10. Assert: x는 수학적 값이다.
  11. numberFormat.[[Style]]"percent"이면 x를 100 × x로 한다.
  12. exponentComputeExponent(numberFormat, x)로 한다.
  13. xx × 10-exponent로 한다.
  14. formatNumberResultFormatNumericToString(numberFormat, x)로 한다.
  15. nformatNumberResult.[[FormattedString]]로 한다.
  16. xformatNumberResult.[[RoundedNumber]]로 한다.
  17. patternGetNumberFormatPattern(numberFormat, x)로 한다.
  18. result를 새로운 빈 리스트로 한다.
  19. patternPartsPartitionPattern(pattern)로 한다.
  20. patternPart에 대해 { [[Type]], [[Value]] } 형태로 반복한다:
  21. ppatternPart.[[Type]]로 한다.
  22. p"literal"이면,
  23. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }를 result에 추가한다.
  24. 아니면 p"number"이면,
  25. notationSubPartsPartitionNotationSubPattern(numberFormat, x, n, exponent)로 한다.
  26. resultresultnotationSubParts를 연결한 리스트로 설정한다.
  27. 아니면 p"plusSign"이면,
  28. plusSignSymbolILND 문자열로 플러스 기호를 나타내는 값으로 한다.
  29. Record { [[Type]]: "plusSign", [[Value]]: plusSignSymbol }를 result에 추가한다.
  30. 아니면 p"minusSign"이면,
  31. minusSignSymbolILND 문자열로 마이너스 기호를 나타내는 값으로 한다.
  32. Record { [[Type]]: "minusSign", [[Value]]: minusSignSymbol }를 result에 추가한다.
  33. 아니면 p"percentSign"이고 numberFormat.[[Style]]"percent"이면,
  34. percentSignSymbolILND 문자열로 퍼센트 기호를 나타내는 값으로 한다.
  35. Record { [[Type]]: "percentSign", [[Value]]: percentSignSymbol }를 result에 추가한다.
  36. 아니면 p"unitPrefix"이고 numberFormat.[[Style]]"unit"이면,
  37. unitnumberFormat.[[Unit]]로 한다.
  38. unitDisplaynumberFormat.[[UnitDisplay]]로 한다.
  39. muunitunitDisplay 형태로 x 앞에 나타내는 ILD 문자열 값으로 한다(언어별 복수형에 따라 달라질 수 있음).
  40. Record { [[Type]]: "unit", [[Value]]: mu }를 result에 추가한다.
  41. 아니면 p"unitSuffix"이고 numberFormat.[[Style]]"unit"이면,
  42. unitnumberFormat.[[Unit]]로 한다.
  43. unitDisplaynumberFormat.[[UnitDisplay]]로 한다.
  44. muunitunitDisplay 형태로 x 뒤에 나타내는 ILD 문자열 값으로 한다(언어별 복수형에 따라 달라질 수 있음).
  45. Record { [[Type]]: "unit", [[Value]]: mu }를 result에 추가한다.
  46. 아니면 p"currencyCode"이고 numberFormat.[[Style]]"currency"이면,
  47. currencynumberFormat.[[Currency]]로 한다.
  48. cdcurrency로 한다.
  49. Record { [[Type]]: "currency", [[Value]]: cd }를 result에 추가한다.
  50. 아니면 p"currencyPrefix"이고 numberFormat.[[Style]]"currency"이면,
  51. currencynumberFormat.[[Currency]]로 한다.
  52. currencyDisplaynumberFormat.[[CurrencyDisplay]]로 한다.
  53. cdcurrencycurrencyDisplay 형태로 x 앞에 나타내는 ILD 문자열 값으로 한다(언어별 복수형에 따라 달라질 수 있음).
  54. Record { [[Type]]: "currency", [[Value]]: cd }를 result에 추가한다.
  55. 아니면 p"currencySuffix"이고 numberFormat.[[Style]]"currency"이면,
  56. currencynumberFormat.[[Currency]]로 한다.
  57. currencyDisplaynumberFormat.[[CurrencyDisplay]]로 한다.
  58. cdcurrencycurrencyDisplay 형태로 x 뒤에 나타내는 ILD 문자열 값으로 한다(구현에 해당 표현이 없으면 currency 자체를 사용).
  59. Record { [[Type]]: "currency", [[Value]]: cd }를 result에 추가한다.
  60. 아니면,
  61. unknownxp에 기반한 ILND 문자열로 한다.
  62. Record { [[Type]]: "unknown", [[Value]]: unknown }를 result에 추가한다.
  63. result를 반환한다.

16.5.5 PartitionNotationSubPattern ( numberFormat, x, n, exponent )

The abstract operation PartitionNotationSubPattern takes arguments numberFormat (Intl.NumberFormat), x (Intl 수학적 값), n (문자열), and exponent (정수) and returns [[Type]](문자열), [[Value]](문자열) 필드를 가진 Record의 리스트. It performs the following steps when called:

  1. result를 새로운 빈 리스트로 한다.
  2. xnot-a-number이면,
  3. Record { [[Type]]: "nan", [[Value]]: n }를 result에 추가한다.
  4. 아니면 xpositive-infinity 또는 negative-infinity이면,
  5. Record { [[Type]]: "infinity", [[Value]]: n }를 result에 추가한다.
  6. 아니면,
  7. notationSubPatternGetNotationSubPattern(numberFormat, exponent)로 한다.
  8. patternPartsPartitionPattern(notationSubPattern)로 한다.
  9. patternPart에 대해 { [[Type]], [[Value]] } 형태로 반복한다:
  10. ppatternPart.[[Type]]로 한다.
  11. p"literal"이면,
  12. Record { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }를 result에 추가한다.
  13. 아니면 p"number"이면,
  14. numberFormat.[[NumberingSystem]]이 아래 Table 30의 Numbering System 열 값 중 하나와 일치하면,
  15. digits를 일치하는 행의 Digits 열에 명시된 코드 포인트 리스트로 한다.
  16. Assert: digits의 길이는 10이다.
  17. transliterated를 빈 문자열로 한다.
  18. lenn의 길이로 한다.
  19. position을 0으로 한다.
  20. position < len 동안 반복한다:
  21. cnposition 인덱스의 코드 유닛으로 한다.
  22. 0x0030 ≤ c ≤ 0x0039이면,
  23. NOTE: c는 ASCII 숫자이다.
  24. ic - 0x0030으로 한다.
  25. cCodePointsToStringdigits[i] »)로 한다.
  26. transliteratedtransliteratedc를 연결한 문자열로 한다.
  27. positionposition + 1로 한다.
  28. ntransliterated로 한다.
  29. 아니면,
  30. 구현에 따라 n을 해당 숫자 시스템에 맞는 표현으로 변환한다.
  31. decimalSepIndexStringIndexOf(n, ".", 0)로 한다.
  32. decimalSepIndexnot-found가 아니고 decimalSepIndex > 0이면,
  33. integern의 0부터 decimalSepIndex까지 부분 문자열로 한다.
  34. fractionndecimalSepIndex + 1부터 끝까지 부분 문자열로 한다.
  35. 아니면,
  36. integern으로 한다.
  37. fractionundefined로 한다.
  38. numberFormat.[[UseGrouping]]false이면,
  39. Record { [[Type]]: "integer", [[Value]]: integer }를 result에 추가한다.
  40. 아니면,
  41. groupSepSymbolILND 문자열로 그룹 구분자를 나타내는 값으로 한다.
  42. groupsinteger 내에서 ILND 위치 집합에 따라 왼쪽에서 오른쪽 순서로 분할된 부분 문자열 리스트로 한다(numberFormat.[[UseGrouping]] 값에 따라 달라질 수 있음).
  43. Assert: groups 리스트의 요소 개수는 0보다 크다.
  44. groups 리스트가 비어있지 않은 동안 반복한다:
  45. 첫 번째 요소를 제거하고 integerGroup을 그 값으로 한다.
  46. Record { [[Type]]: "integer", [[Value]]: integerGroup }를 result에 추가한다.
  47. groups 리스트가 비어있지 않으면,
  48. Record { [[Type]]: "group", [[Value]]: groupSepSymbol }를 result에 추가한다.
  49. fractionundefined가 아니면,
  50. decimalSepSymbolILND 문자열로 소수 구분자를 나타내는 값으로 한다.
  51. Record { [[Type]]: "decimal", [[Value]]: decimalSepSymbol }를 result에 추가한다.
  52. Record { [[Type]]: "fraction", [[Value]]: fraction }를 result에 추가한다.
  53. 아니면 p"compactSymbol"이면,
  54. compactSymbolexponent를 단축 형태로 나타내는 ILD 문자열로 한다(언어별 복수형에 따라 달라질 수 있음). 구현은 이 문자열을 제공할 수 있어야 하며, 그렇지 않으면 패턴에 "{compactSymbol}" 플레이스홀더가 없을 것이다.
  55. Record { [[Type]]: "compact", [[Value]]: compactSymbol }를 result에 추가한다.
  56. 아니면 p"compactName"이면,
  57. compactNameexponent를 긴 형태로 나타내는 ILD 문자열로 한다(언어별 복수형에 따라 달라질 수 있음). 구현은 이 문자열을 제공할 수 있어야 하며, 그렇지 않으면 패턴에 "{compactName}" 플레이스홀더가 없을 것이다.
  58. Record { [[Type]]: "compact", [[Value]]: compactName }를 result에 추가한다.
  59. 아니면 p"scientificSeparator"이면,
  60. scientificSeparatorILND 문자열로 지수 구분자를 나타내는 값으로 한다.
  61. Record { [[Type]]: "exponentSeparator", [[Value]]: scientificSeparator }를 result에 추가한다.
  62. 아니면 p"scientificExponent"이면,
  63. exponent < 0이면,
  64. minusSignSymbolILND 문자열로 마이너스 기호를 나타내는 값으로 한다.
  65. Record { [[Type]]: "exponentMinusSign", [[Value]]: minusSignSymbol }를 result에 추가한다.
  66. exponent를 -exponent로 한다.
  67. exponentResult를 ToRawFixed(exponent, 0, 0, 1, undefined)로 한다.
  68. Record { [[Type]]: "exponentInteger", [[Value]]: exponentResult.[[FormattedString]] }를 result에 추가한다.
  69. 아니면,
  70. unknownxp에 기반한 ILND 문자열로 한다.
  71. Record { [[Type]]: "unknown", [[Value]]: unknown }를 result에 추가한다.
  72. result를 반환한다.
Table 30: 간단한 숫자 매핑을 가진 숫자 시스템
숫자 시스템 숫자
adlm U+1E950 ~ U+1E959
ahom U+11730 ~ U+11739
arab U+0660 ~ U+0669
arabext U+06F0 ~ U+06F9
bali U+1B50 ~ U+1B59
beng U+09E6 ~ U+09EF
bhks U+11C50 ~ U+11C59
brah U+11066 ~ U+1106F
cakm U+11136 ~ U+1113F
cham U+AA50 ~ U+AA59
deva U+0966 ~ U+096F
diak U+11950 ~ U+11959
fullwide U+FF10 ~ U+FF19
gara U+10D40 ~ U+10D49
gong U+11DA0 ~ U+11DA9
gonm U+11D50 ~ U+11D59
gujr U+0AE6 ~ U+0AEF
gukh U+16130 ~ U+16139
guru U+0A66 ~ U+0A6F
hanidec U+3007, U+4E00, U+4E8C, U+4E09, U+56DB, U+4E95, U+516D, U+4E03, U+516B, U+4E5D
hmng U+16B50 ~ U+16B59
hmnp U+1E140 ~ U+1E149
java U+A9D0 ~ U+A9D9
kali U+A900 ~ U+A909
kawi U+11F50 ~ U+11F59
khmr U+17E0 ~ U+17E9
knda U+0CE6 ~ U+0CEF
krai U+16D70 ~ U+16D79
lana U+1A80 ~ U+1A89
lanatham U+1A90 ~ U+1A99
laoo U+0ED0 ~ U+0ED9
latn U+0030 ~ U+0039
lepc U+1C40 ~ U+1C49
limb U+1946 ~ U+194F
mathbold U+1D7CE ~ U+1D7D7
mathdbl U+1D7D8 ~ U+1D7E1
mathmono U+1D7F6 ~ U+1D7FF
mathsanb U+1D7EC ~ U+1D7F5
mathsans U+1D7E2 ~ U+1D7EB
mlym U+0D66 ~ U+0D6F
modi U+11650 ~ U+11659
mong U+1810 ~ U+1819
mroo U+16A60 ~ U+16A69
mtei U+ABF0 ~ U+ABF9
mymr U+1040 ~ U+1049
mymrepka U+116DA ~ U+116E3
mymrpao U+116D0 ~ U+116D9
mymrshan U+1090 ~ U+1099
mymrtlng U+A9F0 ~ U+A9F9
nagm U+1E4F0 ~ U+1E4F9
newa U+11450 ~ U+11459
nkoo U+07C0 ~ U+07C9
olck U+1C50 ~ U+1C59
onao U+1E5F1 ~ U+1E5FA
orya U+0B66 ~ U+0B6F
osma U+104A0 ~ U+104A9
outlined U+1CCF0 ~ U+1CCF9
rohg U+10D30 ~ U+10D39
saur U+A8D0 ~ U+A8D9
segment U+1FBF0 ~ U+1FBF9
shrd U+111D0 ~ U+111D9
sind U+112F0 ~ U+112F9
sinh U+0DE6 ~ U+0DEF
sora U+110F0 ~ U+110F9
sund U+1BB0 ~ U+1BB9
sunu U+11BF0 ~ U+11BF9
takr U+116C0 ~ U+116C9
talu U+19D0 ~ U+19D9
tamldec U+0BE6 ~ U+0BEF
telu U+0C66 ~ U+0C6F
thai U+0E50 ~ U+0E59
tibt U+0F20 ~ U+0F29
tirh U+114D0 ~ U+114D9
tnsa U+16AC0 ~ U+16AC9
tols U+11DE0 ~ U+11DE9
vaii U+A620 ~ U+A629
wara U+118E0 ~ U+118E9
wcho U+1E2F0 ~ U+1E2F9
Note 1
계산은 ILDILND 문자열 값과 숫자 문자열 내 위치에 의존하며, 이는 numberFormat의 유효 로케일 또는 유효 로케일과 숫자 시스템에 따라 달라집니다. 통화 이름을 제외한 ILDILND 문자열 값은 Unicode Standard에서 지정한 General Category "Number, decimal digit" 코드 포인트를 포함해서는 안 됩니다.
Note 2
구현에서는 Common Locale Data Repository에서 제공하는 로케일을 사용하는 것이 권장됩니다 (https://cldr.unicode.org/).

16.5.6 FormatNumeric ( numberFormat, x )

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

  1. partsPartitionNumberPattern(numberFormat, x)로 한다.
  2. result를 빈 문자열로 한다.
  3. Record { [[Type]], [[Value]] } part에 대해 반복한다:
  4. resultresultpart.[[Value]]를 연결한 문자열로 설정한다.
  5. result를 반환한다.

16.5.7 FormatNumericToParts ( numberFormat, x )

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

  1. partsPartitionNumberPattern(numberFormat, x)로 한다.
  2. result를 ! ArrayCreate(0)로 한다.
  3. n을 0으로 한다.
  4. Record { [[Type]], [[Value]] } part에 대해 반복한다:
  5. OOrdinaryObjectCreate(%Object.prototype%)로 한다.
  6. CreateDataPropertyOrThrow(O, "type", part.[[Type]])를 수행한다.
  7. CreateDataPropertyOrThrow(O, "value", part.[[Value]])를 수행한다.
  8. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), O)를 수행한다.
  9. n을 1 증가시킨다.
  10. result를 반환한다.

16.5.8 ToRawPrecision ( x: 0 이상의 수학적 값, minPrecision: 1 이상 21 이하의 정수, maxPrecision: 1 이상 21 이하의 정수, unsignedRoundingMode: Table 31의 Unsigned Rounding Mode 열의 명세 타입 또는 undefined, ): [[FormattedString]](문자열), [[RoundedNumber]](수학적 값), [[IntegerDigitsCount]](정수), [[RoundingMagnitude]](정수) 필드를 가진 Record

The abstract operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It performs the following steps when called:

  1. pmaxPrecision으로 한다.
  2. x = 0이면,
  3. m을 코드 유닛 0x0030(DIGIT ZERO) p번 반복한 문자열로 한다.
  4. e를 0으로 한다.
  5. xFinal을 0으로 한다.
  6. 아니면,
  7. n1, e1를 정수로, r1을 수학적 값으로 하여 r1 = ToRawPrecisionFn(n1, e1, p)이고 r1x이며 r1이 최대가 되도록 한다.
  8. n2, e2를 정수로, r2를 수학적 값으로 하여 r2 = ToRawPrecisionFn(n2, e2, p)이고 r2x이며 r2가 최소가 되도록 한다.
  9. xFinal을 ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode)로 한다.
  10. xFinalr1이면,
  11. nn1으로 한다.
  12. ee1으로 한다.
  13. 아니면,
  14. nn2로 한다.
  15. ee2로 한다.
  16. mn의 십진수 표현의 숫자들로 구성된 문자열로 한다(앞의 0 없이, 순서대로).
  17. e ≥ (p - 1)이면,
  18. mme - p + 1번 코드 유닛 0x0030(DIGIT ZERO)을 연결한 문자열로 한다.
  19. inte + 1로 한다.
  20. 아니면 e ≥ 0이면,
  21. m을 처음 e + 1 코드 유닛, 코드 유닛 0x002E(FULL STOP), 그리고 남은 p - (e + 1) 코드 유닛을 연결한 문자열로 한다.
  22. inte + 1로 한다.
  23. 아니면,
  24. Assert: e < 0.
  25. m"0.", -(e + 1)번 코드 유닛 0x0030(DIGIT ZERO), 그리고 m을 연결한 문자열로 한다.
  26. int를 1로 한다.
  27. m이 코드 유닛 0x002E(FULL STOP)를 포함하고 maxPrecision > minPrecision이면,
  28. cutmaxPrecision - minPrecision으로 한다.
  29. cut > 0이고 m의 마지막 코드 유닛이 0x0030(DIGIT ZERO)인 동안 반복한다:
  30. 마지막 코드 유닛을 제거한다.
  31. cutcut - 1로 한다.
  32. m의 마지막 코드 유닛이 0x002E(FULL STOP)이면,
  33. 마지막 코드 유닛을 제거한다.
  34. Record { [[FormattedString]]: m, [[RoundedNumber]]: xFinal, [[IntegerDigitsCount]]: int, [[RoundingMagnitude]]: ep+1 }를 반환한다.

16.5.9 ToRawFixed ( x: 0 이상의 수학적 값, minFraction: 0 이상 100 이하의 정수, maxFraction: 0 이상 100 이하의 정수, roundingIncrement: 정수, unsignedRoundingMode: Table 31의 Unsigned Rounding Mode 열의 명세 타입 또는 undefined, ): [[FormattedString]](문자열), [[RoundedNumber]](수학적 값), [[IntegerDigitsCount]](정수), [[RoundingMagnitude]](정수) 필드를 가진 Record

The abstract operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It performs the following steps when called:

  1. fmaxFraction으로 한다.
  2. n1을 정수로, r1을 수학적 값으로 하여 r1 = ToRawFixedFn(n1, f)이고 n1 modulo roundingIncrement = 0, r1x, 그리고 r1이 최대가 되도록 한다.
  3. n2를 정수로, r2를 수학적 값으로 하여 r2 = ToRawFixedFn(n2, f)이고 n2 modulo roundingIncrement = 0, r2x, 그리고 r2가 최소가 되도록 한다.
  4. xFinal을 ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode)로 한다.
  5. xFinalr1이면 nn1으로, 아니면 nn2로 한다.
  6. n = 0이면 m"0"으로, 아니면 mn의 십진수 표현의 숫자들로 구성된 문자열로 한다(앞의 0 없이, 순서대로).
  7. f ≠ 0이면,
  8. km의 길이로 한다.
  9. kf이면,
  10. zf + 1 - k번 코드 유닛 0x0030(DIGIT ZERO)로 구성된 문자열로 한다.
  11. mzm을 연결한 문자열로 한다.
  12. kf + 1로 한다.
  13. a를 처음 k - f 코드 유닛, b를 남은 f 코드 유닛으로 한다.
  14. ma, ".", b를 연결한 문자열로 한다.
  15. inta의 길이로 한다.
  16. 아니면,
  17. intm의 길이로 한다.
  18. cutmaxFraction - minFraction으로 한다.
  19. cut > 0이고 m의 마지막 코드 유닛이 0x0030(DIGIT ZERO)인 동안 반복한다:
  20. 마지막 코드 유닛을 제거한다.
  21. cutcut - 1로 한다.
  22. m의 마지막 코드 유닛이 0x002E(FULL STOP)이면,
  23. 마지막 코드 유닛을 제거한다.
  24. Record { [[FormattedString]]: m, [[RoundedNumber]]: xFinal, [[IntegerDigitsCount]]: int, [[RoundingMagnitude]]: –f }를 반환한다.

16.5.10 UnwrapNumberFormat ( nf )

The abstract operation UnwrapNumberFormat takes argument nf (ECMAScript 언어 값) and returns 정상 완료 시 ECMAScript 언어 값 또는 throw 완료. It performs the following steps when called:

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

16.5.11 GetNumberFormatPattern ( numberFormat, x )

The abstract operation GetNumberFormatPattern takes arguments numberFormat (Intl.NumberFormat) and x (Intl 수학적 값) and returns 문자열. It performs the following steps when called:

  1. resolvedLocaleDatanumberFormat.[[LocaleData]]로 한다.
  2. patternsresolvedLocaleData.[[patterns]]로 한다.
  3. Assert: patternsRecord이다(16.2.3 참조).
  4. stylenumberFormat.[[Style]]로 한다.
  5. style"percent"이면,
  6. patternspatterns.[[percent]]로 설정한다.
  7. 아니면 style"unit"이면,
  8. unitnumberFormat.[[Unit]]로 한다.
  9. unitDisplaynumberFormat.[[UnitDisplay]]로 한다.
  10. patternspatterns.[[unit]]로 설정한다.
  11. patterns에 [[<unit>]] 필드가 없으면,
  12. unit"fallback"으로 설정한다.
  13. patternspatterns.[[<unit>]]로 설정한다.
  14. patternspatterns.[[<unitDisplay>]]로 설정한다.
  15. 아니면 style"currency"이면,
  16. currencynumberFormat.[[Currency]]로 한다.
  17. currencyDisplaynumberFormat.[[CurrencyDisplay]]로 한다.
  18. currencySignnumberFormat.[[CurrencySign]]으로 한다.
  19. patternspatterns.[[currency]]로 설정한다.
  20. patterns에 [[<currency>]] 필드가 없으면,
  21. currency"fallback"으로 설정한다.
  22. patternspatterns.[[<currency>]]로 설정한다.
  23. patternspatterns.[[<currencyDisplay>]]로 설정한다.
  24. patternspatterns.[[<currencySign>]]로 설정한다.
  25. 아니면,
  26. Assert: style"decimal"임을 단언한다.
  27. patternspatterns.[[decimal]]로 설정한다.
  28. xnegative-infinity이면,
  29. categorynegative-non-zero로 한다.
  30. 아니면 xnegative-zero이면,
  31. categorynegative-zero로 한다.
  32. 아니면 xnot-a-number이면,
  33. categorypositive-zero로 한다.
  34. 아니면 xpositive-infinity이면,
  35. categorypositive-non-zero로 한다.
  36. 아니면,
  37. Assert: x는 수학적 값이다.
  38. x < 0이면,
  39. categorynegative-non-zero로 한다.
  40. 아니면 x > 0이면,
  41. categorypositive-non-zero로 한다.
  42. 아니면,
  43. categorypositive-zero로 한다.
  44. signDisplaynumberFormat.[[SignDisplay]]로 한다.
  45. signDisplay"never"이면,
  46. patternpatterns.[[zeroPattern]]으로 한다.
  47. 아니면 signDisplay"auto"이면,
  48. categorypositive-non-zero 또는 positive-zero이면,
  49. patternpatterns.[[zeroPattern]]으로 한다.
  50. 아니면,
  51. patternpatterns.[[negativePattern]]으로 한다.
  52. 아니면 signDisplay"always"이면,
  53. categorypositive-non-zero 또는 positive-zero이면,
  54. patternpatterns.[[positivePattern]]으로 한다.
  55. 아니면,
  56. patternpatterns.[[negativePattern]]으로 한다.
  57. 아니면 signDisplay"exceptZero"이면,
  58. categorypositive-zero 또는 negative-zero이면,
  59. patternpatterns.[[zeroPattern]]으로 한다.
  60. 아니면 categorypositive-non-zero이면,
  61. patternpatterns.[[positivePattern]]으로 한다.
  62. 아니면,
  63. patternpatterns.[[negativePattern]]으로 한다.
  64. 아니면,
  65. Assert: signDisplay"negative"임을 단언한다.
  66. categorynegative-non-zero이면,
  67. patternpatterns.[[negativePattern]]으로 한다.
  68. 아니면,
  69. patternpatterns.[[zeroPattern]]으로 한다.
  70. pattern을 반환한다.

16.5.12 GetNotationSubPattern ( numberFormat, exponent )

The abstract operation GetNotationSubPattern takes arguments numberFormat (Intl.NumberFormat) and exponent (정수) and returns 문자열. 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" 또는 "engineering"이면,
  6. notationSubPatterns.[[scientific]]을 반환한다.
  7. 아니면 exponent가 0이 아니면,
  8. Assert: notation"compact"임을 단언한다.
  9. compactDisplaynumberFormat.[[CompactDisplay]]로 한다.
  10. compactPatternsnotationSubPatterns.[[compact]].[[<compactDisplay>]]로 한다.
  11. compactPatterns.[[<exponent>]]을 반환한다.
  12. 아니면,
  13. "{number}"를 반환한다.

16.5.13 ComputeExponent ( numberFormat, x )

The abstract operation ComputeExponent takes arguments numberFormat (Intl.NumberFormat) and x (수학적 값) and returns 정수. It performs the following steps when called:

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

16.5.14 ComputeExponentForMagnitude ( numberFormat, magnitude )

The abstract operation ComputeExponentForMagnitude takes arguments numberFormat (Intl.NumberFormat) and magnitude (정수) and returns 정수. It performs the following steps when called:

  1. notationnumberFormat.[[Notation]]으로 한다.
  2. notation"standard"이면,
  3. 0을 반환한다.
  4. 아니면 notation"scientific"이면,
  5. magnitude를 반환한다.
  6. 아니면 notation"engineering"이면,
  7. thousandsmagnitude / 3 이하의 최대 정수로 한다.
  8. thousands × 3을 반환한다.
  9. 아니면,
  10. Assert: notation"compact"임을 단언한다.
  11. exponent를 현재 로케일의 compact 표기법에서 주어진 magnitude에 맞는 ILD 정수로 한다.
  12. 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. StrUnsignedDecimalLiteralStringIntlMVa로 한다.
  2. a가 0이면 negative-zero를 반환한다.
  3. apositive-infinity이면 negative-infinity를 반환한다.
  4. -a를 반환한다.
StrUnsignedDecimalLiteral ::: Infinity
  1. positive-infinity를 반환한다.
StrUnsignedDecimalLiteral ::: DecimalDigits . DecimalDigitsopt ExponentPartopt
  1. 첫 번째 DecimalDigits의 MV를 a로 한다.
  2. 두 번째 DecimalDigits가 있으면,
  3. 두 번째 DecimalDigits의 MV를 b로 한다.
  4. 두 번째 DecimalDigits의 코드 포인트 개수를 n으로 한다.
  5. 아니면,
  6. b를 0으로 한다.
  7. n을 0으로 한다.
  8. ExponentPart가 있으면, MV를 e로 한다. 아니면 e를 0으로 한다.
  9. (a + (b × 10-n)) × 10e를 반환한다.
StrUnsignedDecimalLiteral ::: . DecimalDigits ExponentPartopt
  1. DecimalDigits의 MV를 b로 한다.
  2. ExponentPart가 있으면, MV를 e로 한다. 아니면 e를 0으로 한다.
  3. DecimalDigits의 코드 포인트 개수를 n으로 한다.
  4. b × 10e - n를 반환한다.
StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPartopt
  1. DecimalDigits의 MV를 a로 한다.
  2. ExponentPart가 있으면, MV를 e로 한다. 아니면 e를 0으로 한다.
  3. a × 10e를 반환한다.

16.5.16 ToIntlMathematicalValue ( value )

The abstract operation ToIntlMathematicalValue takes argument value (ECMAScript 언어 값) and returns 정상 완료 시 Intl 수학적 값 또는 throw 완료. It performs the following steps when called:

  1. primValue를 ? ToPrimitive(value, number)로 한다.
  2. primValue가 BigInt이면, (primValue)를 반환한다.
  3. primValue가 String이면,
  4. strprimValue로 한다.
  5. 아니면,
  6. x를 ? ToNumber(primValue)로 한다.
  7. x-0𝔽이면, negative-zero를 반환한다.
  8. strNumber::toString(x, 10)로 한다.
  9. textStringToCodePoints(str)로 한다.
  10. literalParseText(text, StringNumericLiteral)로 한다.
  11. literal이 오류 리스트이면, not-a-number를 반환한다.
  12. intlMVliteralStringIntlMV로 한다.
  13. intlMV가 수학적 값이면,
  14. roundedRoundMVResult(abs(intlMV))로 한다.
  15. rounded+∞𝔽이고 intlMV < 0이면, negative-infinity를 반환한다.
  16. rounded+∞𝔽이면, positive-infinity를 반환한다.
  17. rounded+0𝔽이고 intlMV < 0이면, negative-zero를 반환한다.
  18. rounded+0𝔽이면, 0을 반환한다.
  19. intlMV를 반환한다.

16.5.17 GetUnsignedRoundingMode ( roundingMode, sign )

The abstract operation GetUnsignedRoundingMode takes arguments roundingMode (반올림 모드) and sign (negative 또는 positive) and returns Table 31의 Unsigned Rounding Mode 열의 명세 타입. It performs the following steps when called:

  1. Table 31의 Identifier 열 값이 roundingMode이고 Sign 열 값이 sign인 행의 Unsigned Rounding Mode 열의 명세 타입을 반환한다.
Table 31: 반올림 모드에서 unsigned 반올림 모드로의 변환
식별자 부호 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: Table 31의 Unsigned Rounding Mode 열의 명세 타입 또는 undefined, ): 수학적 값

The abstract operation UNKNOWN takes UNPARSEABLE ARGUMENTS. 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 (NumberFormat으로 초기화된 객체), x (Intl 수학적 값), and y (Intl 수학적 값) and returns 정상 완료 시 Record 리스트([[Type]](문자열), [[Value]](문자열), [[Source]](문자열) 필드) 또는 throw 완료. It performs the following steps when called:

  1. xnot-a-number이거나 ynot-a-number이면, RangeError 예외를 throw한다.
  2. xResultPartitionNumberPattern(numberFormat, x)로 한다.
  3. yResultPartitionNumberPattern(numberFormat, y)로 한다.
  4. FormatNumeric(numberFormat, x)가 FormatNumeric(numberFormat, y)와 같으면,
  5. appxResultFormatApproximately(numberFormat, xResult)로 한다.
  6. appxResult의 요소 r에 대해,
  7. r.[[Source]]"shared"로 설정한다.
  8. appxResult를 반환한다.
  9. result를 새로운 빈 리스트로 한다.
  10. xResult의 각 요소 r에 대해,
  11. Record { [[Type]]: r.[[Type]], [[Value]]: r.[[Value]], [[Source]]: "startRange" }를 result에 추가한다.
  12. rangeSeparator를 두 숫자를 구분하는 ILND 문자열 값으로 한다.
  13. Record { [[Type]]: "literal", [[Value]]: rangeSeparator, [[Source]]: "shared" }를 result에 추가한다.
  14. yResult의 각 요소 r에 대해,
  15. Record { [[Type]]: r.[[Type]], [[Value]]: r.[[Value]], [[Source]]: "endRange" }를 result에 추가한다.
  16. CollapseNumberRange(numberFormat, result)를 반환한다.

16.5.20 FormatApproximately ( numberFormat, result )

The abstract operation FormatApproximately takes arguments numberFormat (NumberFormat으로 초기화된 객체) and result (PartitionNumberPattern에서 설명된 Record 리스트([[Type]](문자열), [[Value]](문자열))) and returns Record 리스트([[Type]](문자열), [[Value]](문자열)). It performs the following steps when called:

  1. approximatelySign을 숫자가 근사값임을 나타내는 ILND 문자열 값으로 한다.
  2. approximatelySign이 비어있지 않으면, ILND 인덱스에 Record { [[Type]]: "approximatelySign", [[Value]]: approximatelySign }를 result에 삽입한다. 예를 들어, 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 (NumberFormat으로 초기화된 객체) and result (PartitionNumberRangePattern에서 생성된 Record 리스트([[Type]](문자열), [[Value]](문자열), [[Source]](문자열))) and returns Record 리스트([[Type]](문자열), [[Value]](문자열), [[Source]](문자열)).

예를 들어, 구현은 범위 구분자 뒤의 통화 기호 Record를 제거하여 "$3–$5""$3–5"로 변환할 수 있다.

구현은 문법적 정확성을 위해 Record[[Value]] 필드를 수정할 수 있다. 예를 들어, "0.5 miles–1 mile""0.5–1 miles"로 변환할 수 있다.

result를 수정하지 않고 그대로 반환하는 것은 CollapseNumberRange의 올바른 구현임이 보장된다.

16.5.22 FormatNumericRange ( numberFormat, x, y )

The abstract operation FormatNumericRange takes arguments numberFormat (NumberFormat으로 초기화된 객체), x (Intl 수학적 값), and y (Intl 수학적 값) and returns 정상 완료 시 문자열 또는 throw 완료. It performs the following steps when called:

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

16.5.23 FormatNumericRangeToParts ( numberFormat, x, y )

The abstract operation FormatNumericRangeToParts takes arguments numberFormat (NumberFormat으로 초기화된 객체), x (Intl 수학적 값), and y (Intl 수학적 값) and returns 정상 완료 시 배열 또는 throw 완료. It performs the following steps when called:

  1. parts를 ? PartitionNumberRangePattern(numberFormat, x, y)로 한다.
  2. result를 ! ArrayCreate(0)로 한다.
  3. n을 0으로 한다.
  4. parts의 요소 part에 대해,
  5. OOrdinaryObjectCreate(%Object.prototype%)로 한다.
  6. CreateDataPropertyOrThrow(O, "type", part.[[Type]])를 수행한다.
  7. CreateDataPropertyOrThrow(O, "value", part.[[Value]])를 수행한다.
  8. CreateDataPropertyOrThrow(O, "source", part.[[Source]])를 수행한다.
  9. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), O)를 수행한다.
  10. n을 1 증가시킨다.
  11. 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. roptionsResolution.[[ResolvedLocale]]로 한다.
  6. pluralRules.[[Locale]]r.[[Locale]]로 설정한다.
  7. t를 ? GetOption(options, "type", string, « "cardinal", "ordinal" », "cardinal")로 한다.
  8. pluralRules.[[Type]]t로 설정한다.
  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"이면,
  13. pluralRules.[[CompactDisplay]]compactDisplay로 설정한다.
  14. SetNumberFormatDigitOptions(pluralRules, options, 0, 3, notation)를 수행한다.
  15. pluralRules를 반환한다.

17.2 Intl.PluralRules 생성자의 속성

Intl.PluralRules 생성자:

17.2.1 Intl.PluralRules.prototype

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

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

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

supportedLocalesOf 메서드가 인수 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는 복수화 과정에 관련된 로케일 확장 키를 정의하지 않는다.

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

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

17.3 Intl.PluralRules 프로토타입 객체의 속성

Intl.PluralRules 프로토타입 객체:

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

17.3.1 Intl.PluralRules.prototype.constructor

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

17.3.2 Intl.PluralRules.prototype.resolvedOptions ( )

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

  1. prthis 값으로 한다.
  2. RequireInternalSlot(pr, [[InitializedPluralRules]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 한다.
  4. pluralCategories를 선택된 로케일 pr.[[Locale]]에 대해 PluralRuleSelect의 모든 가능한 결과를 포함하는 문자열 리스트로 한다. 다음 순서대로 정렬한다: "zero", "one", "two", "few", "many", "other".
  5. Table 32의 각 행(헤더 행 제외)을 테이블 순서대로 반복하여,
  6. 현재 행의 Property 값을 p로 한다.
  7. 만약 p"pluralCategories"이면,
  8. vCreateArrayFromList(pluralCategories)로 한다.
  9. 그렇지 않으면,
  10. vpr의 내부 슬롯 중 현재 행의 Internal Slot 이름에 해당하는 값으로 한다.
  11. vundefined가 아니면,
  12. 현재 행에 Conversion 값이 있으면,
  13. 현재 행의 Conversion 값이 number임을 단언한다.
  14. v𝔽(v)로 설정한다.
  15. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  16. options를 반환한다.
Table 32: PluralRules 인스턴스의 resolved 옵션
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% 속성의 초기값은 문자열 값 "Intl.PluralRules"이다.

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

17.4 Intl.PluralRules 인스턴스의 속성

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

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

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

  • [[Locale]]는 복수 규칙에 사용되는 로케일의 언어 태그를 가진 문자열 값이다.
  • [[Type]]"cardinal" 또는 "ordinal" 중 하나의 문자열 값으로, 사용되는 복수 규칙을 식별한다.
  • [[Notation]]"standard", "scientific", "engineering", "compact" 중 하나의 문자열 값으로, 사용되는 표기법을 식별한다.
  • [[CompactDisplay]]"short" 또는 "long" 중 하나의 문자열 값으로, "compact" 표기법으로 포매팅할 때 compact 표기 접미사를 짧은 형태("5K") 또는 긴 형태("5 thousand")로 표시할지 지정한다. 이는 일부 경우 복수형 선택에 영향을 줄 수 있다. [[Notation]]"compact" 값일 때만 사용된다.
  • [[MinimumIntegerDigits]]는 사용할 최소 정수 자릿수를 나타내는 0 이상의 정수이다.
  • [[MinimumFractionDigits]][[MaximumFractionDigits]]는 사용할 최소 및 최대 소수 자릿수를 나타내는 0 이상의 정수이다. 숫자는 필요에 따라 반올림되거나 뒤에 0이 추가된다.
  • [[MinimumSignificantDigits]][[MaximumSignificantDigits]]는 사용할 최소 및 최대 유효 자릿수를 나타내는 양의 정수이다. 둘 중 하나만 있거나 둘 다 없을 수 있다. 둘 다 있으면 최소 및 최대 정수/소수 자릿수를 덮어쓴다.
  • [[RoundingType]]fraction-digits, significant-digits, more-precision, less-precision 중 하나의 값으로, 사용할 반올림 전략을 나타낸다. 16.4에서 논의된다.
  • [[ComputedRoundingPriority]]"auto", "morePrecision", "lessPrecision" 중 하나의 문자열 값이다. 에서 [[RoundingType]]"roundingPriority" 옵션으로 변환할 때만 사용된다.
  • [[RoundingIncrement]]는 10, 100, 1000, 10000을 10분의 1, 5분의 1, 4분의 1, 2분의 1로 나누는 정수이다. 반올림해야 할 크기에 대해 반올림이 이루어지는 증가값을 나타낸다. 예를 들어, [[MaximumFractionDigits]]가 2이고 [[RoundingIncrement]]가 5이면, 숫자는 0.05 단위로 반올림된다("nickel rounding").
  • [[RoundingMode]]는 사용할 반올림 모드를 식별한다.
  • [[TrailingZeroDisplay]]"auto" 또는 "stripIfInteger" 중 하나의 문자열 값으로, 포매팅된 숫자가 정수(즉, 0이 아닌 소수 자릿수가 없는 경우)일 때 뒤의 0을 제거할지 여부를 나타낸다.

17.5 PluralRules 객체의 추상 연산

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

The implementation-defined abstract operation PluralRuleSelect takes arguments locale (언어 태그), type ("cardinal" 또는 "ordinal"), notation (문자열), compactDisplay ("short" 또는 "long"), and s (10진 문자열) and returns "zero", "one", "two", "few", "many", 또는 "other".

17.5.2 ResolvePlural ( pluralRules, n )

The abstract operation ResolvePlural takes arguments pluralRules (Intl.PluralRules) and n (Intl 수학 값) and returns [[PluralCategory]]("zero", "one", "two", "few", "many", 또는 "other")와 [[FormattedString]](문자열) 필드를. It performs the following steps when called:

  1. nnot-a-number이면,
  2. sNaN 값을 나타내는 ILD 문자열 값으로 한다.
  3. { [[PluralCategory]]: "other", [[FormattedString]]: s } 레코드를 반환한다.
  4. npositive-infinity이면,
  5. s를 양의 무한대를 나타내는 ILD 문자열 값으로 한다.
  6. { [[PluralCategory]]: "other", [[FormattedString]]: s } 레코드를 반환한다.
  7. nnegative-infinity이면,
  8. s를 음의 무한대를 나타내는 ILD 문자열 값으로 한다.
  9. { [[PluralCategory]]: "other", [[FormattedString]]: s } 레코드를 반환한다.
  10. resFormatNumericToString(pluralRules, n)로 한다.
  11. sres.[[FormattedString]]로 한다.
  12. localepluralRules.[[Locale]]로 한다.
  13. typepluralRules.[[Type]]로 한다.
  14. notationpluralRules.[[Notation]]로 한다.
  15. compactDisplaypluralRules.[[CompactDisplay]]로 한다.
  16. pPluralRuleSelect(locale, type, notation, compactDisplay, s)로 한다.
  17. { [[PluralCategory]]: p, [[FormattedString]]: s } 레코드를 반환한다.

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

The implementation-defined abstract operation PluralRuleSelectRange takes arguments locale (언어 태그), type ("cardinal" 또는 "ordinal"), notation (문자열), compactDisplay ("short" 또는 "long"), xp ("zero", "one", "two", "few", "many", 또는 "other"), and yp ("zero", "one", "two", "few", "many", 또는 "other") and returns "zero", "one", "two", "few", "many", 또는 "other".

17.5.4 ResolvePluralRange ( pluralRules, x, y )

The abstract operation ResolvePluralRange takes arguments pluralRules (Intl.PluralRules), x (Intl 수학 값), and y (Intl 수학 값) and returns 정상 완료 시 "zero", "one", "two", "few", "many", 또는 "other" 중 하나의 문자열 값 또는 throw 완료. It performs the following steps when called:

  1. xnot-a-number이거나 ynot-a-number이면, RangeError 예외를 발생시킨다.
  2. xpResolvePlural(pluralRules, x)로 한다.
  3. ypResolvePlural(pluralRules, y)로 한다.
  4. xp.[[FormattedString]]yp.[[FormattedString]]과 같으면,
  5. xp.[[PluralCategory]]를 반환한다.
  6. localepluralRules.[[Locale]]로 한다.
  7. typepluralRules.[[Type]]로 한다.
  8. notationpluralRules.[[Notation]]로 한다.
  9. compactDisplaypluralRules.[[CompactDisplay]]로 한다.
  10. PluralRuleSelectRange(locale, type, notation, compactDisplay, xp.[[PluralCategory]], yp.[[PluralCategory]])를 반환한다.

18 RelativeTimeFormat 객체

18.1 Intl.RelativeTimeFormat 생성자

Intl.RelativeTimeFormat 생성자:

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

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

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

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

  1. NewTarget이 undefined이면, TypeError 예외를 throw한다.
  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. roptionsResolution.[[ResolvedLocale]]로 한다.
  6. localer.[[Locale]]로 한다.
  7. relativeTimeFormat.[[Locale]]locale로 설정한다.
  8. relativeTimeFormat.[[LocaleData]]r.[[LocaleData]]로 설정한다.
  9. relativeTimeFormat.[[NumberingSystem]]r.[[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 생성자:

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는 상대 시간 포매팅에 관련된 로케일 확장 키 하나를 설명한다: "nu"는 숫자 시스템(포매팅된 숫자의)에 해당한다.

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

  • [[LocaleData]].[[<locale>]]에는 "second", "minute", "hour", "day", "week", "month", "quarter", "year" 필드가 있다. 이전 이름에 "-narrow" 또는 "-short" 문자열이 붙은 추가 필드가 있을 수 있다. 해당 필드의 값은 다음 두 범주의 필드를 포함하는 레코드이다:
    • "future""past" 필드는, 해당 로케일에 관련된 모든 복수형 카테고리의 필드를 가진 레코드이다. 해당 필드의 값은 "{0}"을 포함할 수 있는 패턴이며, 이는 포매팅된 숫자로 대체된다.
    • 선택적으로, 키가 Number의 ToString 결과인 추가 필드가 있을 수 있으며, 해당 값은 템플릿으로 처리되지 않는 리터럴 문자열이다.
  • [[LocaleData]]의 어떤 로케일 필드의 "nu" 필드 값에 포함된 리스트는 "native", "traditio", 또는 "finance" 값을 포함해서는 안 된다.
Note 2
구현에서는 Common Locale Data Repository(https://cldr.unicode.org/)에서 제공하는 로케일 데이터를 사용하는 것이 권장된다.

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

Intl.RelativeTimeFormat 프로토타입 객체:

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

18.3.1 Intl.RelativeTimeFormat.prototype.constructor

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

18.3.2 Intl.RelativeTimeFormat.prototype.resolvedOptions ( )

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

  1. relativeTimeFormatthis 값으로 한다.
  2. RequireInternalSlot(relativeTimeFormat, [[InitializedRelativeTimeFormat]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 한다.
  4. Table 33의 각 행(헤더 행 제외)을 테이블 순서대로 반복한다.
  5. 현재 행의 Property 값을 p로 한다.
  6. relativeTimeFormat의 내부 슬롯 중 현재 행의 Internal Slot 값에 해당하는 값을 v로 한다.
  7. Assert: vundefined가 아니다.
  8. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  9. 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% 속성의 초기값은 문자열 "Intl.RelativeTimeFormat"이다.

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

18.4 Intl.RelativeTimeFormat 인스턴스의 속성

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

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

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

  • [[Locale]]는 포매팅에 사용되는 로케일의 언어 태그를 가진 문자열 값이다.
  • [[LocaleData]]는 구현이 포매팅에 사용할 수 있는 데이터를 나타내는 레코드이다. 이는 %Intl.RelativeTimeFormat%.[[LocaleData]][[Locale]] 값 또는 그 접두사에 해당하는 항목의 값이다.
  • [[Style]]는 사용되는 상대 시간 포맷 스타일을 나타내는 "long", "short", "narrow" 중 하나의 문자열 값이다.
  • [[Numeric]]"always" 또는 "auto" 중 하나의 문자열 값으로, 숫자 표현이 항상 사용되는지, 또는 더 구체적인 버전이 없을 때만 사용되는지(예: "1 day ago" vs "yesterday")를 나타낸다.
  • [[NumberFormat]]는 포매팅에 사용되는 Intl.NumberFormat 객체이다.
  • [[NumberingSystem]]는 포매팅에 사용되는 Unicode Number System Identifier를 나타내는 문자열 값이다.
  • [[PluralRules]]는 포매팅에 사용되는 Intl.PluralRules 객체이다.

18.5 RelativeTimeFormat 객체의 추상 연산

18.5.1 SingularRelativeTimeUnit ( unit )

The abstract operation SingularRelativeTimeUnit takes argument unit (a String) and returns 정상 완료 시 문자열을 포함하거나 throw 완료를 반환. It performs the following steps when called:

  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 예외를 throw한다.
  10. unit을 반환한다.

18.5.2 PartitionRelativeTimePattern ( relativeTimeFormat, value, unit )

The abstract operation PartitionRelativeTimePattern takes arguments relativeTimeFormat (an Intl.RelativeTimeFormat), value (a Number), and unit (a String) and returns 정상 완료 시 [[Type]](문자열), [[Value]](문자열), [[Unit]](문자열 또는 empty) 필드를 가진 레코드 리스트를 포함하거나 throw 완료를 반환. 반환된 리스트는 relativeTimeFormat의 효과적인 로케일과 포매팅 옵션에 따라 value를 나타낸다. It performs the following steps when called:

  1. valueNaN, +∞𝔽, 또는 -∞𝔽이면, RangeError 예외를 throw한다.
  2. unit을 ? SingularRelativeTimeUnit(unit)로 한다.
  3. fieldsrelativeTimeFormat.[[LocaleData]]로 한다.
  4. patternsfields.[[<unit>]]로 한다.
  5. stylerelativeTimeFormat.[[Style]]로 한다.
  6. style"short" 또는 "narrow"이면,
  7. keyunit"-"style을 문자열로 연결한 값으로 한다.
  8. fields에 [[<key>]] 필드가 있으면, patternsfields.[[<key>]]로 설정한다.
  9. relativeTimeFormat.[[Numeric]]"auto"이면,
  10. valueString을 ! ToString(value)로 한다.
  11. patterns에 [[<valueString>]] 필드가 있으면,
  12. resultpatterns.[[<valueString>]]로 한다.
  13. 리스트에 { [[Type]]: "literal", [[Value]]: result, [[Unit]]: empty } 레코드를 포함하여 반환한다.
  14. value-0𝔽이거나 value < -0𝔽이면,
  15. tl"past"로 한다.
  16. 그렇지 않으면,
  17. tl"future"로 한다.
  18. popatterns.[[<tl>]]로 한다.
  19. fvPartitionNumberPattern(relativeTimeFormat.[[NumberFormat]], (value))로 한다.
  20. prResolvePlural(relativeTimeFormat.[[PluralRules]], value).[[PluralCategory]]로 한다.
  21. patternpo.[[<pr>]]로 한다.
  22. MakePartsList(pattern, unit, fv)를 반환한다.

18.5.3 MakePartsList ( pattern, unit, parts )

The abstract operation MakePartsList takes arguments pattern (패턴 문자열), unit (문자열), and parts (포매팅된 숫자를 나타내는 레코드 리스트) and returns [[Type]](문자열), [[Value]](문자열), [[Unit]](문자열 또는 empty) 필드를 가진 레코드 리스트. It performs the following steps when called:

  1. patternPartsPartitionPattern(pattern)로 한다.
  2. result를 새로운 빈 리스트로 한다.
  3. Record { [[Type]], [[Value]] } patternPartpatternParts에서 반복한다.
  4. patternPart.[[Type]]"literal"이면,
  5. { [[Type]]: "literal", [[Value]]: patternPart.[[Value]], [[Unit]]: empty } 레코드를 result에 추가한다.
  6. 그렇지 않으면,
  7. Assert: patternPart.[[Type]]"0"이다.
  8. Record { [[Type]], [[Value]] } partparts에서 반복한다.
  9. { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: unit } 레코드를 result에 추가한다.
  10. result를 반환한다.
Note
예시:
  1. MakePartsList("AA{0}BB", "hour", « Record { [[Type]]: "integer", [[Value]]: "15" } »)를 반환한다.
다음과 같은 레코드 리스트를 반환한다: « { [[Type]]: "literal", [[Value]]: "AA", [[Unit]]: empty}, { [[Type]]: "integer", [[Value]]: "15", [[Unit]]: "hour"}, { [[Type]]: "literal", [[Value]]: "BB", [[Unit]]: empty} »

18.5.4 FormatRelativeTime ( relativeTimeFormat, value, unit )

The abstract operation FormatRelativeTime takes arguments relativeTimeFormat (Intl.RelativeTimeFormat), value (숫자), and unit (문자열) and returns 정상 완료 시 문자열을 포함하거나 throw 완료를 반환. It performs the following steps when called:

  1. parts를 ? PartitionRelativeTimePattern(relativeTimeFormat, value, unit)로 한다.
  2. result를 빈 문자열로 한다.
  3. Record { [[Type]], [[Value]], [[Unit]] } partparts에서 반복한다.
  4. resultresultpart.[[Value]]의 문자열 연결로 설정한다.
  5. result를 반환한다.

18.5.5 FormatRelativeTimeToParts ( relativeTimeFormat, value, unit )

The abstract operation FormatRelativeTimeToParts takes arguments relativeTimeFormat (Intl.RelativeTimeFormat), value (숫자), and unit (문자열) and returns 정상 완료 시 배열을 포함하거나 throw 완료를 반환. It performs the following steps when called:

  1. parts를 ? PartitionRelativeTimePattern(relativeTimeFormat, value, unit)로 한다.
  2. result를 ! ArrayCreate(0)로 한다.
  3. n을 0으로 한다.
  4. Record { [[Type]], [[Value]], [[Unit]] } partparts에서 반복한다.
  5. OOrdinaryObjectCreate(%Object.prototype%)로 한다.
  6. CreateDataPropertyOrThrow(O, "type", part.[[Type]])를 수행한다.
  7. CreateDataPropertyOrThrow(O, "value", part.[[Value]])를 수행한다.
  8. part.[[Unit]]empty가 아니면,
  9. CreateDataPropertyOrThrow(O, "unit", part.[[Unit]])를 수행한다.
  10. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), O)를 수행한다.
  11. n을 1 증가시킨다.
  12. 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 예외를 throw한다.
  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. roptionsResolution.[[ResolvedLocale]]로 한다.
  7. segmenter.[[Locale]]r.[[Locale]]로 설정한다.
  8. granularity를 ? GetOption(options, "granularity", string, « "grapheme", "word", "sentence" », "grapheme")로 한다.
  9. segmenter.[[SegmenterGranularity]]granularity로 설정한다.
  10. segmenter를 반환한다.

19.2 Intl.Segmenter 생성자의 속성

Intl.Segmenter 생성자:

19.2.1 Intl.Segmenter.prototype

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

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

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

supportedLocalesOf 메서드가 localesoptions 인자와 함께 호출될 때, 다음 단계가 수행된다:

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

19.2.3 Intl.Segmenter 생성자의 내부 슬롯

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

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

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

Note
Intl.Segmenter는 관련 확장 키를 가지지 않는다.

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

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

Intl.Segmenter 프로토타입 객체:

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

19.3.1 Intl.Segmenter.prototype.constructor

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

19.3.2 Intl.Segmenter.prototype.resolvedOptions ( )

이 함수는 객체 초기화 시 계산된 로케일과 옵션에 접근할 수 있도록 한다.

  1. segmenterthis 값으로 한다.
  2. RequireInternalSlot(segmenter, [[InitializedSegmenter]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 한다.
  4. Table 34의 각 행(헤더 행 제외)을 테이블 순서대로 반복하여
  5. 현재 행의 Property 값을 p로 한다.
  6. 현재 행의 Internal Slot 이름을 가진 segmenter의 내부 슬롯 값을 v로 한다.
  7. vundefined가 아님을 Assert한다.
  8. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  9. 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 인자를 받아 해당 인스턴스의 로케일과 옵션을 사용하여 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% 속성의 초기값은 문자열 값 "Intl.Segmenter"이다.

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

19.4 Intl.Segmenter 인스턴스의 속성

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

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

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

  • [[Locale]]는 세분화에 사용되는 로케일의 언어 태그를 가진 문자열 값이다.
  • [[SegmenterGranularity]]"grapheme", "word", 또는 "sentence" 중 하나의 문자열 값으로, 분할할 텍스트 요소의 종류를 나타낸다.

19.5 Segments 객체

Segments 인스턴스는 특정 문자열의 세그먼트를 나타내는 객체로, 생성한 Intl.Segmenter 인스턴스의 로케일과 옵션에 따라 달라진다.

19.5.1 CreateSegmentsObject ( segmenter, string )

The abstract operation CreateSegmentsObject takes arguments segmenter (an Intl.Segmenter) and string (a String) and returns a Segments instance. Segments 인스턴스segmenterstring을 참조한다. 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 객체의 프로토타입이다.
  • 일반 객체이다.
  • [[Prototype]] 내부 슬롯의 값이 %Object.prototype%이다.
  • 다음 속성을 가진다:

19.5.2.1 %IntlSegmentsPrototype%.containing ( index )

containing 메서드는 Segments 인스턴스에서 index 인자를 받아 해당 인덱스의 코드 유닛을 포함하는 세그먼트 정보를 로케일과 옵션에 따라 반환한다. 다음 단계가 수행된다:

  1. segmentsthis 값으로 한다.
  2. RequireInternalSlot(segments, [[SegmentsSegmenter]])를 수행한다.
  3. segmentersegments.[[SegmentsSegmenter]]로 한다.
  4. stringsegments.[[SegmentsString]]로 한다.
  5. lenstring의 길이로 한다.
  6. n을 ? ToIntegerOrInfinity(index)로 한다.
  7. n < 0 또는 nlen이면, 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 인스턴스에서 호출되어 해당 문자열의 세그먼트에 대해 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 인스턴스는 세그먼트를 노출하는 문자열 값을 참조하는 [[SegmentsString]] 내부 슬롯을 가진다.

19.6 Segment Iterator 객체

Segment Iterator는 특정 문자열의 세그먼트에 대한 반복을 나타내는 객체이다.

19.6.1 CreateSegmentIterator ( segmenter, string )

The abstract operation CreateSegmentIterator takes arguments segmenter (an Intl.Segmenter) and string (a String) and returns a Segment Iterator. Segment Iteratorsegmenter의 로케일과 옵션을 사용하여 string을 반복한다. It performs the following steps when called:

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

19.6.2 %IntlSegmentIteratorPrototype% 객체

%IntlSegmentIteratorPrototype% 객체:

19.6.2.1 %IntlSegmentIteratorPrototype%.next ( )

next 메서드는 Segment Iterator 인스턴스에서 호출되어 한 세그먼트 앞으로 이동하고, 새 세그먼트를 설명하거나 반복이 끝났음을 선언하는 IteratorResult 객체를 반환한다. 다음 단계가 수행된다:

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

19.6.2.2 %IntlSegmentIteratorPrototype% [ %Symbol.toStringTag% ]

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

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

19.6.3 Segment Iterator 인스턴스의 속성

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

Table 35: Segment Iterator 인스턴스의 내부 슬롯
Internal Slot Description
[[IteratingSegmenter]] 반복에 사용되는 Intl.Segmenter 인스턴스.
[[IteratedString]] 반복되는 문자열 값.
[[IteratedStringNextSegmentCodeUnitIndex]] 반복되는 문자열 값에서 다음 세그먼트 시작 코드 유닛 인덱스.

19.7 Segment Data 객체

Segment Data 객체는 문자열의 특정 세그먼트를 나타내는 객체이다.

19.7.1 CreateSegmentDataObject ( segmenter, string, startIndex, endIndex )

The abstract operation CreateSegmentDataObject takes arguments segmenter (an Intl.Segmenter), string (a String), startIndex (a non-negative integer), and endIndex (a non-negative integer) and returns a Segment Data object. Segment Data 객체segmenterstring에서 startIndexendIndex로 경계된 세그먼트를 설명한다. It performs the following steps when called:

  1. lenstring의 길이로 한다.
  2. endIndexlen임을 Assert한다.
  3. startIndex < endIndex임을 Assert한다.
  4. resultOrdinaryObjectCreate(%Object.prototype%)로 한다.
  5. segmentstringstartIndex부터 endIndex까지의 부분 문자열로 한다.
  6. CreateDataPropertyOrThrow(result, "segment", segment)를 수행한다.
  7. CreateDataPropertyOrThrow(result, "index", 𝔽(startIndex))를 수행한다.
  8. CreateDataPropertyOrThrow(result, "input", string)를 수행한다.
  9. granularitysegmenter.[[SegmenterGranularity]]로 한다.
  10. granularity"word"이면
  11. isWordLikesegmenter.[[Locale]]에 따라 stringsegment가 "word-like"인지 나타내는 Boolean 값으로 한다.
  12. CreateDataPropertyOrThrow(result, "isWordLike", isWordLike)를 수행한다.
  13. result를 반환한다.
Note
세그먼트가 "word-like"인지 여부는 구현에 따라 다르며, 구현에서는 로케일에 맞는 맞춤화를 사용하는 것이 권장된다. 일반적으로 공백 및/또는 구두점만으로 구성된 세그먼트(예: ICU의 "WORD_NONE" 경계로 종료되는 세그먼트)는 "word-like"로 간주되지 않는다.

19.8 Segmenter 객체의 추상 연산

19.8.1 FindBoundary ( segmenter, string, startIndex, direction )

The abstract operation FindBoundary takes arguments segmenter (an Intl.Segmenter), string (a String), startIndex (a non-negative integer), and direction (before or after) and returns a non-negative integer. segmenter의 로케일과 옵션에 따라 string에서 startIndex 인덱스의 코드 유닛에서 지정된 direction으로 세분화 경계를 찾아, 바로 다음 코드 유닛 인덱스를 반환한다. It performs the following steps when called:

  1. lenstring의 길이로 한다.
  2. startIndex < len임을 Assert한다.
  3. localesegmenter.[[Locale]]로 한다.
  4. granularitysegmenter.[[SegmenterGranularity]]로 한다.
  5. directionbefore이면
  6. localegranularity를 사용하여 string의 처음부터 최대 startIndex 코드 유닛까지 마지막 세분화 경계를 검색한다.
  7. 경계가 발견되면, 그 경계 앞의 코드 유닛 수를 반환한다.
  8. 0을 반환한다.
  9. directionafter임을 Assert한다.
  10. localegranularity를 사용하여 startIndex 인덱스의 코드 유닛 뒤에 오는 첫 세분화 경계를 검색한다.
  11. 경계가 발견되면, 그 경계 앞의 코드 유닛 수를 반환한다.
  12. len을 반환한다.
Note
경계 결정은 구현에 따라 다르지만, 일반적인 기본 알고리즘은 Unicode Standard Annex #29에 명시되어 있다. 구현에서는 https://cldr.unicode.org에서 제공되는 Common Locale Data Repository와 같은 로케일 맞춤화를 사용하는 것이 권장된다.

20 ECMAScript 언어 명세의 로케일 민감 함수

ECMA-262는 여러 로케일 민감 함수를 설명합니다. 이 명세를 구현하는 ECMAScript 구현체는 여기에서 설명한 대로 이러한 함수를 구현해야 합니다.

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

20.1 String 프로토타입 객체의 프로퍼티

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

이 정의는 ECMA-262의 정의를 대체합니다, 22.1.3.12.

localeCompare 메서드가 that 인자와 선택적 인자 locales, options와 함께 호출될 때, 다음 단계가 수행됩니다:

  1. O를 ? RequireObjectCoercible(this 값)로 한다.
  2. S를 ? ToString(O)로 한다.
  3. thatValue를 ? ToString(that)로 한다.
  4. collator를 ? Construct(%Intl.Collator%, « locales, options »)로 한다.
  5. CompareStrings(collator, S, thatValue)를 반환한다.

이 함수의 "length" 프로퍼티는 1𝔽입니다.

Note 1
localeCompare 메서드는 직접적으로 Array.prototype.sort의 인자로 적합하지 않습니다. 후자는 두 인자를 받는 함수를 요구하기 때문입니다.
Note 2
localeCompare 함수는 의도적으로 제네릭입니다; this 값이 String 객체일 필요가 없습니다. 따라서 다른 종류의 객체에 메서드로 전달하여 사용할 수 있습니다.

20.1.2 String.prototype.toLocaleLowerCase ( [ locales ] )

이 정의는 ECMA-262의 정의를 대체합니다, 22.1.3.26.

이 함수는 String 값을 코드 포인트의 시퀀스로 해석합니다. ECMA-262, 6.1.4에 설명된 대로입니다. 다음 단계가 수행됩니다:

  1. O를 ? RequireObjectCoercible(this 값)로 한다.
  2. S를 ? ToString(O)로 한다.
  3. TransformCase(S, locales, lower)를 반환한다.
Note
toLocaleLowerCase 함수는 의도적으로 제네릭입니다; this 값이 String 객체일 필요가 없습니다. 따라서 다른 종류의 객체에 메서드로 전달하여 사용할 수 있습니다.

20.1.2.1 TransformCase ( S, locales, targetCase )

The abstract operation TransformCase takes arguments S (a String), locales (an ECMAScript language value), and targetCase (lower or upper). SECMA-262, 6.1.4에 설명된 대로 UTF-16 인코딩된 코드 포인트 시퀀스로 해석하고, ILD 변환을 통해 targetCase로 변환한 결과를 새로운 String 값으로 반환합니다. It performs the following steps when called:

  1. requestedLocales를 ? CanonicalizeLocaleList(locales)로 한다.
  2. requestedLocales가 빈 리스트가 아니면,
  3. requestedLocalerequestedLocales[0]로 한다.
  4. 아니면,
  5. requestedLocaleDefaultLocale()로 한다.
  6. availableLocales를 Unicode Character Database가 언어 민감 케이스 매핑을 포함하는 언어 태그를 포함하는 Available Locales List로 한다. 구현체가 추가 로케일 민감 케이스 매핑을 지원한다면, 해당 언어 태그도 포함해야 한다.
  7. matchLookupMatchingLocaleByPrefix(availableLocales, « requestedLocale »)로 한다.
  8. matchundefined가 아니면 localematch.[[locale]]로 한다; 아니면 locale"und"로 한다.
  9. codePointsStringToCodePoints(S)로 한다.
  10. targetCaselower이면,
  11. newCodePointslocale 또는 Unicode Default Case Conversion 알고리즘을 사용하여 구현체-파생 알고리즘에 따라 codePoints의 소문자 변환 결과 리스트로 한다.
  12. 아니면,
  13. Assert: targetCaseupper이다.
  14. newCodePointslocale 또는 Unicode Default Case Conversion 알고리즘을 사용하여 구현체-파생 알고리즘에 따라 codePoints의 대문자 변환 결과 리스트로 한다.
  15. CodePointsToString(newCodePoints)를 반환한다.

코드 포인트 매핑은 Unicode Standard의 Default Case Conversion Algorithms의 맞춤 버전에 따라 파생될 수 있습니다. 구현체는 Unicode Character Database의 SpecialCasing.txt 파일 및/또는 CLDR 및/또는 기타 맞춤 테일러링을 사용할 수 있습니다. 테일러링과 관계없이, 적합한 구현체의 케이스 변환 알고리즘은 동일한 입력 코드 포인트, 로케일, 대상 케이스에 대해 항상 동일한 결과를 반환해야 합니다.

Note
일부 코드 포인트의 케이스 매핑은 여러 코드 포인트를 생성할 수 있으므로 결과의 길이가 입력과 같지 않을 수 있습니다. toLocaleUpperCasetoLocaleLowerCase 모두 문맥 민감 동작을 가지므로, 함수들은 대칭적이지 않습니다. 즉, s.toLocaleUpperCase().toLocaleLowerCase()는 반드시 s.toLocaleLowerCase()와 같지 않으며, s.toLocaleLowerCase().toLocaleUpperCase()도 반드시 s.toLocaleUpperCase()와 같지 않습니다.

20.1.3 String.prototype.toLocaleUpperCase ( [ locales ] )

이 정의는 ECMA-262의 정의를 대체합니다, 22.1.3.27.

이 함수는 String 값을 코드 포인트의 시퀀스로 해석합니다. ECMA-262, 6.1.4에 설명된 대로입니다. 다음 단계가 수행됩니다:

  1. O를 ? RequireObjectCoercible(this 값)로 한다.
  2. S를 ? ToString(O)로 한다.
  3. TransformCase(S, locales, upper)를 반환한다.
Note
toLocaleUpperCase 함수는 의도적으로 제네릭입니다; this 값이 String 객체일 필요가 없습니다. 따라서 다른 종류의 객체에 메서드로 전달하여 사용할 수 있습니다.

20.2 Number 프로토타입 객체의 프로퍼티

다음 정의는 ECMA-262에 정의된 thisNumberValue 추상 연산을 참조합니다, 21.1.3.

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

이 정의는 ECMA-262의 정의를 대체합니다, 21.1.3.4.

toLocaleString 메서드가 선택적 인자 localesoptions와 함께 호출될 때, 다음 단계가 수행됩니다:

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

20.3 BigInt 프로토타입 객체의 프로퍼티

다음 정의는 ECMA-262에 정의된 thisBigIntValue 추상 연산을 참조합니다, 21.2.3.

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

이 정의는 ECMA-262의 정의를 대체합니다, 21.2.3.2.

toLocaleString 메서드가 선택적 인자 localesoptions와 함께 호출될 때, 다음 단계가 수행됩니다:

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

20.4 Date 프로토타입 객체의 프로퍼티

다음 정의는 ECMA-262에 정의된 thisTimeValue 추상 연산을 참조합니다, 21.4.4.

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

이 정의는 ECMA-262의 정의를 대체합니다, 21.4.4.39.

toLocaleString 메서드가 선택적 인자 localesoptions와 함께 호출될 때, 다음 단계가 수행됩니다:

  1. dateObjectthis 값으로 한다.
  2. RequireInternalSlot(dateObject, [[DateValue]])를 수행한다.
  3. xdateObject.[[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. dateObjectthis 값으로 한다.
  2. RequireInternalSlot(dateObject, [[DateValue]])를 수행한다.
  3. xdateObject.[[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. dateObjectthis 값으로 한다.
  2. RequireInternalSlot(dateObject, [[DateValue]])를 수행한다.
  3. xdateObject.[[DateValue]]로 한다.
  4. xNaN이면, "Invalid Date"를 반환한다.
  5. timeFormat를 ? CreateDateTimeFormat(%Intl.DateTimeFormat%, locales, options, time, time)로 한다.
  6. FormatDateTime(timeFormat, x)를 반환한다.

20.5 Array 프로토타입 객체의 프로퍼티

20.5.1 Array.prototype.toLocaleString ( [ locales [ , options ] ] )

이 정의는 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )의 정의를 대체합니다.

toLocaleString 메서드가 선택적 인자 localesoptions와 함께 호출될 때, 다음 단계가 수행됩니다:

  1. array를 ? ToObject(this 값)로 한다.
  2. len을 ? LengthOfArrayLike(array)로 한다.
  3. separator를 호스트 환경의 현재 로케일에 적합한 구현체-정의 리스트 구분자 문자열 값(예: ", ")로 한다.
  4. R을 빈 문자열로 한다.
  5. k를 0으로 한다.
  6. k < len 동안 반복한다,
  7. k > 0이면,
  8. RRseparator의 문자열 연결로 설정한다.
  9. nextElement를 ? Get(array, ! ToString(𝔽(k)))로 한다.
  10. nextElementundefined 또는 null이 아니면,
  11. S를 ? ToString(? Invoke(nextElement, "toLocaleString", « locales, options »))로 한다.
  12. RRS의 문자열 연결로 설정한다.
  13. kk + 1로 한다.
  14. R을 반환한다.
Note 1
이 알고리즘의 단계는 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )의 단계와 유사하지만, Invoke(nextElement, "toLocaleString")가 이제 localesoptions를 인자로 받습니다.
Note 2
배열의 요소들은 각자의 toLocaleString 메서드를 사용하여 문자열로 변환되고, 이 문자열들은 구현체-정의 로케일 민감 구분자 문자열로 구분되어 연결됩니다. 이 함수는 toString과 유사하지만, 호스트 환경의 현재 로케일 관습에 맞는 로케일 민감 결과를 제공하도록 설계되었습니다.
Note 3
toLocaleString 함수는 의도적으로 제네릭입니다; this 값이 Array 객체일 필요가 없습니다. 따라서 다른 종류의 객체에 메서드로 전달하여 사용할 수 있습니다.

Annex A (informative) 구현에 따라 달라질 수 있는 동작

이 명세의 다음 측면들은 구현에 따라 달라질 수 있습니다:

Annex B (informative) 이전 판과의 호환성에 영향을 주는 추가 및 변경 사항

Annex C (informative) 콜로폰

이 명세서는 GitHub에서 Ecmarkup라는 평문 소스 형식으로 작성되었습니다. Ecmarkup은 HTML과 Markdown 방언으로, 평문으로 ECMAScript 명세서를 작성하고, 이 문서의 편집 규칙을 따르는 완전한 HTML 렌더링으로 처리할 수 있는 프레임워크와 도구를 제공합니다. Ecmarkup은 Grammarkdown을 사용한 구문 정의와 Ecmarkdown을 사용한 알고리즘 단계 작성 등 여러 형식과 기술을 통합하여 구축되었습니다. 이 명세서의 PDF 렌더링은 CSS Paged Media 명세를 활용하는 인쇄 스타일시트를 사용하여 PrinceXML로 변환됩니다.

이전 판의 명세서는 Word로 작성되었습니다. 이 판의 기반이 된 Ecmarkup 소스 텍스트는 ECMAScript 2015 Word 문서를 자동 변환 도구로 Ecmarkup으로 변환하여 생성되었습니다.

Copyright & Software License

Ecma International

Rue du Rhone 114

CH-1204 Geneva

Tel: +41 22 849 6000

Fax: +41 22 849 6001

Web: https://ecma-international.org/

Software License

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.