초안 ECMA-402 / 2025년 10월 22일

ECMAScript® 2026 국제화 API 명세서

이 명세서에 기여하기

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

이 문서가 어떻게 작성되는지에 대한 자세한 정보는 콜로폰을 참고하세요.

소개

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

ECMAScript 2026 국제화 API 명세서(ECMA-402 제13판)는 ECMA-262를 보완하는 주요 언어 민감 기능을 제공합니다. 이 기능들은 Internationalization Components for Unicode (ICU) 라이브러리 (https://unicode-org.github.io/icu-docs/), .NET 프레임워크, Java 플랫폼 등에서 잘 확립된 국제화 API로부터 선택되었습니다.

제1판 API는 2010년 9월 Ecma TC39가 Nebojša Ćirić와 Jungshik Shin의 제안에 따라 설립한 임시 그룹에서 개발되었습니다.

제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

참고
이 명세서의 해당 섹션은 위 참고 문헌에 따라 최선의 노력으로 갱신되나, 반드시 최신 표준을 반영한다고 보장하지는 않습니다.

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 객체는 이 명세서에서 정의된 모든 기능을 하나로 모아 이름 충돌을 방지합니다.

참고
API에는 다양한 포매터가 있지만, 파싱 기능은 제공하지 않습니다. 이는 의도적인 설계이며, 해당 기능을 포함하는 것의 장단점을 충분히 논의한 후 결정된 사항입니다. 자세한 논의는 이슈 트래커를 참고하세요.

4.3 API 관례

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

참고
ECMA 402 v1에서는 Intl 생성자를 기존 객체에 적용하여 해당 객체에 내부 슬롯을 추가해 클래스 인스턴스로 변환하는 동작 모드를 지원했습니다. ECMA 402 v2에서는 기존 객체에 내부 슬롯을 추가하지 않도록 이 기능이 제거되었습니다. ECMA 402 v3에서는 "규범적 선택사항"으로 기능이 복원되어, 생성자가 호출될 때 어떤 객체에도 기반 Intl 인스턴스를 체이닝하는 모드를 지원합니다. 자세한 내용은 이슈 57을 참고하세요.

4.4 구현 종속성

국제화의 특성상, 이 명세서는 여러 세부 사항을 구현 종속적으로 남겨 둘 수밖에 없습니다:

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

브라우저 구현에서는 특정 origin에서 보이는 로케일, 통화, 달력, 숫자 체계 등 나열 가능한 항목의 초기 집합이 동일한 사용자 에이전트 문자열(엔진 및 플랫폼 버전)을 공유하는 모든 사용자에게 동일해야 합니다. 또한, 이러한 집합의 동적 변경은 사용자가 서로 구별될 수 있도록 만들어서는 안 됩니다. 이 제약은 국제화에 내재된 핑거프린팅 위험을 줄이기 위해 부과되며, 향후 개정에서 완화될 수 있습니다. 이 제약의 결과로, 브라우저 구현에서 온디맨드 로케일 설치를 허용하는 경우, 특정 origin에서 새로운 로케일 설치가 필요할 수 있는 첫 요청이 들어오면 해당 로케일이 이미 설치되어 있는지 여부를 노출해서는 안 됩니다.

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

4.4.1 구현 간 호환성

ECMA 402는 함수에서 사용하는 데이터의 스키마를 기술합니다. 내부 데이터는 구현 종속적이며, 시간이 지남에 따라 바뀌고 구현마다 다를 수 있습니다. 이러한 차이는 프로그래머에게 노출되며, 특정 출력에 의존하는 프로그램도 만들 수 있습니다. 그러나 이 명세서는 구현 간에도 잘 작성된 프로그램이 동작할 수 있도록 합리적인 제약을 기술하려고 노력합니다. 구현체들은 언어 데이터의 일관성을 높이기 위한 노력을 계속할 것을 권장합니다.

5 표기 관례

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

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

Record 명세 타입의 확장으로, “[[<name>]]” 표기는 변수 name이 지정하는 String 값의 필드를 나타냅니다. 예를 들어 변수 s의 값이 "a"이면, [[<s>]]는 [[a]] 필드를 나타냅니다.

이 명세서는 규범적 선택사항 블록을 사용하여 ECMA 262의 부록 B의 의미를 표시합니다. 즉, 규범적 선택사항 섹션은 ECMAScript 호스트가 웹 브라우저일 때는 필수입니다. 웹 브라우저가 아닌 경우에는 해당 섹션의 내용이 규범적이지만 선택사항입니다.

5.1 잘 알려진 내재 객체

아래 표는 잘 알려진 내재 객체 표를 확장합니다.

표 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% 세그먼트 이터레이터 객체의 프로토타입 (19.6.2)
%IntlSegmentsPrototype% Segments 객체의 프로토타입 (19.5.2)

6 로케일, 통화, 시간대, 측정 단위, 숫자 체계, 정렬 방식, 달력의 식별

이 절에서는 로케일, 통화, 시간대, 측정 단위, 숫자 체계, 정렬 방식, 달력, 그리고 패턴 문자열을 식별하기 위해 이 명세서에서 사용하는 String 값들을 설명한다.

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

로케일, 통화, 스크립트, 시간대를 식별하는 데 사용되는 String 값은 ASCII 대소문자 비구분 방식으로 해석되며, 코드 유닛 0x0041부터 0x005A까지(유니코드 문자 LATIN CAPITAL LETTER A부터 LATIN CAPITAL LETTER Z에 해당)와 이에 대응하는 코드 유닛 0x0061부터 0x007A까지(유니코드 문자 LATIN SMALL LETTER A부터 LATIN SMALL LETTER Z에 해당)를 포함 범위 내에서 서로 동등하게 취급한다. 그 외의 대소문자 폴딩 동등성은 적용되지 않는다.

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

String 값 SASCII-uppercaseS에서 나타나는 모든 ASCII 소문자 코드 유닛(0x0061부터 0x007A까지, 포함)을 해당하는 ASCII 대문자 코드 유닛(0x0041부터 0x005A까지, 포함)으로 치환하고, 다른 모든 코드 유닛은 보존하여 얻어지는 String 값이다.

String 값 SASCII-lowercaseS에서 나타나는 모든 ASCII 대문자 코드 유닛(0x0041부터 0x005A까지, 포함)을 해당하는 ASCII 소문자 코드 유닛(0x0061부터 0x007A까지, 포함)으로 치환하고, 다른 모든 코드 유닛은 보존하여 얻어지는 String 값이다.

String 값 A는, A의 ASCII-uppercase가 B의 ASCII-uppercase와 정확히 동일한 코드 유닛 시퀀스인 경우, String 값 B에 대한 ASCII 대소문자 비구분 일치이다. 유니코드 코드 포인트 시퀀스 A는, BCodePointsToString(A)에 대한 ASCII 대소문자 비구분 일치인 경우 B와 ASCII 대소문자 비구분 일치이다.

6.2 언어 태그

이 명세서는 로케일을 Unicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance에 의해 정의된 Unicode BCP 47 로케일 식별자로 식별하며, 그 알고리즘은 Section 3 Unicode Language and Locale Identifiers의 문법에 정의된 유니코드 로케일 논터미널을 참조한다. 이러한 각 식별자는 언어 태그라고도 부를 수 있으며, 실제로 BCP 47에서 사용하는 용어의 유효한 언어 태그이다. Unicode Technical Standard #35 Part 1 Core, Section 3.2.1 Canonical Unicode Locale Identifiers에서 규정한 정규형의 로케일 식별자는 "유니코드 정규화 로케일 식별자"라고 한다.

로케일 식별자는, "-" (U+002D HYPHEN-MINUS) 문자로 구분된 대소문자 비구분의 유니코드 Basic Latin 영숫자 서브태그로 구성되며, 한 글자짜리 서브태그는 "싱글턴 서브태그"라고 한다. Unicode Technical Standard #35 Part 1 Core, Section 3.6 Unicode BCP 47 U Extension서브태그 시퀀스가 광범위하게 사용되며, "유니코드 로케일 확장 시퀀스"는 언어 태그의 부분 문자열 중에서 unicode_locale_extensions 유니코드 로케일 논터미널에 의해 매칭될 수 있고 "-x-…" 개인용 서브태그 시퀀스의 일부가 아닌 가장 긴 부분 문자열을 설명한다. 이는 "-u-"로 시작하며, 싱글턴 서브태그가 아닌 즉시 뒤따르는 모든 서브태그와 그 앞의 "-" 구분자를 포함한다. 예를 들어, "en-US-u-fw-mon-x-u-ex-foobar"유니코드 로케일 확장 시퀀스"-u-fw-mon"이다.

모든 구조적으로 유효한 언어 태그는 이 명세서에서 정의된 API와 함께 사용하는 데 적합하지만, 구현체가 이를 검증하기 위해 유니코드 공통 로케일 데이터 저장소(CLDR) 데이터를 사용해야 하는 것은 아니다. 구현체가 충분한 현지화로 지원하는 로케일(즉, 언어 태그)의 집합은 구현 정의이다. Intl 생성자는 요청된 언어 태그를 각 구현체가 지원하는 로케일로 매핑한다.

6.2.1 IsStructurallyValidLanguageTag ( locale )

추상 연산 IsStructurallyValidLanguageTag는 인수 locale (String)을 받아 Boolean을 반환한다. 이는 locale이 구문상 잘 형성된 언어 태그인지 판단한다. locale이 의미 있는 의미론을 전달하는지, 또는 별칭 서브태그와 그 선호 교체 서브태그를 구별하는지, 정규 대소문자나 서브태그 순서를 요구하는지는 고려하지 않는다. 호출 시 다음 단계를 수행한다:

  1. lowerLocaleASCII-lowercase(locale)로 둔다.
  2. lowerLocaleunicode_locale_id 유니코드 로케일 논터미널에 의해 매칭되지 않으면, false를 반환한다.
  3. lowerLocaleUnicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance에 기술된 하위 호환 구문을 아무거나 사용한다면, false를 반환한다.
  4. baseNameGetLocaleBaseName(lowerLocale)로 둔다.
  5. variantsGetLocaleVariants(baseName)로 둔다.
  6. variantsundefined가 아니면, 다음을 수행한다:
    1. variants가 중복된 서브태그를 포함하면, false를 반환한다.
  7. extensionslowerLocale에서 baseName 뒤의 접미사로 둔다.
  8. 참고: pu_extensions 유니코드 로케일 논터미널에 의해 매칭되는 "-x-…" 개인용 서브태그 시퀀스는 무시되어야 하지만, 뒤에 내용이 없는 고립된 마지막 "x" 서브태그는 아래의 어떤 검사에도 영향을 주지 않는다.
  9. puIndexStringIndexOf(extensions, "-x-", 0)로 둔다.
  10. puIndexnot-found가 아니면, extensions를 0부터 puIndex까지의 부분 문자열로 설정한다.
  11. extensions가 빈 String이 아니면, 다음을 수행한다:
    1. extensions가 중복된 싱글턴 서브태그를 포함하면, false를 반환한다.
    2. transformExtension을, transformed_extensions 유니코드 로케일 논터미널에 의해 매칭되는 extensions의 가장 긴 부분 문자열로 둔다. 그런 부분 문자열이 없으면, true를 반환한다.
    3. Assert: transformExtension의 0에서 3까지의 부분 문자열"-t-"이다.
    4. tPrefixtransformExtension의 3 이후의 부분 문자열로 둔다.
    5. tlangtlang 유니코드 로케일 논터미널에 매칭되는 tPrefix의 가장 긴 접두사로 둔다. 그런 접두사가 없다면, true를 반환한다.
    6. tlangVariantsGetLocaleVariants(tlang)으로 둔다.
    7. tlangVariants에 중복된 서브태그가 하나라도 있으면, false를 반환한다.
  12. true를 반환한다.

6.2.2 CanonicalizeUnicodeLocaleId ( locale )

추상 연산 CanonicalizeUnicodeLocaleId는 인수 locale (언어 태그)를 받아 유니코드 정규화 로케일 식별자를 반환한다. 이는 locale의 정규적이고 대소문자 정규화된 형태를 반환한다. 호출 시 다음 단계를 수행한다:

  1. localeId를, Unicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalization에 따라 locale을 정규형으로 변환하는 알고리즘을 수행한 결과의 String 값으로 둔다(알고리즘은 구문만 정규화하는 것부터 시작함에 유의).
  2. localeId유니코드 로케일 확장 시퀀스부분 문자열이 포함되어 있으면, 다음을 수행한다:
    1. extension을, localeId 내의 유니코드 로케일 확장 시퀀스 부분 문자열로 구성된 String 값으로 둔다.
    2. newExtension"-u"로 둔다.
    3. componentsUnicodeExtensionComponents(extension)으로 둔다.
    4. components.[[Attributes]]의 각 요소 attr에 대해, 다음을 수행한다:
      1. newExtensionnewExtension, "-", attr문자열 연결로 설정한다.
    5. Record { [[Key]], [[Value]] } keywordcomponents.[[Keywords]]의 각 원소에 대해 다음을 수행한다:
      1. newExtensionnewExtension, "-", keyword.[[Key]]문자열 연결로 설정한다.
      2. keyword.[[Value]]가 빈 String이 아니면, 다음을 수행한다:
        1. newExtensionnewExtension, "-", keyword.[[Value]]문자열 연결로 설정한다.
    6. Assert: newExtension"-u"가 아니다.
    7. localeId를, localeId에서 부분 문자열 extension의 첫 번째 등장 요소를 newExtension으로 치환한 복사본으로 설정한다.
  3. localeId를 반환한다.
참고
단계 2는 반환된 언어 태그유니코드 로케일 확장 시퀀스가 다음을 포함하도록 보장한다:
  • 입력에서 중복된 어떤 속성의 경우에도 첫 번째 인스턴스만,
  • 입력에서 주어진 키에 대한 키워드도 첫 번째 것만.

6.2.3 DefaultLocale ( )

구현 정의 추상 연산 DefaultLocale은 인수를 받지 않으며 유니코드 정규화 로케일 식별자를 반환한다. 반환되는 String 값은 6.2.1에 따라 구조적으로 유효하고, 6.2.2에 따라 정규화된, 언어 태그이며, 호스트 환경의 현재 로케일을 나타낸다. 반환 값에는 유니코드 로케일 확장 시퀀스가 포함되어서는 안 된다.

참고
반환 값은 잠재적인 핑거프린팅 벡터가 될 수 있다. 브라우저 환경에서는 추가적인 구분 정보를 제공하지 않도록 navigator.language와 일치해야 한다.

6.3 통화 코드

이 명세서는 ISO 4217에 의해 정의된 3글자 통화 코드로 통화를 식별한다. 그 정규형은 대문자이다.

형식이 올바른 모든 3글자 ISO 4217 통화 코드는 허용된다. 하지만, 현지화된 통화 기호를 사용할 수 있는 통화 코드와 언어 태그의 조합 집합은 구현 종속이다. 현지화된 통화 기호가 제공되지 않는 경우, 서식을 위해 ISO 4217 통화 코드가 사용된다.

6.3.1 IsWellFormedCurrencyCode ( currency )

추상 연산 IsWellFormedCurrencyCode는 인수 currency (String)를 받아 Boolean을 반환한다. 이는 currency 인수가 형식이 올바른 3글자 ISO 4217 통화 코드임을 검증한다. 호출 시 다음 단계를 수행한다:

  1. currency의 길이가 3이 아니면, false를 반환한다.
  2. normalizedASCII-uppercase(currency)로 둔다.
  3. normalized에 0x0041부터 0x005A(유니코드 문자 LATIN CAPITAL LETTER A부터 LATIN CAPITAL LETTER Z에 해당) 범위를 벗어나는 코드 유닛이 하나라도 있으면, false를 반환한다.
  4. true를 반환한다.

6.4 AvailableCanonicalCurrencies ( )

구현 정의 추상 연산 AvailableCanonicalCurrencies는 인수를 받지 않으며 List 형태의 String들을 반환한다. 반환되는 List사전식 코드 유닛 순서에 따라 정렬되며, 고유하고, 형식이 올바르고, 대문자로 정규화된 3글자 ISO 4217 통화 코드를 포함한다. 이는 구현체가 Intl.DisplayNames 및 Intl.NumberFormat 객체의 기능을 제공하는 통화를 식별한다.

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

이 명세서를 채택하는 구현체는 시간대 인지를 해야 한다: ECMAScript의 계산 및 서식에 사용되는 사용 가능한 명명된 시간대 식별자와 데이터를 제공하기 위해 IANA 시간대 데이터베이스 https://www.iana.org/time-zones/를 사용해야 한다. 이 절은 시간대 인지 구현체가 IANA 시간대 데이터베이스를 어떻게 사용해야 하는지를 정의한다. IANA 시간대 데이터베이스의 Zone 이름 또는 Link 이름이 아닌 String은 어떤 것도 사용 가능한 명명된 시간대 식별자가 될 수 없다. ECMAScript 내장 객체가 반환하는 사용 가능한 명명된 시간대 식별자는 IANA 시간대 데이터베이스에 있는 대소문자를 사용해야 한다.

IANA 시간대 데이터베이스의 각 Zone은 주(primary) 시간대 식별자여야 하며, IANA 시간대 데이터베이스의 각 Link 이름은 해당 Zone 이름으로 해석되는 비주(non-primary) 시간대 식별자여야 한다. 단, 다음의 예외는 AvailableNamedTimeZoneIdentifiers에서 구현한다:

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

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

유니코드 공통 로케일 데이터 저장소(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"는 새 Zone "Europe/Kyiv"로 해석되는 Link로 더 이상 사용되지 않도록(deprecated) 되었다. 더 이상 사용되지 않게 된 Link는 이름이 변경된 시간대 식별자라고 부르고, 새로 추가된 Zone은 대체 시간대 식별자라고 부른다.

이러한 드문 변경으로 인한 혼란을 줄이기 위해, 구현은 처음에는 각 대체 시간대 식별자를 기존의 이름이 변경된 시간대 식별자로 해석되는 비주 시간대 식별자로 추가해야 한다. 이는 ECMAScript 프로그램이 두 식별자 모두를 인식하도록 허용하지만, 아직 해당 식별자를 인식하지 못하는 다른 시스템에 대체 시간대 식별자를 전송할 가능성을 낮춘다. 이름 변경 대기 기간 이후, 구현은 새 Zone을 주 시간대 식별자로 승격시키는 동시에, 이름이 변경된 시간대 식별자를 비주로 강등시켜야 한다. 다른 시스템이 업데이트될 수 있도록 충분한 시간을 제공하기 위해, 권장되는 이름 변경 대기 기간은 2년이다. 다만, 반드시 정확하거나 동적인 값일 필요는 없다. 대신, 구현은 시간대 데이터 업데이트를 위한 정상적인 릴리스 과정의 일부로, 대기 기간 이후에 대체 시간대 식별자를 주로 승격시켜야 한다.

대기 기간은 오직 기존 Zone을 대체하기 위해 새로운 Zone이 추가된 경우에만 적용되어야 한다. 기존 Zone과 Link가 서로 바뀐 경우에는 이름 변경이 일어난 것이 아니므로 대기 기간이 필요 없다.

구현이 agent의 수명 동안 시간대 정보를 수정한다면, 사용 가능한 명명된 시간대 식별자 목록, 어떤 사용 가능한 명명된 시간대 식별자와 연관된 주 시간대 식별자, 그리고 어떤 사용 가능한 명명된 시간대 식별자와 연관된 UTC 오프셋 및 전환은, 해당 agent가 이전에 관찰한 결과와 일치해야 한다. 이러한 요구사항을 지원하는 것이 복잡하므로, 구현은 각 agent의 수명 동안, IANA 시간대 데이터베이스의 완전히 일관된 사본을 유지하는 것이 권장된다.

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

6.5.1 AvailableNamedTimeZoneIdentifiers ( )

구현 정의 추상 연산 AvailableNamedTimeZoneIdentifiers는 인수를 받지 않으며 List 형태의 Time Zone Identifier Record들을 반환한다. 그 결과는 이 구현체에서의 모든 사용 가능한 명명된 시간대 식별자와 각 사용 가능한 명명된 시간대 식별자에 대응하는 주 시간대 식별자를 기술한다. List는 각 Time Zone Identifier Record[[Identifier]] 필드에 따라 정렬된다.

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

  1. identifiers를, IANA 시간대 데이터베이스의 각 Zone 또는 Link 이름의 String 값을 포함하는 List로 둔다.
  2. Assert: identifiers의 어떤 요소도 다른 어떤 요소에 대한 ASCII 대소문자 비구분 일치가 아니다.
  3. identifiers사전식 코드 유닛 순서에 따라 정렬한다.
  4. result를 새로운 비어 있는 List로 둔다.
  5. identifiers의 각 요소 identifier에 대해, 다음을 수행한다:
    1. primaryidentifier로 둔다.
    2. identifier가 IANA 시간대 데이터베이스에서 Link 이름이고, IANA 시간대 데이터베이스의 zone.tab의 “TZ” 열에 identifier가 존재하지 않으면, 다음을 수행한다:
      1. zone을, IANA 시간대 데이터베이스의 Link 이름 해석 규칙에 따라 identifier가 해석되는 Zone 이름으로 둔다.
      2. zone"Etc/"로 시작하면, 다음을 수행한다:
        1. primaryzone으로 설정한다.
      3. 그렇지 않으면, 다음을 수행한다:
        1. identifierCountryCode를, identifier에 대응하는 지리적 영역을 포함하는 ISO 3166-1 Alpha-2 국가 코드로 둔다.
        2. zoneCountryCode를, zone에 대응하는 지리적 영역을 포함하는 ISO 3166-1 Alpha-2 국가 코드로 둔다.
        3. identifierCountryCodezoneCountryCode와 같다면, 다음을 수행한다:
          1. primaryzone으로 설정한다.
        4. 그렇지 않으면, 다음을 수행한다:
          1. countryCodeLineCount를, IANA 시간대 데이터베이스의 zone.tab 파일에서 “country-code” 열이 identifierCountryCode인 행의 개수로 둔다.
          2. countryCodeLineCount가 1이면, 다음을 수행한다:
            1. countryCodeLine을, IANA 시간대 데이터베이스의 zone.tab 파일에서 “country-code” 열이 identifierCountryCode인 행으로 둔다.
            2. primarycountryCodeLine의 “TZ” 열의 내용으로 설정한다.
          3. 그 외의 경우, 다음을 수행한다:
            1. backzoneundefined로 둔다.
            2. backzoneLinkLines를, IANA 시간대 데이터베이스의 backzone 파일에서 "Link " 또는 "#PACKRATLIST zone.tab Link "로 시작하는 행들의 List로 둔다.
            3. backzoneLinkLines의 각 요소 line에 대해, 다음을 수행한다:
              1. iStringIndexOf(line, "Link ", 0)로 둔다.
              2. linei + 5부터의 부분 문자열로 설정한다.
              3. backzoneAndLinkStringSplitToList(line, " ")로 둔다.
              4. Assert: backzoneAndLink는 최소 두 개의 요소를 가지며, backzoneAndLink[0]과 backzoneAndLink[1]은 모두 사용 가능한 명명된 시간대 식별자이다.
              5. backzoneAndLink[1]이 identifier와 같다면, 다음을 수행한다:
                1. Assert: backzoneundefined이다.
                2. backzonebackzoneAndLink[0]으로 설정한다.
            4. Assert: backzoneundefined가 아니다.
            5. primarybackzone으로 설정한다.
    3. primary"Etc/UTC", "Etc/GMT", "GMT" 중 하나이면, primary"UTC"로 설정한다.
    4. primary대체 시간대 식별자이고 그 이름 변경 대기 기간이 끝나지 않았다면, 다음을 수행한다:
      1. renamedIdentifier를, primary가 대체한 이름이 변경된 시간대 식별자로 둔다.
      2. primaryrenamedIdentifier로 설정한다.
    5. recordTime Zone Identifier Record { [[Identifier]]: identifier, [[PrimaryIdentifier]]: primary }로 둔다.
    6. recordresult에 추가한다.
  6. Assert: result에는 Time Zone Identifier Record r가 포함되어 있으며, r.[[Identifier]]"UTC"이고 r.[[PrimaryIdentifier]]"UTC"이다.
  7. result를 반환한다.
참고 1

위의 Link를 주 시간대 식별자로 해석하는 알고리즘은 International Components for Unicode (ICU)의 icu::TimeZone::getIanaID() 동작과, 유니코드 공통 로케일 데이터 저장소(CLDR)에서 시간대 식별자 데이터를 유지 관리하는 절차에 대응하도록 의도되었다.

이 알고리즘은 IANA 시간대 데이터베이스의 zone.tabbackzone 파일의 데이터를 사용하여, ISO 3166-1 Alpha-2 국가 코드의 경계를 넘지 않으면서 Link를 주 시간대 식별자로 해석한다. Link의 국가 코드가 zone.tab에 한 줄만 있다면, 그 줄이 주 시간대 식별자를 결정한다. 하지만 그 국가 코드가 zone.tab에 여러 줄이라면, 올바른 주 시간대 식별자를 식별하기 위해 backzone의 과거 매핑을 사용해야 한다.

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

zone.tab이 선호되는 매핑 데이터 소스임에 유의하라. 그 이유는 backzone 매핑이 드물게 ISO 3166-1 Alpha-2 국가 코드의 경계를 넘을 수 있기 때문이다. 예를 들어, "Atlantic/Jan_Mayen"(국가 코드 "SJ")은 backzone에서 "Europe/Oslo"(국가 코드 "NO")로 매핑된다. IANA 시간대 데이터베이스 2024a 릴리스 기준으로, 이것이 발생하는 유일한 사례이다.

참고 2
IANA 시간대 데이터베이스의 시간대 식별자는 시간이 지남에 따라 변경될 수 있다. 최소한, 구현은 GetAvailableNamedTimeZoneIdentifier가 허용하는 변경으로 제한하여, surrounding agent의 수명 동안 AvailableNamedTimeZoneIdentifiers의 결과 변경을 제한하는 것이 권장된다. 이러한 권고를 지원하는 것이 복잡하므로, AvailableNamedTimeZoneIdentifiers(그리고 따라서 GetAvailableNamedTimeZoneIdentifier)의 결과는 surrounding agent의 수명 동안 동일하게 유지하는 것이 권장된다.

6.5.2 GetAvailableNamedTimeZoneIdentifier ( timeZoneIdentifier )

추상 연산 GetAvailableNamedTimeZoneIdentifier는 인수 timeZoneIdentifier (String)를 받아 Time Zone Identifier Record 또는 empty를 반환한다. timeZoneIdentifier사용 가능한 명명된 시간대 식별자인 경우, List로 반환되는 Record 중의 하나를 반환한다. 이 ListAvailableNamedTimeZoneIdentifiers에 의해 반환된다. 그렇지 않으면, empty를 반환한다. 호출 시 다음 단계를 수행한다:

  1. AvailableNamedTimeZoneIdentifiers()의 각 요소 record에 대해, 다음을 수행한다:
    1. record.[[Identifier]]timeZoneIdentifier에 대한 ASCII 대소문자 비구분 일치이면, record를 반환한다.
  2. empty를 반환한다.
참고
어떤 timeZoneIdentifier에 대해서든, 혹은 그것에 대한 ASCII 대소문자 비구분 일치인 값에 대해서도, 결과 Time Zone Identifier Recordsurrounding agent의 수명 동안 동일한 필드 값을 포함해야 한다. 또한, 시간대 식별자surrounding agent의 수명 동안 주에서 비주로 동적으로 변경되어서는 안 된다. 즉, timeZoneIdentifier가 이전의 GetAvailableNamedTimeZoneIdentifier 호출 결과의 [[PrimaryIdentifier]] 필드에 대한 ASCII 대소문자 비구분 일치라면, GetAvailableNamedTimeZoneIdentifier(timeZoneIdentifier)는 [[Identifier]][[PrimaryIdentifier]]Time Zone Identifier Record를 반환해야 한다. 이러한 요구사항을 지원하는 것이 복잡하므로, AvailableNamedTimeZoneIdentifiers(그리고 따라서 GetAvailableNamedTimeZoneIdentifier) 결과는 surrounding agent의 수명 동안 동일하게 유지하는 것이 권장된다.

6.5.3 AvailablePrimaryTimeZoneIdentifiers ( )

추상 연산 AvailablePrimaryTimeZoneIdentifiers는 인수를 받지 않으며 List 형태의 String들을 반환한다. 반환되는 List는 IANA 시간대 데이터베이스에서 지원되는 Zone 및 Link 이름의 정렬된 List이다. 호출 시 다음 단계를 수행한다:

  1. recordsAvailableNamedTimeZoneIdentifiers()로 둔다.
  2. result를 새로운 비어 있는 List로 둔다.
  3. records의 각 요소 timeZoneIdentifierRecord에 대해, 다음을 수행한다:
    1. timeZoneIdentifierRecord.[[Identifier]]timeZoneIdentifierRecord.[[PrimaryIdentifier]]와 같다면, 다음을 수행한다:
      1. timeZoneIdentifierRecord.[[Identifier]]result에 추가한다.
  4. result를 반환한다.

6.5.4 StringSplitToList ( S, separator )

추상 연산 StringSplitToList는 인수 S (String)와 separator (String)를 받아 List 형태의 String들을 반환한다. 반환되는 Listseparator를 포함하지 않으면서, separator의 발생 바로 앞/뒤에 위치하는, S의 서로 겹치지 않는 모든 부분 문자열을 포함한다. 그러한 각 부분 문자열은 인접한 separator 사이, S 맨 앞의 separator 앞, 또는 S 맨 끝의 separator 뒤에 위치하는 빈 String일 수 있으나, 그 외의 경우에는 빈 String이 아니다. 호출 시 다음 단계를 수행한다:

  1. Assert: S는 빈 String이 아니다.
  2. Assert: separator는 빈 String이 아니다.
  3. separatorLengthseparator의 길이로 둔다.
  4. substrings를 새로운 비어 있는 List로 둔다.
  5. i를 0으로 둔다.
  6. jStringIndexOf(S, separator, 0)로 둔다.
  7. jnot-found가 아닌 동안 반복한다,
    1. Ti부터 j까지의 부분 문자열로 둔다.
    2. Tsubstrings에 추가한다.
    3. ij + separatorLength로 설정한다.
    4. jStringIndexOf(S, separator, i)로 설정한다.
  8. Ti부터의 부분 문자열로 둔다.
  9. Tsubstrings에 추가한다.
  10. substrings를 반환한다.

6.6 측정 단위 식별자

이 명세서는 Unicode Technical Standard #35 Part 2 General, Section 6.2 Unit Identifiers에 의해 정의된 코어 단위 식별자(동치로 코어 단위 ID)를 사용하여 측정 단위를 식별한다. 그 정규형은 유니코드 Basic Latin 소문자(U+0061 LATIN SMALL LETTER A부터 U+007A LATIN SMALL LETTER Z까지)만 포함하고, 중간 하이픈(U+002D HYPHEN-MINUS)을 0개 이상 포함하는 문자열이다.

승인된 코어 단위 식별자 집합만 사용할 수 있다. 승인되지 않은 코어 단위 식별자를 사용하려고 하면 RangeError가 발생한다.

6.6.1 IsWellFormedUnitIdentifier ( unitIdentifier )

추상 연산 IsWellFormedUnitIdentifier는 인수 unitIdentifier (String)를 받아 Boolean을 반환한다. 이는 unitIdentifier 인수가, 승인된 단일 단위이거나 두 개의 승인된 단일 단위를 나눗셈으로 구성한 복합 단위인, 형식이 올바른 코어 단위 식별자를 나타내는지 검증한다. 호출 시 다음 단계를 수행한다:

  1. IsSanctionedSingleUnitIdentifier(unitIdentifier) 가 true이면, 다음을 수행한다:
    1. true를 반환한다.
  2. iStringIndexOf(unitIdentifier, "-per-", 0)로 둔다.
  3. inot-found이거나, StringIndexOf(unitIdentifier, "-per-", i + 1)가 not-found가 아니면, 다음을 수행한다:
    1. false를 반환한다.
  4. Assert: 다섯 글자의 부분 문자열 "-per-"unitIdentifier에서 정확히 한 번, 인덱스 i에 나타난다.
  5. numerator를, unitIdentifier의 0부터 i까지의 부분 문자열로 둔다.
  6. denominator를, unitIdentifieri + 5부터의 부분 문자열로 둔다.
  7. IsSanctionedSingleUnitIdentifier(numerator) 와 IsSanctionedSingleUnitIdentifier(denominator) 가 모두 true이면, 다음을 수행한다:
    1. true를 반환한다.
  8. false를 반환한다.

6.6.2 IsSanctionedSingleUnitIdentifier ( unitIdentifier )

추상 연산 IsSanctionedSingleUnitIdentifier는 인수 unitIdentifier (String)를 받아 Boolean을 반환한다. 이는 unitIdentifier 인수가, 이 명세서의 현재 버전에서 승인된 단일 단위 식별자(시간에 따라 목록이 늘어날 수 있으며, 공통 로케일 데이터 저장소의 릴리스 38 단위 유효성 데이터의 부분집합) 중 하나인지 검증한다. Unicode Technical Standard #35 Part 2 General, Section 6.2 Unit Identifiers에서 논의된 바와 같이, 단일 단위 식별자는 다른 단위 식별자의 곱셈이나 나눗셈으로 구성되지 않은 코어 단위 식별자이다. 호출 시 다음 단계를 수행한다:

  1. unitIdentifier가 아래의 표 2에 나열되어 있으면, true를 반환한다.
  2. 그 외의 경우, false를 반환한다.
표 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 ( )

추상 연산 AvailableCanonicalUnits는 인수를 받지 않으며 List 형태의 String들을 반환한다. 반환되는 List사전식 코드 유닛 순서에 따라 정렬되며, 표 2의 모든 행(헤더 행 제외)에 나열된 단순 단위 식별자의 고유한 값으로 구성된다.

6.7 숫자 체계 식별자

이 명세서는 Unicode Technical Standard #35 Part 3 Numbers, Section 1 Numbering Systems에 참조된 이름에 대응하는 숫자 체계 식별자를 사용하여 숫자 체계를 식별한다. 그 정규형은 유니코드 Basic Latin 소문자(U+0061 LATIN SMALL LETTER A부터 U+007A LATIN SMALL LETTER Z까지)만 포함하는 문자열이다.

6.7.1 AvailableCanonicalNumberingSystems ( )

구현 정의 추상 연산 AvailableCanonicalNumberingSystems는 인수를 받지 않으며 List 형태의 String들을 반환한다. 반환되는 List사전식 코드 유닛 순서에 따라 정렬되며, 구현체가 Intl.DateTimeFormat, Intl.NumberFormat, Intl.RelativeTimeFormat 객체의 기능을 제공하는 숫자 체계를 식별하는, 고유하고 정규화된 숫자 체계 식별자를 포함한다. List에는 표 28의 모든 행(헤더 행 제외)의 Numbering System 값이 포함되어야 한다.

6.8 정렬 방식 유형

이 명세서는 Unicode Technical Standard #35 Part 5 Collation, Section 3.1 Collation Types에 의해 정의된 정렬 방식 유형을 사용하여 정렬 방식을 식별한다. 그 정규형은 유니코드 Basic Latin 소문자(U+0061 LATIN SMALL LETTER A부터 U+007A LATIN SMALL LETTER Z까지)만 포함하고, 중간 하이픈(U+002D HYPHEN-MINUS)을 0개 이상 포함하는 문자열이다.

6.8.1 AvailableCanonicalCollations ( )

구현 정의 추상 연산 AvailableCanonicalCollations는 인수를 받지 않으며 List 형태의 String들을 반환한다. 반환되는 List사전식 코드 유닛 순서에 따라 정렬되며, 구현체가 Intl.Collator 객체의 기능을 제공하는 정렬 방식을 식별하는, 고유하고 정규화된 정렬 방식 유형을 포함한다.

6.9 달력 유형

이 명세서는 Unicode Technical Standard #35 Part 4 Dates, Section 2 Calendar Elements에 의해 정의된 달력 유형을 사용하여 달력을 식별한다. 그 정규형은 유니코드 Basic Latin 소문자(U+0061 LATIN SMALL LETTER A부터 U+007A LATIN SMALL LETTER Z까지)만 포함하고, 중간 하이픈(U+002D HYPHEN-MINUS)을 0개 이상 포함하는 문자열이다.

6.9.1 AvailableCalendars ( )

구현 정의 추상 연산 AvailableCalendars는 인수를 받지 않으며 List 형태의 String들을 반환한다. 반환되는 List사전식 코드 유닛 순서에 따라 정렬되며, 구현체가 Intl.DateTimeFormat 객체의 기능을 제공하는 달력을 식별하는, 정규형(6.9)의 고유한 달력 유형을 포함한다. 별칭(예: "islamicc""islamic-civil" 중 하나만이 아니라 둘 다 또는 둘 다 없음)도 포함한다. List에는 "iso8601"가 포함되어야 한다.

6.10 패턴 문자열 유형

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

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

이 문서에서 별도로 명시하지 않는 한, 이 표준에서 설명하는 객체, 함수, 생성자ECMAScript 표준 내장 객체에 대해 지정된 일반적인 요구 사항 및 제한 사항의 적용을 받는다.

8 Intl 객체

Intl 객체:

8.1 Intl 객체의 값 속성

8.1.1 Intl [ %Symbol.toStringTag% ]

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

이 속성의 속성(attribute)은 { [[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"이면,
    1. list를 새로운 비어 있는 List로 둔다.
    2. AvailableCalendars()의 각 요소 identifier에 대해,
      1. canonicalCanonicalizeUValue("ca", identifier)로 둔다.
      2. identifiercanonical과 같으면,
        1. identifierlist에 추가한다.
  3. 그 외에 key"collation"이면,
    1. listAvailableCanonicalCollations( )로 둔다.
  4. 그 외에 key"currency"이면,
    1. listAvailableCanonicalCurrencies( )로 둔다.
  5. 그 외에 key"numberingSystem"이면,
    1. listAvailableCanonicalNumberingSystems( )로 둔다.
  6. 그 외에 key"timeZone"이면,
    1. listAvailablePrimaryTimeZoneIdentifiers( )로 둔다.
  7. 그 외에 key"unit"이면,
    1. listAvailableCanonicalUnits( )로 둔다.
  8. 그 외의 경우,
    1. RangeError 예외를 던진다.
  9. CreateArrayFromList( list)를 반환한다.

9 로케일 및 매개변수 협상

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

사용 가능한 로케일 목록언어 태그의 임의 순서 중복 없는 List이며, 각 요소는 구조적으로 유효하고, 정규화되어 있으며, 유니코드 로케일 확장 시퀀스를 포함하지 않는다. 이는 특정 컨텍스트에서 구현체가 기능을 제공하는 모든 로케일을 나타낸다.

언어 우선순위 목록List이며, 내림차순 우선순위로 나열된 로케일 선호 시퀀스를 나타내는 구조적으로 유효하고 정규화언어 태그로 구성된다. 이는 BCP 47RFC 4647 섹션 2.3에서 정의된 동명 용어에 대응하지만, "*" 요소를 금지하고 정규화된 내용만 포함한다.

해결 옵션 서술자[[Key]] (문자열, 보통 [[RelevantExtensionKeys]] List의 요소)와 [[Property]] (문자열) 필드를 가지는 Record이며, 선택적으로 [[Type]] (boolean 또는 string)과 [[Values]] (empty 또는 List 형태의 ECMAScript 언어 값)을 포함할 수 있다. 이는 객체 생성 중 로케일 해결에 관련된 옵션을 읽는 방법을 설명한다.

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

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

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

9.2 추상 연산

9.2.1 CanonicalizeLocaleList ( locales )

추상 연산 CanonicalizeLocaleList는 인수 locales (ECMAScript 언어 값)을 받아, 정상 완료로 언어 우선순위 목록을 포함하거나 throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

  1. localesundefined이면,
    1. 새로운 빈 List를 반환한다.
  2. seen을 새로운 빈 List로 둔다.
  3. localesString이거나, localesObject이고 locales[[InitializedLocale]] 내부 슬롯을 가진다면,
    1. O를 ! CreateArrayFromListlocales »)로 둔다.
  4. 그 외의 경우,
    1. O를 ? ToObject(locales)로 둔다.
  5. len을 ? LengthOfArrayLike(O)로 둔다.
  6. k를 0으로 둔다.
  7. k < len인 동안 반복한다,
    1. Pk를 ! ToString(𝔽(k))로 둔다.
    2. kPresent를 ? HasProperty(O, Pk)로 둔다.
    3. kPresenttrue이면,
      1. kValue를 ? Get(O, Pk)로 둔다.
      2. kValueString이 아니고, kValueObject도 아니면, TypeError 예외를 던진다.
      3. kValueObject이고 kValue[[InitializedLocale]] 내부 슬롯을 가진다면,
        1. tagkValue.[[Locale]]로 둔다.
      4. 그 외의 경우,
        1. tag를 ? ToString(kValue)로 둔다.
      5. IsStructurallyValidLanguageTag(tag)가 false이면, RangeError 예외를 던진다.
      6. canonicalizedTagCanonicalizeUnicodeLocaleId(tag)로 둔다.
      7. seencanonicalizedTag가 없다면, seencanonicalizedTag를 추가한다.
    4. kk + 1로 설정한다.
  8. seen을 반환한다.
참고 1
비규범 요약: 본 추상 연산은 locales 인수를 배열로 해석하고 그 요소들을 List에 복사하면서, 각 요소가 구조적으로 유효한 언어 태그인지 검증하고 정규화하며, 중복을 생략한다.
참고 2
kValue가 String 또는 Object여야 한다는 요구는, Number 값 NaN이 민난어를 의미하는 언어 태그 "nan"으로 해석되지 않도록 한다.

9.2.2 CanonicalizeUValue ( ukey, uvalue )

추상 연산 CanonicalizeUValue는 인수 ukey (Unicode Technical Standard #35 Part 1 Core 섹션 3.6.1 Key and Type Definitions에 정의된 유니코드 로케일 확장 시퀀스 키)와 uvalue (String)를 받아 String을 반환한다. 반환되는 문자열은 ukey의 값으로서 uvalue의 정규적이며 대소문자 정규화된 형태이다. 호출 시 다음 단계를 수행한다:

  1. lowerValueASCII-lowercase(uvalue)로 둔다.
  2. canonicalized를, Unicode Technical Standard #35 Part 1 Core, 부록 C LocaleId Canonicalization 섹션 5 Canonicalizing Syntax, Processing LocaleIds에 따라 키 ukey의 값으로서 lowerValue를 정규화한 결과의 String 값으로 둔다.
  3. 참고: 구현체는 공통 로케일 데이터 저장소가 제공하는 common/bcp47의 'u' 확장 데이터를 사용하는 것이 권장된다(https://cldr.unicode.org/).
  4. canonicalized를 반환한다.

9.2.3 LookupMatchingLocaleByPrefix ( availableLocales, requestedLocales )

추상 연산 LookupMatchingLocaleByPrefix는 인수 availableLocales (사용 가능한 로케일 목록)과 requestedLocales (언어 우선순위 목록)을 받아, [[locale]] (유니코드 정규화 로케일 식별자)와 [[extension]] (유니코드 로케일 확장 시퀀스 또는 empty) 필드를 가진 Recordundefined를 반환한다. 이는 BCP 47RFC 4647 섹션 3.4에 정의된 조회 알고리즘을 사용하여, 유니코드 로케일 확장 시퀀스를 무시하고 requestedLocales를 만족시키는 availableLocales의 최적 요소를 결정한다. 기본이 아닌 일치가 발견되면, availableLocales에서 일치하는 언어 태그[[locale]] 필드에 담고, requestedLocales의 해당 요소의 유니코드 로케일 확장 시퀀스(요청된 언어 태그에 그러한 시퀀스가 없다면 empty)를 [[extension]] 필드에 담은 Record를 반환한다. 호출 시 다음 단계를 수행한다:

  1. requestedLocales의 각 요소 locale에 대해, 다음을 수행한다:
    1. extensionempty로 둔다.
    2. locale유니코드 로케일 확장 시퀀스가 포함되면,
      1. extensionlocale유니코드 로케일 확장 시퀀스로 설정한다.
      2. locale에서 모든 유니코드 로케일 확장 시퀀스가 제거된 문자열 값으로 locale을 설정한다.
    3. prefixlocale로 둔다.
    4. prefix가 빈 문자열이 아닌 동안 반복한다,
      1. availableLocalesprefix가 포함되어 있으면, Record { [[locale]]: prefix, [[extension]]: extension }를 반환한다.
      2. prefix"-"(코드 유닛 0x002D HYPHEN-MINUS)가 포함되어 있으면, posprefix에서 마지막으로 나타나는 "-"의 인덱스로 둔다; 그 외의 경우 pos를 0으로 둔다.
      3. pos ≥ 2이고 prefix부분 문자열 pos - 2에서 pos - 1까지가 "-"인 동안 반복한다,
        1. pospos - 2로 설정한다.
      4. prefixprefix의 0에서 pos까지의 부분 문자열로 설정한다.
  2. undefined를 반환한다.
참고
요청된 로케일이 Unicode Technical Standard #35 Part 1 Core BCP 47 T Extension 서브태그 시퀀스를 포함하는 경우, 이 알고리즘의 절단은 일시적으로 유효하지 않은 언어 태그를 생성할 수 있다. 그러나 availableLocales에는 유효한 언어 태그만 포함되어 있으므로 그러한 태그가 반환되지는 않는다.

9.2.4 LookupMatchingLocaleByBestFit ( availableLocales, requestedLocales )

구현 정의 추상 연산 LookupMatchingLocaleByBestFit는 인수 availableLocales (사용 가능한 로케일 목록)과 requestedLocales (언어 우선순위 목록)을 받아, [[locale]] (유니코드 정규화 로케일 식별자)와 [[extension]] (유니코드 로케일 확장 시퀀스 또는 empty) 필드를 가진 Recordundefined를 반환한다. 이는 유니코드 로케일 확장 시퀀스를 무시하고 requestedLocales를 만족시키는 availableLocales의 최적 요소를 결정한다. 알고리즘은 구현에 따라 달라질 수 있으나, 일반적인 요청 로케일 사용자에게 LookupMatchingLocaleByPrefix 알고리즘이 산출하는 결과만큼은 최소한 만족스럽다고 여겨질 만한 결과를 산출해야 한다. 기본이 아닌 일치가 발견되면, availableLocales에서 일치하는 언어 태그[[locale]]에, requestedLocales의 해당 요소의 유니코드 로케일 확장 시퀀스(요청된 언어 태그에 그러한 시퀀스가 없다면 empty)를 [[extension]]에 담은 Record를 반환한다.

9.2.5 UnicodeExtensionComponents ( extension )

추상 연산 UnicodeExtensionComponents는 인수 extension (유니코드 로케일 확장 시퀀스)을 받아, [[Attributes]][[Keywords]] 필드를 가진 Record를 반환한다. 이 연산은 extension을 고유한 속성들의 List와 고유 키를 가진 키워드들의 List로 분해한다. 동일한 속성이나 키워드 키가 두 번째 이후에 반복해서 나타나는 경우는 무시된다. 호출 시 다음 단계를 수행한다:

  1. Assert: extensionASCII-lowercaseextension 자체이다.
  2. Assert: extension의 0에서 3까지의 부분 문자열"-u-"이다.
  3. attributes를 새로운 빈 List로 둔다.
  4. keywords를 새로운 빈 List로 둔다.
  5. keywordundefined로 둔다.
  6. sizeextension의 길이로 둔다.
  7. k를 3으로 둔다.
  8. k < size인 동안 반복한다,
    1. eStringIndexOf(extension, "-", k)로 둔다.
    2. enot-found이면 lensize - k로, 그 외의 경우 lene - k로 둔다.
    3. subtagextensionk에서 k + len까지의 부분 문자열로 둔다.
    4. 참고: 키워드는 첫 번째가 길이 2의 키이고 그 뒤를 따르는 것들(있다면)이 길이 포함 구간 3~8에 해당하는 서브태그들의 시퀀스로, 중간 "-" 구분자들과 함께 하나의 값으로 구성된다. 속성은 모든 키워드에 앞서며 길이가 포함 구간 3~8인 단일 서브태그이다.
    5. Assert: len ≥ 2.
    6. keywordundefined이고 len ≠ 2이면,
      1. subtagattributes의 요소가 아니라면, attributessubtag를 추가한다.
    7. 그 외의 경우 len = 2이면,
      1. keywordRecord { [[Key]]: subtag, [[Value]]: "" }로 설정한다.
      2. keywords[[Key]]keyword.[[Key]]인 요소가 없다면, keywordskeyword를 추가한다.
    8. 그 외의 경우 keyword.[[Value]]가 빈 문자열이면,
      1. keyword.[[Value]]subtag로 설정한다.
    9. 그 외의 경우,
      1. keyword.[[Value]]keyword.[[Value]], "-", subtag문자열 연결로 설정한다.
    10. kk + len + 1로 설정한다.
  9. Record { [[Attributes]]: attributes, [[Keywords]]: keywords }를 반환한다.

9.2.6 InsertUnicodeExtensionAndCanonicalize ( locale, attributes, keywords )

추상 연산 InsertUnicodeExtensionAndCanonicalize는 인수 locale (언어 태그), attributes (문자열들의 List), keywords (Record들의 List)을 받아 유니코드 정규화 로케일 식별자를 반환한다. 이 연산은 attributeskeywordslocale유니코드 로케일 확장 시퀀스로써 삽입하고, 정규화된 결과를 반환한다. 호출 시 다음 단계를 수행한다:

  1. Assert: locale유니코드 로케일 확장 시퀀스를 포함하지 않는다.
  2. extension"-u"로 둔다.
  3. attributes의 각 요소 attr에 대해,
    1. extensionextension, "-", attr문자열 연결로 설정한다.
  4. keywords의 각 Record { [[Key]], [[Value]] } keyword에 대해,
    1. extensionextension, "-", keyword.[[Key]]문자열 연결로 설정한다.
    2. keyword.[[Value]]가 빈 문자열이 아니면, extensionextension, "-", keyword.[[Value]]문자열 연결로 설정한다.
  5. extension"-u"이면, CanonicalizeUnicodeLocaleId(locale)를 반환한다.
  6. privateIndexStringIndexOf(locale, "-x-", 0)로 둔다.
  7. privateIndexnot-found이면,
    1. newLocalelocaleextension문자열 연결로 둔다.
  8. 그 외의 경우,
    1. preExtensionlocale의 0에서 privateIndex까지의 부분 문자열로 둔다.
    2. postExtensionlocaleprivateIndex부터의 부분 문자열로 둔다.
    3. newLocalepreExtension, extension, postExtension문자열 연결로 둔다.
  9. Assert: IsStructurallyValidLanguageTag(newLocale)는 true이다.
  10. CanonicalizeUnicodeLocaleId(newLocale)를 반환한다.

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

추상 연산 ResolveLocale은 인수 availableLocales (사용 가능한 로케일 목록), requestedLocales (언어 우선순위 목록), options (Record), relevantExtensionKeys (문자열들의 List), localeData (Record)를 받아 Record를 반환한다. 이는 BCP 47RFC 4647 섹션 3에 정의된 "lookup"을 수행하며, options.[[localeMatcher]]에 의해 지정된 대로 LookupMatchingLocaleByBestFit 또는 LookupMatchingLocaleByPrefix 알고리즘을 사용하여, 유니코드 로케일 확장 시퀀스를 무시하고 requestedLocales를 만족시키는 availableLocales의 최적 요소를 결정한다. 그리고 일치 결과에 더해 localeData의 대응 데이터와 relevantExtensionKeys의 각 요소에 대한 해석된 값을 포함하는 표현을 반환한다(기본적으로 일치한 로케일의 데이터가 사용되고, 요청된 유니코드 로케일 확장 시퀀스가 있으면 그 데이터가 우선하며, options에 해당 값이 있으면 다시 그것으로 대체된다). 또한, requestedLocales에서 일치한 요소가 유니코드 로케일 확장 시퀀스를 포함한다면, 반환되는 Record[[Locale]] 필드의 언어 태그에 그 시퀀스를 복사하되, relevantExtensionKeys에 포함되지 않은 key 값을 가진 keyword 유니코드 로케일 논터미널이나, options의 다른 값으로 대체되는 type 값은 생략한다. 호출 시 다음 단계를 수행한다:

  1. matcheroptions.[[localeMatcher]]로 둔다.
  2. matcher"lookup"이면,
    1. rLookupMatchingLocaleByPrefix(availableLocales, requestedLocales)로 둔다.
  3. 그 외의 경우,
    1. rLookupMatchingLocaleByBestFit(availableLocales, requestedLocales)로 둔다.
  4. rundefined이면, rRecord { [[locale]]: DefaultLocale(), [[extension]]: empty }로 설정한다.
  5. foundLocaler.[[locale]]로 둔다.
  6. foundLocaleDatalocaleData.[[<foundLocale>]]로 둔다.
  7. Assert: foundLocaleDataRecord이다.
  8. result를 새로운 Record로 둔다.
  9. result.[[LocaleData]]foundLocaleData로 설정한다.
  10. r.[[extension]]empty가 아니면,
    1. componentsUnicodeExtensionComponents(r.[[extension]])로 둔다.
    2. keywordscomponents.[[Keywords]]로 둔다.
  11. 그 외의 경우,
    1. keywords를 새로운 빈 List로 둔다.
  12. supportedKeywords를 새로운 빈 List로 둔다.
  13. relevantExtensionKeys의 각 요소 key에 대해,
    1. keyLocaleDatafoundLocaleData.[[<key>]]로 둔다.
    2. Assert: keyLocaleDataList이다.
    3. valuekeyLocaleData[0]으로 둔다.
    4. Assert: valueString이거나 null이다.
    5. supportedKeywordempty로 둔다.
    6. keywords[[Key]]key인 요소가 있으면,
      1. entry를, [[Key]]keykeywords의 요소로 둔다.
      2. requestedValueentry.[[Value]]로 둔다.
      3. requestedValue가 빈 문자열이 아니면,
        1. keyLocaleDatarequestedValue가 포함되어 있으면,
          1. valuerequestedValue로 설정한다.
          2. supportedKeywordRecord { [[Key]]: key, [[Value]]: value }로 설정한다.
      4. 그 외의 경우 keyLocaleData"true"가 포함되어 있으면,
        1. value"true"로 설정한다.
        2. supportedKeywordRecord { [[Key]]: key, [[Value]]: "" }로 설정한다.
    7. Assert: options는 [[<key>]] 필드를 가진다.
    8. optionsValueoptions.[[<key>]]로 둔다.
    9. Assert: optionsValueString이거나, undefined 또는 null이다.
    10. optionsValueString이면,
      1. ukeykeyASCII-lowercase로 둔다.
      2. optionsValueCanonicalizeUValue(ukey, optionsValue)로 설정한다.
      3. optionsValue가 빈 문자열이면,
        1. optionsValue"true"로 설정한다.
    11. SameValue(optionsValue, value)가 false이고 keyLocaleDataoptionsValue가 포함되어 있으면,
      1. valueoptionsValue로 설정한다.
      2. supportedKeywordempty로 설정한다.
    12. supportedKeywordempty가 아니면, supportedKeywordssupportedKeyword를 추가한다.
    13. result.[[<key>]]를 value로 설정한다.
  14. supportedKeywords가 비어 있지 않으면,
    1. supportedAttributes를 새로운 빈 List로 둔다.
    2. foundLocaleInsertUnicodeExtensionAndCanonicalize(foundLocale, supportedAttributes, supportedKeywords)로 설정한다.
  15. result.[[Locale]]foundLocale로 설정한다.
  16. result를 반환한다.

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

추상 연산 ResolveOptions는 인수 constructor (서비스 생성자), localeData (Record), locales (ECMAScript 언어 값), options (ECMAScript 언어 값)과 선택 인수 specialBehaviours (enum들의 List), modifyResolutionOptions (매개변수 하나를 가지는 Abstract Closure)를 받아, 정상 완료로 [[Options]] (Object), [[ResolvedLocale]] (Record), [[ResolutionOptions]] (Record) 필드를 가진 Record를 포함하거나, throw 완료를 반환한다. 이 연산은 constructor를 위한 입력을 읽고 이를 로케일로 해석한다. 호출 시 다음 단계를 수행한다:

  1. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  2. specialBehaviours가 존재하고 require-options를 포함하며 optionsundefined이면, TypeError 예외를 던진다.
  3. specialBehaviours가 존재하고 coerce-options를 포함하면, options를 ? CoerceOptionsToObject(options)로 설정한다. 그 외의 경우, options를 ? GetOptionsObject(options)로 설정한다.
  4. matcher를 ? GetOption(options, "localeMatcher", string, « "lookup", "best fit" », "best fit")로 둔다.
  5. optRecord { [[localeMatcher]]: matcher }로 둔다.
  6. constructor.[[ResolutionOptionDescriptors]]의 각 해결 옵션 서술자 desc에 대해,
    1. desc[[Type]] 필드가 있으면, typedesc.[[Type]]으로 둔다. 그 외의 경우, typestring으로 둔다.
    2. desc[[Values]] 필드가 있으면, valuesdesc.[[Values]]로 둔다. 그 외의 경우, valuesempty로 둔다.
    3. value를 ? GetOption(options, desc.[[Property]], type, values, undefined)로 둔다.
    4. valueundefined가 아니면,
      1. value를 ! ToString(value)로 설정한다.
      2. valuetype 유니코드 로케일 논터미널에 의해 매칭될 수 없으면, RangeError 예외를 던진다.
    5. keydesc.[[Key]]로 둔다.
    6. opt.[[<key>]]를 value로 설정한다.
  7. modifyResolutionOptions가 존재하면, ! modifyResolutionOptions(opt)를 수행한다.
  8. resolutionResolveLocale(constructor.[[AvailableLocales]], requestedLocales, opt, constructor.[[RelevantExtensionKeys]], localeData)로 둔다.
  9. Record { [[Options]]: options, [[ResolvedLocale]]: resolution, [[ResolutionOptions]]: opt }를 반환한다.

9.2.9 FilterLocales ( availableLocales, requestedLocales, options )

추상 연산 FilterLocales는 인수 availableLocales (사용 가능한 로케일 목록), requestedLocales (언어 우선순위 목록), options (ECMAScript 언어 값)을 받아, 정상 완료로 유니코드 정규화 로케일 식별자List를 포함하거나, throw 완료를 반환한다. 이는 BCP 47RFC 4647 섹션 3에 정의된 "filtering"을 수행하며, options에 지정된 대로 LookupMatchingLocaleByBestFit 또는 LookupMatchingLocaleByPrefix 알고리즘을 사용할 때 availableLocales가 일치하는 로케일을 포함하는 requestedLocales의 요소들을 상대적 순서를 보존한 채 반환한다. 호출 시 다음 단계를 수행한다:

  1. options를 ? CoerceOptionsToObject(options)로 설정한다.
  2. matcher를 ? GetOption(options, "localeMatcher", string, « "lookup", "best fit" », "best fit")로 둔다.
  3. subset을 새로운 빈 List로 둔다.
  4. requestedLocales의 각 요소 locale에 대해,
    1. matcher"lookup"이면,
      1. matchLookupMatchingLocaleByPrefix(availableLocales, « locale »)로 둔다.
    2. 그 외의 경우,
      1. matchLookupMatchingLocaleByBestFit(availableLocales, « locale »)로 둔다.
    3. matchundefined가 아니면, subsetlocale을 추가한다.
  5. CreateArrayFromList(subset)를 반환한다.

9.2.10 GetOptionsObject ( options )

추상 연산 GetOptionsObject는 인수 options (ECMAScript 언어 값)을 받아, 정상 완료로 Object를 포함하거나 throw 완료를 반환한다. 이는 GetOption과 함께 사용하기에 적합한 Object를 반환하며, options 자체 또는 기본 빈 Object가 된다. optionsundefined도 Object도 아니면 TypeError를 던진다. 호출 시 다음 단계를 수행한다:

  1. optionsundefined이면,
    1. OrdinaryObjectCreate(null)를 반환한다.
  2. optionsObject이면,
    1. options를 반환한다.
  3. TypeError 예외를 던진다.

9.2.11 CoerceOptionsToObject ( options )

추상 연산 CoerceOptionsToObject는 인수 options (ECMAScript 언어 값)을 받아, 정상 완료로 Object를 포함하거나 throw 완료를 반환한다. 이는 GetOption과 함께 사용하기에 적합한 Object로 options를 강제 변환하며, 기본값은 빈 Object이다. 이 연산은 null이 아닌 원시 값을 객체로 강제하므로, 새로운 기능에서는 GetOptionsObject를 사용하는 것이 권장된다. 호출 시 다음 단계를 수행한다:

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

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

추상 연산 GetOption은 인수 options (Object), property (프로퍼티 키), type (boolean 또는 string), values (empty 또는 List 형태의 ECMAScript 언어 값), default (required 또는 ECMAScript 언어 값)을 받아, 정상 완료로 ECMAScript 언어 값을 포함하거나 throw 완료를 반환한다. 이는 options의 지정된 프로퍼티 값을 추출하여 요구된 type으로 변환하고, valuesempty가 아니라면 허용 여부를 확인하며, 값이 undefined이면 default로 대체한다. 호출 시 다음 단계를 수행한다:

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

9.2.13 GetBooleanOrStringNumberFormatOption ( options, property, stringValues, fallback )

추상 연산 GetBooleanOrStringNumberFormatOption은 인수 options (Object), property (프로퍼티 키), stringValues (문자열들의 List), fallback (ECMAScript 언어 값)을 받아, 정상 완료로 Boolean, String 또는 fallback 중 하나를 포함하거나, throw 완료를 반환한다. 이는 제공된 options 객체에서 property라는 이름의 프로퍼티 값을 추출한다. 그 값이 undefined이면 fallback을 반환하고, true이면 true를 반환하며, ToBoolean 결과가 false이면 false를 반환한다. 그 외의 경우 String으로 강제 변환한 값을 stringValues가 허용하면 그 결과를 반환한다. 호출 시 다음 단계를 수행한다:

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

9.2.14 DefaultNumberOption ( value, minimum, maximum, fallback )

추상 연산 DefaultNumberOption은 인수 value (ECMAScript 언어 값), minimum (정수), maximum (정수), fallback (정수 또는 undefined)을 받아, 정상 완료로 정수 또는 undefined를 포함하거나 throw 완료를 반환한다. 이는 value정수로 변환하고 허용 범위 내인지 확인하며 필요 시 fallback 값을 채운다. 호출 시 다음 단계를 수행한다:

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

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

추상 연산 GetNumberOption은 인수 options (Object), property (String), minimum (정수), maximum (정수), fallback (정수 또는 undefined)을 받아, 정상 완료로 정수 또는 undefined를 포함하거나 throw 완료를 반환한다. 이는 제공된 options 객체에서 property라는 이름의 프로퍼티 값을 추출하여 정수로 변환하고, 허용 범위 내인지 확인하며, 필요 시 fallback을 채운다. 호출 시 다음 단계를 수행한다:

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

9.2.16 PartitionPattern ( pattern )

추상 연산 PartitionPattern은 인수 pattern (패턴 문자열)을 받아, [[Type]] (String)과 [[Value]] (String 또는 undefined) 필드를 가진 Record들의 List를 반환한다. [[Type]]"literal"인 경우에 한해 [[Value]] 필드는 String 값이며, 그 외에는 undefined이다. 호출 시 다음 단계를 수행한다:

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

10 Collator 객체

10.1 Intl.Collator 생성자

Intl.Collator 생성자:

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

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

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

Intl.Collator 함수가 선택적 인수 localesoptions와 함께 호출되면, 다음 단계를 수행한다:

  1. NewTarget이 undefined이면, newTarget활성 함수 객체로 하고, 그렇지 않으면 newTarget을 NewTarget으로 둔다.
  2. internalSlotsList를 « [[InitializedCollator]], [[Locale]], [[Usage]], [[Collation]], [[Numeric]], [[CaseFirst]], [[Sensitivity]], [[IgnorePunctuation]], [[BoundCompare]] »로 둔다.
  3. collator를 ? OrdinaryCreateFromConstructor(newTarget, "%Intl.Collator.prototype%", internalSlotsList)로 둔다.
  4. 참고: ResolveOptions에 사용할 로케일 데이터의 출처는 options"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"이면,
    1. localeData%Intl.Collator%.[[SortLocaleData]]로 둔다.
  10. 그 밖의 경우,
    1. localeData%Intl.Collator%.[[SearchLocaleData]]로 둔다.
  11. optionsResolution을 ? ResolveOptions(%Intl.Collator%, localeData, CreateArrayFromList(requestedLocales), options)로 둔다.
  12. roptionsResolution.[[ResolvedLocale]]로 둔다.
  13. collator.[[Locale]]r.[[Locale]]로 설정한다.
  14. r.[[co]]null이면, collation"default"로, 그렇지 않으면 collationr.[[co]]로 둔다.
  15. collator.[[Collation]]collation으로 설정한다.
  16. collator.[[Numeric]]SameValue(r.[[kn]], "true")의 결과로 설정한다.
  17. collator.[[CaseFirst]]r.[[kf]]로 설정한다.
  18. resolvedLocaleDatar.[[LocaleData]]로 둔다.
  19. usage"sort"이면 defaultSensitivity"variant"로, 그렇지 않으면 defaultSensitivityresolvedLocaleData.[[sensitivity]]로 둔다.
  20. collator.[[Sensitivity]]를 ? GetOption(options, "sensitivity", string, « "base", "accent", "case", "variant" », defaultSensitivity)로 설정한다.
  21. defaultIgnorePunctuationresolvedLocaleData.[[ignorePunctuation]]로 둔다.
  22. collator.[[IgnorePunctuation]]을 ? GetOption(options, "ignorePunctuation", boolean, empty, defaultIgnorePunctuation)로 설정한다.
  23. collator를 반환한다.
참고
"usage" 옵션의 값이 "search"인 경우에 연관된 정렬 방식은 특정한 순서가 보장되지 않으므로, 일치하는 문자열을 찾는 용도로만 사용해야 한다. 이러한 동작은 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 생성자:

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

10.2.1 Intl.Collator.prototype

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

이 속성의 특성(attribute)은 { [[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]] 내부 슬롯의 값은 List로서, 요소 "co"를 반드시 포함해야 하며, "kf""kn" 중 임의의 것을 포함할 수 있고, 그 외의 다른 요소는 포함해서는 안 된다.

참고
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions는 정렬(collation)과 관련된 열 개의 로케일 확장 키를 설명한다: 정렬기 사용 및 특화를 위한 "co", 대체 처리(alternate handling)를 위한 "ka", 역방향 2차 가중치를 위한 "kb", 대소문자 수준을 위한 "kc", 대소문자 우선(case first)을 위한 "kf", 히라가나 4차를 위한 "kh", 정규화를 위한 "kk", 숫자 비교를 위한 "kn", 재정렬을 위한 "kr", 강도를 위한 "ks", 그리고 variable top을 위한 "vt". 그러나 Collator에서는 사용을 options 객체의 "usage" 속성으로, 대체 처리를 options 객체의 "ignorePunctuation" 속성으로, 그리고 대소문자 수준 및 강도를 options 객체의 "sensitivity" 속성으로 지정해야 한다. 언어 태그"co" 키는 정렬기 특화에 대해서만 지원되며, "kb", "kh", "kk", "kr", "vt" 키는 국제화 API의 이 버전에서는 허용되지 않는다. 나머지 키에 대한 지원은 구현에 따라 달라진다.

[[ResolutionOptionDescriptors]] 내부 슬롯의 값은 « { [[Key]]: "co", [[Property]]: "collation" }, { [[Key]]: "kn", [[Property]]: "numeric", [[Type]]: boolean }, { [[Key]]: "kf", [[Property]]: "caseFirst", [[Values]]: « "upper", "lower", "false" » } »이다.

[[SortLocaleData]][[SearchLocaleData]] 내부 슬롯의 값은 구현 정의이며, 9.1에 설명된 제약과 아래 추가 제약을 모두 만족해야 하며, 모든 로케일 값 locale에 대해 다음을 만족해야 한다:

  • [[SortLocaleData]].[[<locale>]].[[co]]의 첫 번째 요소와 [[SearchLocaleData]].[[<locale>]].[[co]]의 첫 번째 요소는 null이어야 한다.
  • [[SortLocaleData]].[[<locale>]].[[co]][[SearchLocaleData]].[[<locale>]].[[co]]의 어떤 List에도 "standard""search" 값이 요소로 사용되어서는 안 된다.
  • [[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 ( )

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

  1. collatorthis 값으로 둔다.
  2. RequireInternalSlot(collator, [[InitializedCollator]])을 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  4. 표 3의 각 행(헤더 행 제외)을 표의 순서대로 순회하며, 다음을 수행한다:
    1. p를 현재 행의 Property 값으로 둔다.
    2. v를 현재 행의 Internal Slot 값과 같은 이름을 가진 collator의 내부 슬롯의 값으로 둔다.
    3. 현재 행에 Extension Key 값이 있으면,
      1. extensionKey를 현재 행의 Extension Key 값으로 둔다.
      2. 만약 %Intl.Collator%.[[RelevantExtensionKeys]]extensionKey를 포함하지 않으면,
        1. vundefined로 설정한다.
    4. vundefined가 아니면,
      1. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  5. options를 반환한다.
표 3: Collator 인스턴스의 해석된 옵션
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이면,
    1. F10.3.3.1에 정의된 새로운 내장 함수 객체로 둔다.
    2. F.[[Collator]]collator로 설정한다.
    3. collator.[[BoundCompare]]F로 설정한다.
  4. collator.[[BoundCompare]]를 반환한다.
참고
반환된 함수는 collator에 바인딩되어 있어, Array.prototype.sort 또는 다른 함수에 직접 전달할 수 있다.

10.3.3.1 Collator 비교 함수

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

Collator 비교 함수 F가 인수 xy와 함께 호출되면, 다음 단계를 수행한다:

  1. collatorF.[[Collator]]로 둔다.
  2. Assert: collatorObject이며, 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 )

구현 정의 추상 연산 CompareStrings는 인수 collator (Intl.Collator), x (String), y (String)를 받아 Number(단, NaN은 아님)를 반환한다. 반환된 Number는 구현 정의된 로케일 민감 비교에 따라 xy를 비교한 결과를 나타낸다. 결과는 유효한 로케일 및 정렬 옵션에 따른 문자열 값의 정렬 순서에 대응하도록 의도되며, xy보다 앞서면 음수, 뒤면 양수, 그 밖의 모든 경우(상대적 순서가 없음)에는 0이 된다. 문자열 값은 ECMA-2626.1.4에 따라 UTF-16 코드 유닛 시퀀스로 해석되어야 하며, 문자열 내의 서러게이트 쌍(0xD800~0xDBFF 범위의 코드 유닛 뒤에 0xDC00~0xDFFF 범위의 코드 유닛)는 해당 코드 포인트로 해석해야 한다.

아래에 설명된 동작은 문자열의 정렬 요소 시퀀스(특히 “기본 문자”)의 로케일 민감 식별에 의존하며, 서로 다른 기본 문자는 항상 같지 않다고 비교된다(따라서 그것들을 포함하는 문자열 역시 같지 않다고 비교됨). 동일 기본 문자의 대소문자, 발음 구별 부호 등의 차이에 따른 비교 결과는 collator.[[Sensitivity]]에 따라 다음과 같이 달라진다:

표 4: Collator 민감도의 효과
[[Sensitivity]] 설명 "a" vs. "á" "a" vs. "A"
"base" 동일한 기본 문자를 가진 문자는 대소문자 및/또는 발음 구별 부호의 차이와 무관하게 서로 같지 않다고 비교되지 않는다. 같음 같음
"accent" 동일한 기본 문자를 가진 문자는 대소문자 차이와 무관하게, 악센트 및/또는 다른 발음 구별 부호가 다를 때만 같지 않다고 비교된다. 같지 않음 같음
"case" 동일한 기본 문자를 가진 문자는 발음 구별 부호의 차이와 무관하게, 대소문자가 다를 때만 같지 않다고 비교된다. 같음 같지 않음
"variant" 동일한 기본 문자를 가진 문자는 대소문자, 발음 구별 부호 및/또는 잠재적 다른 차이가 있을 때 같지 않다고 비교된다. 같지 않음 같지 않음
참고 1
입력 코드 포인트에서 기본 문자로의 매핑은 임의의 축약, 확장, 충돌을 포함할 수 있으며, 일부 발음 구별 부호가 있는 문자에 대한 특별 처리를 포함할 수 있다. 예를 들어, 스웨덴어에서 "ö"는 "o"와 다른 기본 문자이고, "v"와 "w"는 동일한 기본 문자로 간주된다. 슬로바키아어에서는 "ch"가 하나의 기본 문자이며, 영어에서는 "æ"가 "a"로 시작해 "e"로 끝나는 기본 문자 시퀀스이다.

collator.[[IgnorePunctuation]]true이면, 문장 부호는 무시된다(예: 문장 부호만 다른 문자열은 같다고 비교됨).

로케일 확장 키를 통해 설정 가능한 옵션의 해석에 대해서는 Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions를 참조하라.

실제 반환 값은 추가 정보를 인코딩할 수 있도록 구현 정의일 수 있으나, 특정 collator에 대해 xy의 함수로서 고려했을 때, 모든 문자열 집합에 대해 전순서를 정의하는 일관된 비교자여야 한다. 또한, 유니코드 표준에 따른 정준 동등성을 인지하고 준수해야 하며, 구별 가능하지만 정준적으로 동등한 문자열을 비교할 때 +0𝔽을 반환해야 한다.

참고 2
CompareStrings 추상 연산은 Unicode Technical Standard #10: Unicode Collation Algorithm을 따르며, collator의 유효한 로케일 및 정렬 옵션에 대한 테일러링을 사용하는 방식으로 구현할 것을 권장한다. 구현에서는 공통 로케일 데이터 저장소(CLDR, https://cldr.unicode.org/)가 제공하는 테일러링을 사용하는 것이 권장된다.
참고 3
애플리케이션은 동일한 해석된 옵션을 가진 Collator 인스턴스에 대해 CompareStrings 추상 연산의 동작이, 동일 구현의 다른 버전에서도 동일하게 유지된다고 가정해서는 안 된다.

10.3.4 Intl.Collator.prototype [ %Symbol.toStringTag% ]

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

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

10.4 Intl.Collator 인스턴스의 속성

Intl.Collator 인스턴스는 일반 객체이며, %Intl.Collator.prototype%로부터 속성을 상속받는다.

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

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

  • [[Locale]]는 정렬에 사용되는 로케일의 String 값이며, 해당 로케일의 언어 태그를 나타낸다.
  • [[Usage]]는 정렬기 사용을 식별하는 "sort" 또는 "search" 중 하나의 String 값이다.
  • [[Sensitivity]]는 정렬기의 민감도를 식별하는 "base", "accent", "case", "variant" 중 하나의 String 값이다.
  • [[IgnorePunctuation]]는 비교에서 문장 부호를 무시할지 여부를 지정하는 Boolean 값이다.
  • [[Collation]]은 정렬에 사용되는 Unicode Collation Identifier를 나타내는 String 값이며, "standard""search" 값은 허용되지 않고, "default"는 허용된다.

또한, 표 3에서 내부 슬롯 이름에 대응하는 키가 Intl.Collator의 [[RelevantExtensionKeys]] 내부 슬롯에 포함된 경우, Intl.Collator 인스턴스는 다음 내부 슬롯을 추가로 가진다:

  • [[Numeric]]는 숫자 정렬을 사용할지 여부를 지정하는 Boolean 값이다.
  • [[CaseFirst]]"upper", "lower", "false" 중 하나의 String 값이다.

마지막으로, Intl.Collator 인스턴스는 비교 접근자(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 주 1의 규범적 선택적 생성자 모드를 지원한다면,
    1. thisthis 값으로 둔다.
    2. ChainDateTimeFormat(dateTimeFormat, NewTarget, this)를 반환한다.
  4. dateTimeFormat을 반환한다.

11.1.1.1 ChainDateTimeFormat ( dateTimeFormat, newTarget, this )

추상 연산 ChainDateTimeFormat은 인수 dateTimeFormat (Intl.DateTimeFormat), newTarget (ECMAScript 언어 값), this (ECMAScript 언어 값)를 받아, 정상 완료로 Object를 포함하거나 throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

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

추상 연산 CreateDateTimeFormat은 인수 newTarget (생성자), locales (ECMAScript 언어 값), options (ECMAScript 언어 값), required (date, time, any), defaults (date, time, all)을 받아, 정상 완료로 DateTimeFormat 객체를 포함하거나 throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

11.1.3 FormatOffsetTimeZoneIdentifier ( offsetMinutes )

추상 연산 FormatOffsetTimeZoneIdentifier는 인수 offsetMinutes (정수)를 받아 String을 반환한다. 이는 UTC 오프셋(분 단위)을 ±HH:MM 형식의 UTC 오프셋 문자열로 포맷한다. 호출 시 다음 단계를 수행한다:

  1. offsetMinutes ≥ 0이면, sign을 코드 유닛 0x002B(플러스 기호)로, 그렇지 않으면 sign을 코드 유닛 0x002D(하이픈 마이너스)로 둔다.
  2. absoluteMinutesabs(offsetMinutes)로 둔다.
  3. hoursfloor(absoluteMinutes / 60)로 둔다.
  4. minutesabsoluteMinutes modulo 60으로 둔다.
  5. sign, ToZeroPaddedDecimalString(hours, 2), 코드 유닛 0x003A(콜론), ToZeroPaddedDecimalString(minutes, 2)의 문자열 연결 결과를 반환한다.

11.2 Intl.DateTimeFormat 생성자의 속성

Intl.DateTimeFormat 생성자:

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

11.2.1 Intl.DateTimeFormat.prototype

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

이 속성의 특성(attribute)은 { [[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" »이다.

참고 1
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions에서는 날짜 및 시간 서식과 관련된 네 개의 로케일 확장 키를 설명한다: 달력을 위한 "ca", 시(hour) 주기를 위한 "hc", (서식된 숫자의) 숫자 체계를 위한 "nu", 그리고 표준시에 대한 "tz". 그러나 DateTimeFormat에서는 표준시를 options 객체의 "timeZone" 속성을 통해 지정해야 한다.

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

[[LocaleData]] 내부 슬롯의 값은 구현 정의이며, 9.1에 설명된 제약과 다음의 추가 제약을 모두 만족해야 하며, 모든 로케일 값 locale에 대해 다음을 만족해야 한다:

  • [[LocaleData]].[[<locale>]].[[nu]]List여야 하며, "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>]] 필드를 가지는 Record여야 한다. 각 [[<calendar>]] 필드의 값은 DateTime Format RecordsList여야 한다. 그러한 List 안의 여러 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>]] 필드를 가지는 Record여야 한다. 각 [[<calendar>]] 필드의 값은 DateTime Styles Record여야 한다.

11.2.3.1 날짜-시간 서식 레코드

DateTime Format Record 각각은 표 5에 정의된 필드를 가진다.

표 5: DateTime Format Record
필드 이름 값 타입 설명
[[weekday]] [[Weekday]] 값들 (표 16의 Values 열) 선택적 필드. [[pattern]]부분 문자열 "{weekday}"이 포함된 경우 존재한다.
[[era]] [[Era]] 값들 (표 16의 Values 열) 선택적 필드. [[pattern]]부분 문자열 "{era}"가 포함된 경우 존재한다.
[[year]] [[Year]] 값들 (표 16의 Values 열) 선택적 필드. [[pattern]]"{year}", "{yearName}", "{relatedYear}" 중 적어도 하나의 부분 문자열이 포함된 경우 존재한다.
[[month]] [[Month]] 값들 (표 16의 Values 열) 선택적 필드. [[pattern]]부분 문자열 "{month}"가 포함된 경우 존재한다.
[[day]] [[Day]] 값들 (표 16의 Values 열) 선택적 필드. [[pattern]]부분 문자열 "{day}"가 포함된 경우 존재한다.
[[dayPeriod]] [[DayPeriod]] 값들 (표 16의 Values 열) 선택적 필드. [[pattern]]부분 문자열 "{dayPeriod}"가 포함된 경우 존재한다.
[[hour]] [[Hour]] 값들 (표 16의 Values 열) 선택적 필드. [[pattern]]부분 문자열 "{hour}"가 포함된 경우 존재한다.
[[minute]] [[Minute]] 값들 (표 16의 Values 열) 선택적 필드. [[pattern]]부분 문자열 "{minute}"가 포함된 경우 존재한다.
[[second]] [[Second]] 값들 (표 16의 Values 열) 선택적 필드. [[pattern]]부분 문자열 "{second}"가 포함된 경우 존재한다.
[[fractionalSecondDigits]] [[FractionalSecondDigits]] 값들 (표 16의 Values 열) 선택적 필드. [[pattern]]부분 문자열 "{fractionalSecondDigits}"가 포함된 경우 존재한다.
[[timeZoneName]] [[TimeZoneName]] 값들 (표 16의 Values 열) 선택적 필드. [[pattern]]부분 문자열 "{timeZoneName}"가 포함된 경우 존재한다.
[[pattern]] Pattern String 레코드의 각 날짜 및 시간 서식 구성 요소 필드에 대해, 부분 문자열이 포함된다. 이 부분 문자열은 "{"로 시작하고 필드 이름이 뒤따르며, "}"로 끝난다. 레코드에 [[year]] 필드가 있는 경우 문자열에는 "{yearName}""{relatedYear}" 부분 문자열이 포함될 수 있다.
[[pattern12]] Pattern String 선택적 필드. [[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 각각은 표 6에 정의된 필드를 가진다.

표 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 각각은 표 7에 정의된 필드를 가진다.

표 7: DateTime Range Pattern Format Record
필드 이름 값 타입 설명
[[weekday]] [[Weekday]] 값들 (표 16의 Values 열) 선택적 필드. [[PatternParts]]Pattern String 중 하나에 부분 문자열 "{weekday}"가 포함된 경우 존재한다.
[[era]] [[Era]] 값들 (표 16의 Values 열) 선택적 필드. [[PatternParts]]Pattern String 중 하나에 부분 문자열 "{era}"가 포함된 경우 존재한다.
[[year]] [[Year]] 값들 (표 16의 Values 열) 선택적 필드. [[PatternParts]]Pattern String 중 하나에 "{year}", "{yearName}", "{relatedYear}" 중 적어도 하나의 부분 문자열이 포함된 경우 존재한다.
[[month]] [[Month]] 값들 (표 16의 Values 열) 선택적 필드. [[PatternParts]]Pattern String 중 하나에 부분 문자열 "{month}"가 포함된 경우 존재한다.
[[day]] [[Day]] 값들 (표 16의 Values 열) 선택적 필드. [[PatternParts]]Pattern String 중 하나에 부분 문자열 "{day}"가 포함된 경우 존재한다.
[[dayPeriod]] [[DayPeriod]] 값들 (표 16의 Values 열) 선택적 필드. [[PatternParts]]Pattern String 중 하나에 부분 문자열 "{dayPeriod}"가 포함된 경우 존재한다.
[[hour]] [[Hour]] 값들 (표 16의 Values 열) 선택적 필드. [[PatternParts]]Pattern String 중 하나에 부분 문자열 "{hour}"가 포함된 경우 존재한다.
[[minute]] [[Minute]] 값들 (표 16의 Values 열) 선택적 필드. [[PatternParts]]Pattern String 중 하나에 부분 문자열 "{minute}"가 포함된 경우 존재한다.
[[second]] [[Second]] 값들 (표 16의 Values 열) 선택적 필드. [[PatternParts]]Pattern String 중 하나에 부분 문자열 "{second}"가 포함된 경우 존재한다.
[[fractionalSecondDigits]] [[FractionalSecondDigits]] 값들 (표 16의 Values 열) 선택적 필드. [[PatternParts]]Pattern String 중 하나에 부분 문자열 "{fractionalSecondDigits}"가 포함된 경우 존재한다.
[[timeZoneName]] [[TimeZoneName]] 값들 (표 16의 Values 열) 선택적 필드. [[PatternParts]]Pattern String 중 하나에 부분 문자열 "{timeZoneName}"가 포함된 경우 존재한다.
[[PatternParts]] List (DateTime Range Pattern Part Records의 목록) 각 레코드는 범위 패턴의 일부를 나타낸다.

11.2.3.4 날짜-시간 범위 패턴 파트 레코드

DateTime Range Pattern Part Record 각각은 표 8에 정의된 필드를 가진다.

표 8: DateTime Range Pattern Part Record
필드 이름 값 타입 설명
[[Source]] "shared", "startRange", "endRange" [[Pattern]] 필드의 값을 사용하여 범위의 어느 날짜를 서식화할지 나타낸다.
[[Pattern]] Pattern String 일반 날짜 패턴 문자열과 동일한 형식의 문자열이다.

11.2.3.5 날짜-시간 스타일 레코드

DateTime Styles Record 각각은 표 9에 정의된 필드를 가진다.

표 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 각각은 표 10에 정의된 필드를 가진다.

표 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 각각은 표 11에 정의된 필드를 가진다. 모든 커넥터 패턴 문자열에는 "{0}""{1}" 문자열이 포함되어야 한다.

표 11: DateTime Connector Record
필드 이름 값 타입 설명
[[full]] Pattern String date 스타일이 "full"일 때의 커넥터 패턴.
[[long]] Pattern String date 스타일이 "long"일 때의 커넥터 패턴.
[[medium]] Pattern String date 스타일이 "medium"일 때의 커넥터 패턴.
[[short]] Pattern String date 스타일이 "short"일 때의 커넥터 패턴.

11.2.3.8 날짜-시간 날짜 범위 레코드

DateTime Date Range Record 각각은 표 12에 정의된 필드를 가진다.

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

11.2.3.9 날짜-시간 시간 범위 레코드

DateTime Time Range Record 각각은 표 13에 정의된 필드를 가진다.

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

11.2.3.10 날짜-시간 스타일 범위 레코드

DateTime Style Range Record 각각은 표 14에 정의된 필드를 가진다.

표 14: DateTime Style Range Record
필드 이름 값 타입 설명
[[rangePatterns]] DateTime Range Pattern Record date 및 time 스타일을 결합하기 위한 범위 패턴.
[[rangePatterns12]] DateTime Range Pattern Record 선택적 필드. 12시간 형식을 위한 date 및 time 스타일 결합 범위 패턴.
참고 2
예를 들어, 어떤 구현은 영어 로케일 데이터의 일부로서 다음의 Record를 포함할 수 있다:
  • [[hour]]: "numeric"
  • [[minute]]: "numeric"
  • [[pattern]]: "{hour}:{minute}"
  • [[pattern12]]: "{hour}:{minute} {ampm}"
  • [[rangePatterns]]:
    • [[Hour]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
    • [[Minute]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
    • [[Default]]:
      • [[year]]: "2-digit"
      • [[month]]: "numeric"
      • [[day]]: "numeric"
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute}"}
  • [[rangePatterns12]]:
    • [[Hour]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " {ampm}"}
    • [[Minute]]:
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{hour}:{minute}"}
        • {[[Source]]: "shared", [[Pattern]]: " {ampm}"}
    • [[Default]]:
      • [[year]]: "2-digit"
      • [[month]]: "numeric"
      • [[day]]: "numeric"
      • [[hour]]: "numeric"
      • [[minute]]: "numeric"
      • [[PatternParts]]:
        • {[[Source]]: "startRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute} {ampm}"}
        • {[[Source]]: "shared", [[Pattern]]: " – "}
        • {[[Source]]: "endRange", [[Pattern]]: "{day}/{month}/{year}, {hour}:{minute} {ampm}"}
참고 3
구현에서는 가능하면 Common Locale Data Repository(https://cldr.unicode.org/)에서 제공하는 로케일 데이터를 사용하는 것이 권장된다.

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 주 1의 규범적 선택적 생성자 모드를 지원한다면,
    1. dtf를 ? UnwrapDateTimeFormat(dtf)로 설정한다.
  3. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]])를 수행한다.
  4. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  5. 표 15의 각 행(헤더 행 제외)을 표의 순서대로 순회하며, 다음을 수행한다:
    1. p를 현재 행의 Property 값으로 둔다.
    2. 현재 행에 Internal Slot 값이 있으면,
      1. vdtf의 해당 내부 슬롯 값으로 둔다.
    3. 그 외의 경우,
      1. formatdtf.[[DateTimeFormat]]로 둔다.
      2. format에 [[<p>]] 필드가 있고, dtf.[[DateStyle]]undefined이며 dtf.[[TimeStyle]]undefined라면,
        1. vformat.[[<p>]]로 둔다.
      3. 그 외의 경우,
        1. vundefined로 둔다.
    4. vundefined가 아니면,
      1. 현재 행에 Conversion 값이 있으면,
        1. conversion을 현재 행의 Conversion 값으로 둔다.
        2. conversionhour12이면,
          1. v"h11" 또는 "h12"vtrue로, 아니면 false로 설정한다.
        3. 그 외의 경우,
          1. Assert: conversionnumber이다.
          2. v𝔽(v)로 설정한다.
      2. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  6. options를 반환한다.
표 15: DateTimeFormat 인스턴스의 해석된 옵션
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로 설정되어야 한다.

참고 1
이 버전의 API에서는, options 객체에 "timeZone" 속성이 제공되지 않으면 "timeZone" 속성은 호스트 환경의 표준시 식별자가 된다. 1판에서는 이 경우 "timeZone" 속성을 undefined로 남겨두었다.
참고 2
5판 이전 버전과 호환을 위해 "hourCycle" 속성 외에도 "hour12" 속성을 설정한다.

11.3.3 get Intl.DateTimeFormat.prototype.format

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

  1. dtfthis 값으로 둔다.
  2. 구현체가 4.3 주 1의 규범적 선택적 생성자 모드를 지원한다면,
    1. dtf를 ? UnwrapDateTimeFormat(dtf)로 설정한다.
  3. RequireInternalSlot(dtf, [[InitializedDateTimeFormat]])를 수행한다.
  4. dtf.[[BoundFormat]]undefined이면,
    1. F를 DateTime Format Functions (11.5.4)에 정의된 새로운 내장 함수 객체로 둔다.
    2. F.[[DateTimeFormat]]dtf로 설정한다.
    3. dtf.[[BoundFormat]]F로 설정한다.
  5. dtf.[[BoundFormat]]를 반환한다.
참고
반환된 함수는 dtf에 바인딩되어 있어 Array.prototype.map이나 다른 함수에 직접 전달할 수 있다. 이는 더 이상 새로운 기능에 사용하지 않는 관례의 역사적 유산으로, 기존 프로그램과의 호환성을 위해 유지된다.

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

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

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

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

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

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

11.3.6 Intl.DateTimeFormat.prototype.formatToParts ( date )

formatToParts 메서드가 date 인수를 통해 호출되면, 다음 단계를 수행한다:

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

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

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

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

11.4 Intl.DateTimeFormat 인스턴스의 속성

Intl.DateTimeFormat 인스턴스는 일반 객체이며, %Intl.DateTimeFormat.prototype%로부터 속성을 상속받는다.

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

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

  • [[Locale]] String 값이며, 서식에 사용되는 로케일의 언어 태그를 나타낸다.
  • [[Calendar]] String 값이며, 서식에 사용되는 유니코드 달력 식별자를 나타낸다.
  • [[NumberingSystem]] String 값이며, 서식에 사용되는 유니코드 숫자 체계 식별자를 나타낸다.
  • [[TimeZone]] String 값이며, 서식에 사용되는 값으로 사용 가능한 명명된 표준시 식별자 또는 오프셋 표준시 식별자 중 하나이다.
  • [[HourCycle]] String 값이며, 12시간 형식("h11", "h12") 또는 24시간 형식("h23", "h24") 중 어느 쪽을 사용할지 나타낸다. "h11""h23"은 0시부터 11, 23까지, "h12""h24"는 1시부터 12, 24까지 사용한다. [[HourCycle]][[DateTimeFormat]][[hour]] 필드가 있을 때만 사용된다.
  • [[DateStyle]], [[TimeStyle]]은 각각 undefined이거나, "full", "long", "medium", "short" 값 중 하나인 String 값이다.
  • [[DateTimeFormat]]DateTime Format Record이다.

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

11.5 DateTimeFormat 객체를 위한 추상 연산

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

표 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 )

추상 연산 DateTimeStyleFormat은 인수 dateStyle ("full", "long", "medium", "short" 또는 undefined), timeStyle ("full", "long", "medium", "short" 또는 undefined), styles (DateTime Styles Record)를 받아 DateTime Format Record를 반환한다. styles는 어떤 로케일 locale과 달력 calendar에 대해 %Intl.DateTimeFormat%.[[LocaleData]].[[<locale>]].[[styles]].[[<calendar>]]의 Record이다. 이 연산은 매개변수에 기반해 날짜-시간 서식에 적절한 Record를 반환한다. 호출 시 다음 단계를 수행한다:

  1. Assert: dateStyleundefined가 아니거나 timeStyleundefined가 아니다.
  2. timeStyleundefined가 아니면,
    1. Assert: timeStyle"full", "long", "medium", "short" 중 하나이다.
    2. timeFormatstyles.[[Time]].[[<timeStyle>]]로 둔다.
  3. dateStyleundefined가 아니면,
    1. Assert: dateStyle"full", "long", "medium", "short" 중 하나이다.
    2. dateFormatstyles.[[Date]].[[<dateStyle>]]로 둔다.
  4. dateStyleundefined가 아니고 timeStyleundefined가 아니면,
    1. format을 새로운 DateTime Format Record로 둔다.
    2. formatdateFormat의 모든 필드를 추가하되, [[pattern]][[rangePatterns]]는 제외한다.
    3. formattimeFormat의 모든 필드를 추가하되, [[pattern]], [[rangePatterns]], [[pattern12]], [[rangePatterns12]](존재하는 경우)은 제외한다.
    4. connectorstyles.[[Connector]].[[<dateStyle>]]로 둔다.
    5. patternconnector 문자열에서 부분 문자열 "{0}"timeFormat.[[pattern]]으로, 부분 문자열 "{1}"dateFormat.[[pattern]]으로 치환한 문자열로 둔다.
    6. format.[[pattern]]pattern으로 설정한다.
    7. timeFormat[[pattern12]] 필드가 있으면,
      1. pattern12connector 문자열에서 부분 문자열 "{0}"timeFormat.[[pattern12]]으로, 부분 문자열 "{1}"dateFormat.[[pattern]]으로 치환한 문자열로 둔다.
      2. format.[[pattern12]]pattern12로 설정한다.
    8. dateTimeRangeFormatstyles.[[DateTimeRangeFormat]].[[<dateStyle>]].[[<timeStyle>]]로 둔다.
    9. format.[[rangePatterns]]dateTimeRangeFormat.[[rangePatterns]]로 설정한다.
    10. dateTimeRangeFormat[[rangePatterns12]] 필드가 있으면,
      1. format.[[rangePatterns12]]dateTimeRangeFormat.[[rangePatterns12]]로 설정한다.
    11. format을 반환한다.
  5. timeStyleundefined가 아니면,
    1. timeFormat을 반환한다.
  6. Assert: dateStyleundefined가 아니다.
  7. dateFormat을 반환한다.

11.5.2 BasicFormatMatcher ( options, formats )

추상 연산 BasicFormatMatcher는 인수 options (Record) 및 formats (List, DateTime Format Records)를 받아 DateTime Format Record를 반환한다. 호출 시 다음 단계를 수행한다:

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

11.5.3 BestFitFormatMatcher ( options, formats )

구현 정의 추상 연산 BestFitFormatMatcher는 인수 options (Record) 및 formats (List, DateTime Format Records)를 받아 DateTime Format Record를 반환한다. 이는 선택된 로케일의 일반 사용자가 BasicFormatMatcher가 반환하는 것과 최소한 동등하게 우수하다고 인지할 구성 요소 표현 집합을 반환한다.

11.5.4 날짜-시간 서식 함수

날짜-시간 서식 함수는 [[DateTimeFormat]] 내부 슬롯을 가진 익명 내장 함수이다.

날짜-시간 서식 함수 F가 선택적 인수 date와 함께 호출되면, 다음 단계를 수행한다:

  1. dtfF.[[DateTimeFormat]]로 둔다.
  2. Assert: dtfObject이고 dtf[[InitializedDateTimeFormat]] 내부 슬롯을 가진다.
  3. date가 제공되지 않았거나 undefined이면,
    1. x를 ! Call(%Date.now%, undefined)로 둔다.
  4. 그 밖의 경우,
    1. x를 ? ToNumber(date)로 둔다.
  5. FormatDateTime(dtf, x)를 반환한다.

날짜-시간 서식 함수의 "length" 속성은 1𝔽이다.

11.5.5 FormatDateTimePattern ( dateTimeFormat, format, pattern, epochNanoseconds )

추상 연산 FormatDateTimePattern은 인수 dateTimeFormat (Intl.DateTimeFormat), format (DateTime Format Record 또는 DateTime Range Pattern Format Record), pattern (Pattern String), epochNanoseconds (BigInt)을 받아, 필드 [[Type]] (String)과 [[Value]] (String)을 가진 List를 반환한다. 이 연산은 patterndateTimeFormatformat의 유효 로케일과 서식 옵션에 따라 epoch 시간 epochNanoseconds에 대한 해당 파트를 생성한다. 호출 시 다음 단계를 수행한다:

  1. localedateTimeFormat.[[Locale]]로 둔다.
  2. nfOptionsOrdinaryObjectCreate(null)로 둔다.
  3. CreateDataPropertyOrThrow(nfOptions, "numberingSystem", dateTimeFormat.[[NumberingSystem]])를 수행한다.
  4. CreateDataPropertyOrThrow(nfOptions, "useGrouping", false)를 수행한다.
  5. nf를 ! Construct(%Intl.NumberFormat%, « locale, nfOptions »)로 둔다.
  6. nf2OptionsOrdinaryObjectCreate(null)로 둔다.
  7. CreateDataPropertyOrThrow(nf2Options, "minimumIntegerDigits", 2𝔽)를 수행한다.
  8. CreateDataPropertyOrThrow(nf2Options, "numberingSystem", dateTimeFormat.[[NumberingSystem]])를 수행한다.
  9. CreateDataPropertyOrThrow(nf2Options, "useGrouping", false)를 수행한다.
  10. nf2를 ! Construct(%Intl.NumberFormat%, « locale, nf2Options »)로 둔다.
  11. format[[fractionalSecondDigits]] 필드가 있으면,
    1. fractionalSecondDigitsformat.[[fractionalSecondDigits]]로 둔다.
    2. nf3OptionsOrdinaryObjectCreate(null)로 둔다.
    3. CreateDataPropertyOrThrow(nf3Options, "minimumIntegerDigits", 𝔽(fractionalSecondDigits))를 수행한다.
    4. CreateDataPropertyOrThrow(nf3Options, "numberingSystem", dateTimeFormat.[[NumberingSystem]])를 수행한다.
    5. CreateDataPropertyOrThrow(nf3Options, "useGrouping", false)를 수행한다.
    6. nf3를 ! Construct(%Intl.NumberFormat%, « locale, nf3Options »)로 둔다.
  12. tmToLocalTime(epochNanoseconds, dateTimeFormat.[[Calendar]], dateTimeFormat.[[TimeZone]])로 둔다.
  13. patternPartsPartitionPattern(pattern)로 둔다.
  14. result를 새로운 빈 List로 둔다.
  15. patternParts의 각 Record { [[Type]], [[Value]] } patternPart에 대해,
    1. ppatternPart.[[Type]]로 둔다.
    2. p"literal"이면,
      1. resultRecord { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }를 추가한다.
    3. 그 밖에 p"fractionalSecondDigits"이면,
      1. Assert: format[[fractionalSecondDigits]] 필드가 있다.
      2. vtm.[[Millisecond]]로 둔다.
      3. vfloor(v × 10( fractionalSecondDigits - 3 ))로 설정한다.
      4. fvFormatNumeric(nf3, v)로 둔다.
      5. resultRecord { [[Type]]: "fractionalSecond", [[Value]]: fv }를 추가한다.
    4. 그 밖에 p"dayPeriod"이면,
      1. Assert: format[[dayPeriod]] 필드가 있다.
      2. fformat.[[dayPeriod]]로 둔다.
      3. fvtm의 주기(day period)를 f에 지정된 형태로 나타내는 String 값으로 둔다. 이 값은 구현 및 dateTimeFormat의 유효 로케일에 따라 달라진다.
      4. resultRecord { [[Type]]: p, [[Value]]: fv }를 추가한다.
    5. 그 밖에 p"timeZoneName"이면,
      1. Assert: format[[timeZoneName]] 필드가 있다.
      2. fformat.[[timeZoneName]]로 둔다.
      3. vdateTimeFormat.[[TimeZone]]로 둔다.
      4. fvf에 지정된 형태로 v를 나타내는 String 값으로 둔다. 이 값은 구현 및 dateTimeFormat의 유효 로케일에 따라 달라진다. f"short", "long", "shortOffset", "longOffset"인 경우, 이 값은 tm[[InDST]] 값에 의존할 수도 있다. 구현에 f에 대한 지역화 표현이 없으면 v 자체의 String 값을 사용한다.
      5. resultRecord { [[Type]]: p, [[Value]]: fv }를 추가한다.
    6. 그 밖에 p표 16의 Property 열과 일치하면,
      1. Assert: format에 [[<p>]] 필드가 있다.
      2. fformat.[[<p>]]로 둔다.
      3. v를 일치하는 행의 Internal Slot 열 이름과 동일한 tm의 필드 값으로 둔다.
      4. p"year"이고 v ≤ 0이면 v를 1 - v로 설정한다.
      5. p"month"이면 vv + 1로 설정한다.
      6. p"hour"이고 dateTimeFormat.[[HourCycle]]"h11" 또는 "h12"이면,
        1. vv modulo 12로 설정한다.
        2. v가 0이고 dateTimeFormat.[[HourCycle]]"h12"이면 v를 12로 설정한다.
      7. p"hour"이고 dateTimeFormat.[[HourCycle]]"h24"이면,
        1. v가 0이면 v를 24로 설정한다.
      8. f"numeric"이면,
        1. fvFormatNumeric(nf, v)로 둔다.
      9. 그 밖에 f"2-digit"이면,
        1. fvFormatNumeric(nf2, v)로 둔다.
        2. codePointsStringToCodePoints(fv)로 둔다.
        3. countcodePoints의 원소 수로 둔다.
        4. count > 2이면,
          1. tenscodePoints[count - 2]로 둔다.
          2. onescodePoints[count - 1]로 둔다.
          3. fvCodePointsToStringtens, ones »)로 설정한다.
      10. 그 밖에 f"narrow", "short", "long"이면,
        1. fvf에 지정된 형태로 v를 나타내는 String 값으로 둔다. 이 값은 구현 및 dateTimeFormat의 유효 로케일과 달력에 따라 달라진다. p"month"이면, 이 값은 format.[[day]]의 존재 여부에도 의존할 수 있다. 구현에 지역화된 표현이 없으면 v 자체의 String 값을 사용한다.
      11. resultRecord { [[Type]]: p, [[Value]]: fv }를 추가한다.
    7. 그 밖에 p"ampm"이면,
      1. vtm.[[Hour]]로 둔다.
      2. v가 11보다 크면,
        1. fvILD String 값( "post meridiem" )으로 둔다.
      3. 그 밖에는,
        1. fvILD String 값( "ante meridiem" )으로 둔다.
      4. resultRecord { [[Type]]: "dayPeriod", [[Value]]: fv }를 추가한다.
    8. 그 밖에 p"relatedYear"이면,
      1. vtm.[[RelatedYear]]로 둔다.
      2. fvFormatNumeric(nf, v)로 둔다.
      3. resultRecord { [[Type]]: "relatedYear", [[Value]]: fv }를 추가한다.
    9. 그 밖에 p"yearName"이면,
      1. vtm.[[YearName]]로 둔다.
      2. fvILD String 값( v를 나타냄 )으로 둔다.
      3. resultRecord { [[Type]]: "yearName", [[Value]]: fv }를 추가한다.
    10. 그 밖에는,
      1. unknownepochNanosecondsp에 기반한 구현/로케일/숫자 체계 의존 String으로 둔다.
      2. resultRecord { [[Type]]: "unknown", [[Value]]: unknown }를 추가한다.
  16. result를 반환한다.
참고
구현에서는 Common Locale Data Repository(https://cldr.unicode.org/)가 제공하는 로케일 및 달력 의존 문자열을 사용하고, DateTimeFormat의 "short" 문자열에는 CLDR의 "abbreviated" 문자열을, "long" 문자열에는 CLDR의 "wide" 문자열을 사용하는 것이 권장된다.

11.5.6 PartitionDateTimePattern ( dateTimeFormat, x )

추상 연산 PartitionDateTimePattern은 인수 dateTimeFormat (Intl.DateTimeFormat)과 x (Number)를 받아, 정상 완료로 List (각 원소는 [[Type]] (String), [[Value]] (String) 필드를 가짐)을 포함하거나, throw 완료를 반환한다. xECMA-262, 21.4.1.1에 규정된 time value로 해석되며, dateTimeFormat의 유효 로케일과 서식 옵션에 따라 해당 파트를 생성한다. 호출 시 다음 단계를 수행한다:

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

11.5.7 FormatDateTime ( dateTimeFormat, x )

추상 연산 FormatDateTime은 인수 dateTimeFormat (Intl.DateTimeFormat)과 x (Number)를 받아, 정상 완료로 String을 포함하거나, throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

11.5.8 FormatDateTimeToParts ( dateTimeFormat, x )

추상 연산 FormatDateTimeToParts는 인수 dateTimeFormat (Intl.DateTimeFormat)과 x (Number)를 받아, 정상 완료로 Array를 포함하거나, throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

11.5.9 PartitionDateTimeRangePattern ( dateTimeFormat, x, y )

추상 연산 PartitionDateTimeRangePattern은 인수 dateTimeFormat (Intl.DateTimeFormat), x (Number), y (Number)를 받아, 정상 완료로 [[Type]] (String), [[Value]] (String), [[Source]] (String) 필드를 가진 List를 포함하거나, throw 완료를 반환한다. xyECMA-262, 21.4.1.1에 규정된 time values로 해석되며, dateTimeFormat의 유효 로케일과 서식 옵션에 따라 해당 파트를 생성한다. 호출 시 다음 단계를 수행한다:

  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"이면,
    1. patternformat.[[pattern12]]로 둔다.
    2. rangePatternsformat.[[rangePatterns12]]로 둔다.
  11. 그 밖에는,
    1. patternformat.[[pattern]]로 둔다.
    2. rangePatternsformat.[[rangePatterns]]로 둔다.
  12. selectedRangePatternundefined로 둔다.
  13. relevantFieldsEqualtrue로 둔다.
  14. checkMoreFieldstrue로 둔다.
  15. 표 6의 각 행(헤더 행 제외)을 표의 순서대로 순회하며, 다음을 수행한다:
    1. fieldName를 해당 행의 Field Name 열에 주어진 이름으로 둔다.
    2. rangePatterns에 이름이 fieldName인 필드가 있으면 rangePattern을 그 필드로, 없으면 rangePatternundefined로 둔다.
    3. selectedRangePatternundefined가 아니고 rangePatternundefined이면,
      1. 참고: 이 필드에서의 차이에 대한 범위 패턴이 없으므로, 더 이상의 검사는 수행되지 않는다.
      2. checkMoreFieldsfalse로 설정한다.
    4. fieldName[[Default]]와 같지 않고 relevantFieldsEqualtrue이며 checkMoreFieldstrue이면,
      1. selectedRangePatternrangePattern으로 설정한다.
      2. fieldName[[AmPm]]이면,
        1. tm1.[[Hour]]가 12보다 작으면 v1"am"으로, 그렇지 않으면 v1"pm"으로 둔다.
        2. tm2.[[Hour]]가 12보다 작으면 v2"am"으로, 그렇지 않으면 v2"pm"으로 둔다.
      3. 그 밖에 fieldName[[DayPeriod]]이면,
        1. v1tm1의 주기를 나타내는 String 값으로 둔다. 이 값은 구현 및 dateTimeFormat의 유효 로케일에 따라 달라진다.
        2. v2tm2의 주기를 나타내는 String 값으로 둔다. 이 값은 구현 및 dateTimeFormat의 유효 로케일에 따라 달라진다.
      4. 그 밖에 fieldName[[FractionalSecondDigits]]이면,
        1. format[[fractionalSecondDigits]] 필드가 있으면,
          1. fractionalSecondDigitsformat.[[fractionalSecondDigits]]로 둔다.
        2. 그 밖에는,
          1. fractionalSecondDigits를 3으로 둔다.
        3. expfractionalSecondDigits - 3으로 둔다.
        4. v1floor(tm1.[[Millisecond]] × 10exp)로 둔다.
        5. v2floor(tm2.[[Millisecond]] × 10exp)로 둔다.
      5. 그 밖에는,
        1. v1을 이름이 fieldNametm1의 필드 값으로 둔다.
        2. v2를 이름이 fieldNametm2의 필드 값으로 둔다.
      6. v1v2이면,
        1. relevantFieldsEqualfalse로 설정한다.
  16. relevantFieldsEqualtrue이면,
    1. collapsedResult를 새로운 빈 List로 둔다.
    2. resultPartsFormatDateTimePattern(dateTimeFormat, format, pattern, xEpochNanoseconds)로 둔다.
    3. resultParts의 각 Record { [[Type]], [[Value]] } r에 대해,
      1. collapsedResultRecord { [[Type]]: r.[[Type]], [[Value]]: r.[[Value]], [[Source]]: "shared" }를 추가한다.
    4. collapsedResult를 반환한다.
  17. rangeResult를 새로운 빈 List로 둔다.
  18. selectedRangePatternundefined이면,
    1. selectedRangePatternrangePatterns.[[Default]]로 설정한다.
  19. selectedRangePattern.[[PatternParts]]의 각 Record { [[Pattern]], [[Source]] } rangePatternPart에 대해,
    1. patternrangePatternPart.[[Pattern]]로 둔다.
    2. sourcerangePatternPart.[[Source]]로 둔다.
    3. source"startRange" 또는 "shared"이면,
      1. zxEpochNanoseconds로 둔다.
    4. 그 밖에는,
      1. zyEpochNanoseconds로 둔다.
    5. resultPartsFormatDateTimePattern(dateTimeFormat, selectedRangePattern, pattern, z)로 둔다.
    6. resultParts의 각 Record { [[Type]], [[Value]] } r에 대해,
      1. rangeResultRecord { [[Type]]: r.[[Type]], [[Value]]: r.[[Value]], [[Source]]: source }를 추가한다.
  20. rangeResult를 반환한다.

11.5.10 FormatDateTimeRange ( dateTimeFormat, x, y )

추상 연산 FormatDateTimeRange는 인수 dateTimeFormat (Intl.DateTimeFormat), x (Number), y (Number)를 받아, 정상 완료로 String을 포함하거나, throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

11.5.11 FormatDateTimeRangeToParts ( dateTimeFormat, x, y )

추상 연산 FormatDateTimeRangeToParts는 인수 dateTimeFormat (Intl.DateTimeFormat), x (Number), y (Number)를 받아, 정상 완료로 Array를 포함하거나, throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

11.5.12 ToLocalTime ( epochNs, calendar, timeZoneIdentifier )

구현 정의 추상 연산 ToLocalTime은 인수 epochNs (BigInt), calendar (String), timeZoneIdentifier (String)을 받아 ToLocalTime Record를 반환한다. 호출 시 다음 단계를 수행한다:

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

11.5.13 ToLocalTime 레코드

ToLocalTime Record 각각은 표 17에 정의된 필드를 가진다.

표 17: Record ( ToLocalTime이 반환 )
필드 이름 값 타입 그레고리력에 대한 값 계산
[[Weekday]] an integer (WeekDay(𝔽(floor(tz / 106))))
[[Era]] a String yearYearFromTime(𝔽(floor(tz / 106)))로 둔다. year < 1𝔽이면 "BC"를, 그 밖에는 "AD"를 반환한다.
[[Year]] an integer (YearFromTime(𝔽(floor(tz / 106))))
[[RelatedYear]] an integer or undefined undefined
[[YearName]] a String or undefined undefined
[[Month]] an integer (MonthFromTime(𝔽(floor(tz / 106))))
[[Day]] an integer (DateFromTime(𝔽(floor(tz / 106))))
[[Hour]] an integer (HourFromTime(𝔽(floor(tz / 106))))
[[Minute]] an integer (MinFromTime(𝔽(floor(tz / 106))))
[[Second]] an integer (SecFromTime(𝔽(floor(tz / 106))))
[[Millisecond]] an integer (msFromTime(𝔽(floor(tz / 106))))
[[InDST]] a Boolean UTC로부터의 표준시 오프셋과 일광 절약 시간제 규칙에 대한 IANA Time Zone Database의 최신 및 과거 정보를 포함하여, 지정된 calendartimeZoneIdentifier에 대한 가능한 최선의 정보를 사용해 true 또는 false를 계산한다.

11.5.14 UnwrapDateTimeFormat ( dtf )

추상 연산 UnwrapDateTimeFormat은 인수 dtf (ECMAScript 언어 값)을 받아, 정상 완료로 ECMAScript 언어 값을 포함하거나, throw 완료를 반환한다. 이 연산은 입력 객체에 대한 DateTimeFormat 인스턴스를 반환하며, 이는 값 자체이거나 %Intl.DateTimeFormat%의 규범적 선택적 생성자 모드(4.3 주 1)에 따라 그와 연관된 값이다. 호출 시 다음 단계를 수행한다:

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

12 DisplayNames 객체

12.1 Intl.DisplayNames 생성자

Intl.DisplayNames 생성자:

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

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

12.1.1 Intl.DisplayNames ( locales, options )

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

  1. NewTarget이 undefined이면, TypeError 예외를 던진다.
  2. displayNames를 ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.DisplayNames.prototype%", « [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[LanguageDisplay]], [[Fields]] »)로 둔다.
  3. optionsResolution을 ? ResolveOptions(%Intl.DisplayNames%, %Intl.DisplayNames%.[[LocaleData]], locales, options, « require-options »)로 둔다.
  4. optionsoptionsResolution.[[Options]]로 설정한다.
  5. 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"이면,
    1. displayNames.[[LanguageDisplay]]languageDisplay로 설정한다.
    2. typeFieldstypeFields.[[<languageDisplay>]]로 설정한다.
    3. Assert: typeFieldsRecord이다 (12.2.3 참조).
  21. styleFieldstypeFields.[[<style>]]로 둔다.
  22. Assert: styleFieldsRecord이다 (12.2.3 참조).
  23. displayNames.[[Fields]]styleFields로 설정한다.
  24. displayNames를 반환한다.

12.2 Intl.DisplayNames 생성자의 속성

Intl.DisplayNames 생성자:

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

12.2.1 Intl.DisplayNames.prototype

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

이 속성의 특성(attribute)은 { [[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여야 하며, 모든 표시 이름 타입의 이름을 가진 필드를 포함해야 한다: "language", "region", "script", "currency", "calendar", "dateTimeField".
  • "language" 필드의 값은 Record여야 하며, 유효한 언어 표시 중 하나의 이름을 가진 필드를 포함해야 한다: "dialect""standard".
  • 표시 이름 타입 "language" 아래의 언어 표시 필드는 유효한 표시 이름 스타일 중 하나의 이름을 가진 필드를 포함하는 Records여야 한다: "narrow", "short", "long".
  • "region", "script", "currency", "calendar", "dateTimeField" 필드의 값은 Records여야 하며, 모든 표시 이름 스타일의 이름을 가진 필드를 포함해야 한다: "narrow", "short", "long".
  • 표시 이름 타입 "language" 아래의 표시 이름 스타일 필드는 unicode_language_id가 매칭될 수 있는 언어 코드에 대응하는 키를 가진 Records를 포함해야 한다. 이 필드들의 값은 문자열이어야 한다.
  • 표시 이름 타입 "region" 아래의 표시 이름 스타일 필드는 지역 코드에 대응하는 키를 가진 Records를 포함해야 한다. 이 필드들의 값은 문자열이어야 한다.
  • 표시 이름 타입 "script" 아래의 표시 이름 스타일 필드는 스크립트 코드에 대응하는 키를 가진 Records를 포함해야 한다. 이 필드들의 값은 문자열이어야 한다.
  • 표시 이름 타입 "currency" 아래의 표시 이름 스타일 필드는 통화 코드에 대응하는 키를 가진 Records를 포함해야 한다. 이 필드들의 값은 문자열이어야 한다.
  • 표시 이름 타입 "calendar" 아래의 표시 이름 스타일 필드는 type Unicode 로케일 비단말에 매칭될 수 있는 달력 식별자에 대응하는 키를 가진 Records를 포함해야 한다. 이 필드들의 값은 문자열이어야 한다.
  • 표시 이름 타입 "dateTimeField" 아래의 표시 이름 스타일 필드는 Records를 포함해야 하며, 키는 표 19에 나열된 코드에 대응해야 한다. 이 필드들의 값은 문자열이어야 한다.
참고
구현에서는 가능하면 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. 표 18의 각 행(헤더 행 제외)을 표의 순서대로 순회하며, 다음을 수행한다:
    1. p를 현재 행의 Property 값으로 둔다.
    2. vdisplayNames의 현재 행의 Internal Slot 이름을 가진 내부 슬롯의 값으로 둔다.
    3. Assert: vundefined가 아니다.
    4. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  5. options를 반환한다.
표 18: DisplayNames 인스턴스의 해석된 옵션
Internal Slot Property
[[Locale]] "locale"
[[Style]] "style"
[[Type]] "type"
[[Fallback]] "fallback"
[[LanguageDisplay]] "languageDisplay"

12.3.3 Intl.DisplayNames.prototype.of ( code )

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

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

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

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

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

12.4 Intl.DisplayNames 인스턴스의 속성

Intl.DisplayNames 인스턴스는 일반 객체이며, %Intl.DisplayNames.prototype%로부터 속성을 상속받는다.

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

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

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

12.5 DisplayNames 객체를 위한 추상 연산

12.5.1 CanonicalCodeForDisplayNames ( type, code )

추상 연산 CanonicalCodeForDisplayNames는 인수 type (String)과 code (String)을 받아, 정상 완료로 String을 포함하거나 throw 완료를 반환한다. 이 연산은 type에 따라 code가 올바른 형식의 코드임을 검증하고, code의 케이스 정규화 형태를 반환한다. 호출 시 다음 단계를 수행한다:

  1. type"language"이면,
    1. codeunicode_language_id Unicode 로케일 비단말에 매칭되지 않으면, RangeError 예외를 던진다.
    2. IsStructurallyValidLanguageTag(code) 가 false이면, RangeError 예외를 던진다.
    3. CanonicalizeUnicodeLocaleId(code)를 반환한다.
  2. type"region"이면,
    1. codeunicode_region_subtag Unicode 로케일 비단말에 매칭되지 않으면, RangeError 예외를 던진다.
    2. codeASCII-대문자 형태를 반환한다.
  3. type"script"이면,
    1. codeunicode_script_subtag Unicode 로케일 비단말에 매칭되지 않으면, RangeError 예외를 던진다.
    2. Assert: code의 길이는 4이고, code의 모든 코드 유닛은 ASCII 문자(0x0041–0x005A 및 0x0061–0x007A)를 나타낸다.
    3. firstcode의 0부터 1까지 부분 문자열ASCII-대문자로 둔다.
    4. restcode의 1부터의 부분 문자열ASCII-소문자로 둔다.
    5. firstrest문자열 연결 결과를 반환한다.
  4. type"calendar"이면,
    1. codetype Unicode 로케일 비단말에 매칭되지 않으면, RangeError 예외를 던진다.
    2. codeUnicode Technical Standard #35 Part 1 Core, Section 3.3 BCP 47 Conformance에 기술된 하위 호환 문법을 사용하면, RangeError 예외를 던진다.
    3. codeASCII-소문자 형태를 반환한다.
  5. type"dateTimeField"이면,
    1. IsValidDateTimeFieldCode(code)의 결과가 false이면, RangeError 예외를 던진다.
    2. code를 반환한다.
  6. Assert: type"currency"이다.
  7. IsWellFormedCurrencyCode(code) 가 false이면, RangeError 예외를 던진다.
  8. codeASCII-대문자 형태를 반환한다.

12.5.2 IsValidDateTimeFieldCode ( field )

추상 연산 IsValidDateTimeFieldCode는 인수 field (String)를 받아 Boolean을 반환한다. 이 연산은 field 인수가 유효한 날짜-시간 필드 코드를 나타내는지 검증한다. 호출 시 다음 단계를 수행한다:

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

13 DurationFormat 객체

13.1 Intl.DurationFormat 생성자

Intl.DurationFormat 생성자:

  • %Intl.DurationFormat%이다.
  • "DurationFormat" 속성의 초기 값이며, Intl 객체에 해당한다.

Intl 객체서비스 생성자 속성에 공통적인 동작은 9.1에서 규정된다.

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

Intl.DurationFormat 함수가 선택적 인수 localesoptions와 함께 호출되면, 다음 단계를 수행한다:

  1. NewTarget이 undefined이면 TypeError 예외를 던진다.
  2. durationFormat을 ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.DurationFormatPrototype%", « [[InitializedDurationFormat]], [[Locale]], [[NumberingSystem]], [[Style]], [[YearsOptions]], [[MonthsOptions]], [[WeeksOptions]], [[DaysOptions]], [[HoursOptions]], [[MinutesOptions]], [[SecondsOptions]], [[MillisecondsOptions]], [[MicrosecondsOptions]], [[NanosecondsOptions]], [[HourMinuteSeparator]], [[MinuteSecondSeparator]], [[FractionalDigits]] »)로 둔다.
  3. optionsResolution을 ? ResolveOptions(%Intl.DurationFormat%, %Intl.DurationFormat%.[[LocaleData]], locales, options)로 둔다.
  4. optionsoptionsResolution.[[Options]]로 설정한다.
  5. 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. 표 20의 각 행(헤더 행 제외)을 표의 순서대로 순회하며, 다음을 수행한다:
    1. slot을 현재 행의 Internal Slot 값으로 둔다.
    2. unit을 현재 행의 Unit 값으로 둔다.
    3. styles을 현재 행의 Styles 값으로 둔다.
    4. digitalBase를 현재 행의 Digital Default 값으로 둔다.
    5. unitOptions을 ? GetDurationUnitOptions(unit, options, style, styles, digitalBase, prevStyle, digitalFormat.[[TwoDigitHours]])로 둔다.
    6. durationFormat의 내부 슬롯 중 이름이 slot인 슬롯의 값을 unitOptions로 설정한다.
    7. unit"hours", "minutes", "seconds", "milliseconds", "microseconds" 중 하나이면,
      1. prevStyleunitOptions.[[Style]]로 설정한다.
  16. durationFormat.[[FractionalDigits]]를 ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined)로 설정한다.
  17. durationFormat을 반환한다.
표 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 생성자:

  • [[Prototype]] 내부 슬롯을 가지며, 그 값은 %Function.prototype%이다.
  • 다음 속성들을 가진다:

13.2.1 Intl.DurationFormat.prototype

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

이 속성의 특성(attribute)은 { [[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>]]는 Record여야 하며, [[nu]][[DigitalFormat]] 필드를 가져야 한다.
  • [[LocaleData]].[[<locale>]].[[nu]]List여야 하며, 16.2.3에 명시된 바와 같고, "native", "traditio", "finance" 값은 포함하지 않아야 한다.
  • [[LocaleData]].[[<locale>]].[[DigitalFormat]]Record여야 하며, locale에 제공되는 각 숫자 체계에 대응하는 키를 가져야 한다. 각 값은 Record여야 하며, 다음 필드를 가져야 한다:
    • [[HourMinuteSeparator]]는 해당 로케일과 숫자 체계 조합에서 style이 "numeric" 또는 "2-digit"일 때 시간-분 사이에 사용되는 올바른 구분자 문자열이어야 한다.
    • [[MinuteSecondSeparator]]는 해당 로케일과 숫자 체계 조합에서 style이 "numeric" 또는 "2-digit"일 때 분-초 사이에 사용되는 올바른 구분자 문자열이어야 한다.
    • [[TwoDigitHours]]는 style이 "numeric"일 때 시간이 항상 두 자리로 표시되는지 여부를 나타내는 Boolean 값이어야 한다.
참고
구현에서는 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. 표 21의 각 행(헤더 행 제외)을 표의 순서대로 순회하며, 다음을 수행한다:
    1. p를 현재 행의 Property 값으로 둔다.
    2. vdf의 현재 행의 Internal Slot 이름을 가진 내부 슬롯의 값으로 둔다.
    3. vundefined가 아니면,
      1. 현재 행에 Conversion 값이 있으면 conversion을 해당 값으로, 없으면 conversionempty로 둔다.
      2. conversionnumber이면,
        1. v𝔽(v)로 설정한다.
      3. 그 밖에 conversionempty가 아니면,
        1. Assert: conversionstyle+display이고 vDuration Unit Options Record이다.
        2. 참고: v.[[Style]]p (복수 Temporal 단위) 이름의 속성으로 표현되고, v.[[Display]]p"Display"를 접미한 이름의 속성으로 표현된다.
        3. stylev.[[Style]]로 둔다.
        4. style"fractional"이면,
          1. Assert: IsFractionalSecondUnitName(p) 이 true이다.
          2. style"numeric"로 설정한다.
        5. CreateDataPropertyOrThrow(options, p, style)를 수행한다.
        6. p문자열 연결(p, "Display")의 결과로 설정한다.
        7. vv.[[Display]]로 설정한다.
      4. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  5. options를 반환한다.
표 21: DurationFormat 인스턴스의 해석된 옵션
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. parts의 각 Record { [[Type]], [[Value]], [[Unit]] } part에 대해,
    1. result문자열 연결(result, part.[[Value]]) 결과로 설정한다.
  7. result를 반환한다.

13.3.4 Intl.DurationFormat.prototype.formatToParts ( duration )

formatToParts 메서드가 duration 인수와 함께 호출되면, 다음 단계를 수행한다:

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

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

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

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

13.4 Intl.DurationFormat 인스턴스의 속성

Intl.DurationFormat 인스턴스는 %Intl.DurationFormat.prototype%로부터 속성을 상속받는다.

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

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

13.5 DurationFormat 객체를 위한 추상 연산

13.5.1 Duration Records

Duration Record는 기간(Duration)을 표현하는 데 사용되는 Record 값이다.

Duration Records는 표 22에 나열된 필드를 가진다.

표 22: Duration Record Fields
Field Meaning
[[Years]] 지속 시간의 연 수.
[[Months]] 지속 시간의 월 수.
[[Weeks]] 지속 시간의 주 수.
[[Days]] 지속 시간의 일 수.
[[Hours]] 지속 시간의 시 수.
[[Minutes]] 지속 시간의 분 수.
[[Seconds]] 지속 시간의 초 수.
[[Milliseconds]] 지속 시간의 밀리초 수.
[[Microseconds]] 지속 시간의 마이크로초 수.
[[Nanoseconds]] 지속 시간의 나노초 수.

13.5.2 ToIntegerIfIntegral ( argument )

추상 연산 ToIntegerIfIntegral은 인수 argument (ECMAScript 언어 값)을 받아, 정상 완료로 integer를 포함하거나, throw 완료를 반환한다. 이 연산은 argument를 그 Number 값을 나타내는 integer로 변환하거나, 그 값이 정수가 아닌 경우 RangeError를 던진다. 호출 시 다음 단계를 수행한다:

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

13.5.3 ToDurationRecord ( input )

추상 연산 ToDurationRecord는 인수 input (ECMAScript 언어 값)을 받아, 정상 완료로 Duration Record를 포함하거나, throw 완료를 반환한다. 이 연산은 기간을 나타내는 주어진 객체를 Duration Record로 변환한다. 호출 시 다음 단계를 수행한다:

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

13.5.4 DurationSign ( duration )

추상 연산 DurationSign은 인수 duration (Duration Record)을 받아 -1, 0, 또는 1을 반환한다. duration의 가장 의미 있는 0이 아닌 필드가 양수면 1, 음수면 -1을 반환한다. 모든 필드가 0이면 0을 반환한다. 호출 시 다음 단계를 수행한다:

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

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

추상 연산 IsValidDuration은 인수 years (integer), months (integer), weeks (integer), days (integer), hours (integer), minutes (integer), seconds (integer), milliseconds (integer), microseconds (integer), nanoseconds (integer)를 받아 Boolean을 반환한다. 인수들이 Duration Record를 구성하기 위한 유효한 입력이면 true, 그렇지 않으면 false를 반환한다. 호출 시 다음 단계를 수행한다:

  1. sign을 0으로 둔다.
  2. « years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds »의 각 값 v에 대해, 다음을 수행한다:
    1. 𝔽(v)가 finite가 아니면, false를 반환한다.
    2. v < 0 이면,
      1. sign > 0 이면 false를 반환한다.
      2. sign을 -1로 설정한다.
    3. 그 밖에 v > 0 이면,
      1. sign < 0 이면 false를 반환한다.
      2. sign을 1로 설정한다.
  3. abs(years) ≥ 232이면, false를 반환한다.
  4. abs(months) ≥ 232이면, false를 반환한다.
  5. abs(weeks) ≥ 232이면, false를 반환한다.
  6. normalizedSecondsdays × 86,400 + hours × 3600 + minutes × 60 + seconds + (𝔽(milliseconds)) × 10-3 + (𝔽(microseconds)) × 10-6 + (𝔽(nanoseconds)) × 10-9로 둔다.
  7. 참고: 위 단계는 부동소수점 산술을 직접 사용해 구현할 수 없다. milliseconds, microseconds, nanoseconds가 안전하지 않은 integer인 경우 10-3, 10-6, 10-9를 각각 곱하는 것은 부정확할 수 있다. 이 곱셈은 충분한 몫 비트를 갖는 std::remquo() 구현을 사용한 C++에서 구현할 수 있다. 또한 10의 거듭제곱을 곱하는 것이므로 문자열 조작으로도 정확한 결과를 얻을 수 있다.
  8. abs(normalizedSeconds) ≥ 253이면, false를 반환한다.
  9. true를 반환한다.

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

추상 연산 GetDurationUnitOptions는 인수 unit (String), options (Object), baseStyle (String), stylesList (Strings의 List), digitalBase (String), prevStyle (String), twoDigitHours (Boolean)을 받아 정상 완료로 Duration Unit Options Record를 포함하거나 throw 완료를 반환한다. 주어진 객체에서 임의의 unit에 대한 관련 옵션을 추출하여 Record로 반환한다. 호출 시 다음 단계를 수행한다:

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

13.5.6.1 Duration Unit Options Records

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

표 23: Duration Unit Options Record
Field Name Value Type
[[Style]] 표 20의 Styles 열 중 하나의 String
[[Display]] "auto" 또는 "always"

13.5.6.2 ValidateDurationUnitStyle ( unit, style, display, prevStyle )

추상 연산 ValidateDurationUnitStyle은 인수 unit (String), style (String), display (String), prevStyle (String)을 받아, 정상 완료로 unused를 반환하거나 throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

13.5.7 ComputeFractionalDigits ( durationFormat, duration )

추상 연산 ComputeFractionalDigits는 인수 durationFormat (DurationFormat 객체)과 duration (Duration Record)을 받아 수학적 값을 반환한다. 이 연산은 durationFormat에서 "fractional" 스타일을 사용하는 모든 단위의 값을, "fractional" 스타일을 사용하지 않는 가장 작은 단위의 분수로 표현하여 합산한다. 호출 시 다음 단계를 수행한다:

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

13.5.8 NextUnitFractional ( durationFormat, unit )

추상 연산 NextUnitFractional은 인수 durationFormat (DurationFormat 객체)과 unit (String)을 받아 Boolean을 반환한다. 다음으로 작은 단위가 "fractional" 스타일을 사용하면 true를 반환한다. 호출 시 다음 단계를 수행한다:

  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 )

추상 연산 FormatNumericHours는 인수 durationFormat (DurationFormat 객체), hoursValue (integer), signDisplayed (Boolean)을 받아 RecordsList를 반환한다. hoursValue는 시 수를 나타내는 integer이다. 이 연산은 유효 로케일과 durationFormat의 서식 옵션에 따라 hoursValue에 대한 파트를 생성한다. 호출 시 다음 단계를 수행한다:

  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"이면,
    1. CreateDataPropertyOrThrow(nfOpts, "minimumIntegerDigits", 2𝔽)를 수행한다.
  8. signDisplayedfalse이면,
    1. CreateDataPropertyOrThrow(nfOpts, "signDisplay", "never")를 수행한다.
  9. CreateDataPropertyOrThrow(nfOpts, "useGrouping", false)를 수행한다.
  10. nf를 ! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOpts »)로 둔다.
  11. hoursPartsPartitionNumberPattern(nf, hoursValue)로 둔다.
  12. hoursParts의 각 Record { [[Type]], [[Value]] } part에 대해,
    1. resultRecord { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: "hour" }를 추가한다.
  13. result를 반환한다.

13.5.10 FormatNumericMinutes ( durationFormat, minutesValue, hoursDisplayed, signDisplayed )

추상 연산 FormatNumericMinutes는 인수 durationFormat (DurationFormat 객체), minutesValue (integer), hoursDisplayed (Boolean), signDisplayed (Boolean)을 받아 RecordsList를 반환한다. minutesValue는 분 수를 나타내는 integer이다. 유효 로케일과 durationFormat의 서식 옵션에 따라 minutesValue에 대한 파트를 생성한다. 호출 시 다음 단계를 수행한다:

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

13.5.11 FormatNumericSeconds ( durationFormat, secondsValue, minutesDisplayed, signDisplayed )

추상 연산 FormatNumericSeconds는 인수 durationFormat (DurationFormat 객체), secondsValue (수학적 값), minutesDisplayed (Boolean), signDisplayed (Boolean)을 받아 RecordsList를 반환한다. secondsValue는 초 수를 나타내는 수학적 값이다. 유효 로케일과 durationFormat의 서식 옵션에 따라 secondsValue에 대한 파트를 생성한다. 호출 시 다음 단계를 수행한다:

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

13.5.12 FormatNumericUnits ( durationFormat, duration, firstNumericUnit, signDisplayed )

추상 연산 FormatNumericUnits는 인수 durationFormat (DurationFormat 객체), duration (Duration Record), firstNumericUnit (String), signDisplayed (Boolean)을 받아 RecordsList를 반환한다. 이 연산은 유효 로케일과 durationFormat의 서식 옵션에 따라, "numeric" 또는 "2-digit" 스타일을 사용하는 duration의 요소들을 나타내는 파트를 생성한다. 호출 시 다음 단계를 수행한다:

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

13.5.13 IsFractionalSecondUnitName ( unit )

추상 연산 IsFractionalSecondUnitName은 인수 unit (String)을 받아 Boolean을 반환한다. 호출 시 다음 단계를 수행한다:

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

13.5.14 ListFormatParts ( durationFormat, partitionedPartsList )

추상 연산 ListFormatParts는 인수 durationFormat (DurationFormat 객체)과 partitionedPartsList (ListsList로 구성된, RecordsList)을 받아 List를 반환한다. 이 연산은 유효 로케일과 durationFormat의 서식 옵션에 따라, partitionedPartsListLists의 파트에 대응하는 List를 생성한다.

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

13.5.15 PartitionDurationFormatPattern ( durationFormat, duration )

추상 연산 PartitionDurationFormatPattern은 인수 durationFormat (DurationFormat)과 duration (Duration Record)을 받아 List를 반환한다. 유효 로케일과 durationFormat의 서식 옵션에 따라 duration에 대응하는 파트를 생성한다. 호출 시 다음 단계를 수행한다:

  1. result를 새로운 빈 List로 둔다.
  2. signDisplayedtrue로 둔다.
  3. numericUnitFoundfalse로 둔다.
  4. numericUnitFoundfalse인 동안, 표 24의 각 행(헤더 행 제외)을 표 순서대로 반복한다:
    1. value를 현재 행의 Value Field 이름을 가진 duration의 필드 값으로 둔다.
    2. unitOptions를 현재 행의 Internal Slot 이름을 가진 durationFormat의 내부 슬롯 값으로 둔다.
    3. styleunitOptions.[[Style]]로 둔다.
    4. displayunitOptions.[[Display]]로 둔다.
    5. unit을 현재 행의 Unit 값으로 둔다.
    6. numberFormatUnit를 현재 행의 NumberFormat Unit 값으로 둔다.
    7. style"numeric" 또는 "2-digit"이면,
      1. numericPartsListFormatNumericUnits(durationFormat, duration, unit, signDisplayed)로 둔다.
      2. numericPartsList가 비어 있지 않으면, resultnumericPartsList를 추가한다.
      3. numericUnitFoundtrue로 설정한다.
    8. 그 밖에는,
      1. nfOptsOrdinaryObjectCreate(null)로 둔다.
      2. NextUnitFractional(durationFormat, unit)이 true이면,
        1. valuevalue + ComputeFractionalDigits(durationFormat, duration)로 설정한다.
        2. fractionDigitsdurationFormat.[[FractionalDigits]]로 둔다.
        3. fractionDigitsundefined이면,
          1. CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", 9𝔽)를 수행한다.
          2. CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", +0𝔽)를 수행한다.
        4. 그 밖에는,
          1. CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", fractionDigits)를 수행한다.
          2. CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", fractionDigits)를 수행한다.
        5. CreateDataPropertyOrThrow(nfOpts, "roundingMode", "trunc")를 수행한다.
        6. numericUnitFoundtrue로 설정한다.
      3. display"always"이거나 value ≠ 0이면,
        1. CreateDataPropertyOrThrow(nfOpts, "numberingSystem", durationFormat.[[NumberingSystem]])를 수행한다.
        2. signDisplayedtrue이면,
          1. signDisplayedfalse로 설정한다.
          2. value = 0이고 DurationSign(duration) = -1이면, valuenegative-zero로 설정한다.
        3. 그 밖에는,
          1. CreateDataPropertyOrThrow(nfOpts, "signDisplay", "never")를 수행한다.
        4. CreateDataPropertyOrThrow(nfOpts, "style", "unit")를 수행한다.
        5. CreateDataPropertyOrThrow(nfOpts, "unit", numberFormatUnit)를 수행한다.
        6. CreateDataPropertyOrThrow(nfOpts, "unitDisplay", style)를 수행한다.
        7. nf를 ! Construct(%Intl.NumberFormat%, « durationFormat.[[Locale]], nfOpts »)로 둔다.
        8. partsPartitionNumberPattern(nf, value)로 둔다.
        9. list를 새로운 빈 List로 둔다.
        10. parts의 각 Record { [[Type]], [[Value]] } part에 대해,
          1. listRecord { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: numberFormatUnit }를 추가한다.
        11. resultlist를 추가한다.
  5. ListFormatParts(durationFormat, result)를 반환한다.
표 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%이다.
  • "ListFormat" 속성의 초기 값이며, Intl 객체에 해당한다.

Intl 객체서비스 생성자 속성에 공통적인 동작은 9.1에서 규정된다.

14.1.1 Intl.ListFormat ( [ locales [ , options ] ] )

Intl.ListFormat 함수가 선택적 인수 localesoptions와 함께 호출되면, 다음 단계를 수행한다:

  1. NewTarget이 undefined이면, TypeError 예외를 던진다.
  2. listFormat을 ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.ListFormat.prototype%", « [[InitializedListFormat]], [[Locale]], [[Type]], [[Style]], [[Templates]] »)로 둔다.
  3. optionsResolution을 ? ResolveOptions(%Intl.ListFormat%, %Intl.ListFormat%.[[LocaleData]], locales, options)로 둔다.
  4. optionsoptionsResolution.[[Options]]로 설정한다.
  5. 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 생성자:

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

14.2.1 Intl.ListFormat.prototype

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

이 속성의 특성(attribute)은 { [[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]] 내부 슬롯의 값은 « »이다.

참고 1
Intl.ListFormat은 관련 확장 키를 가지지 않는다.

[[LocaleData]] 내부 슬롯의 값은 구현 정의이며, 9.1에 설명된 제약과 다음의 추가 제약을 각 로케일 값 locale에 대해 만족해야 한다. %Intl.ListFormat%.[[AvailableLocales]]에 포함된 각 로케일에 대해:

  • [[LocaleData]].[[<locale>]]는 세 개의 필드 [[conjunction]], [[disjunction]], [[unit]]를 가진 Record이다. 이들 각각은 세 가지 서식 스타일 이름 [[long]], [[short]], [[narrow]]의 필드를 가져야 하는 Record이어야 한다.
  • 이 필드 각각은 ListFormat 템플릿 집합으로 간주되며, [[Pair]], [[Start]], [[Middle]], [[End]]라는 이름의 필드를 가진 RecordsList여야 한다. 각 필드는 LDML List Format Rules에 규정된 템플릿 문자열이어야 한다. 각 템플릿 문자열은 "{0}""{1}" 부분 문자열을 정확히 한 번씩 포함해야 한다. 부분 문자열 "{0}"부분 문자열 "{1}"보다 앞에 나와야 한다.
참고 2
구현에서는 Common Locale Data Repository(https://cldr.unicode.org/)에서 제공하는 로케일 데이터를 사용하는 것이 권장된다. LDML의 listPattern에서, conjunction은 "standard"에, disjunction은 "or"에, unit은 "unit"에 대응한다.
참고 3
목록 타입 중에서 conjunction은 "and" 기반 목록(예: "A, B, and C")을, disjunction은 "or" 기반 목록(예: "A, B, or C")을, unit은 단위가 있는 값의 목록(예: "5 pounds, 12 ounces")을 의미한다.

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

Intl.ListFormat 프로토타입 객체:

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

14.3.1 Intl.ListFormat.prototype.constructor

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

14.3.2 Intl.ListFormat.prototype.resolvedOptions ( )

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

  1. lfthis 값으로 둔다.
  2. RequireInternalSlot(lf, [[InitializedListFormat]])를 수행한다.
  3. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  4. 표 25의 각 행(헤더 행 제외)을 표의 순서대로 순회하며, 다음을 수행한다:
    1. p를 현재 행의 Property 값으로 둔다.
    2. vlf의 현재 행의 Internal Slot 이름을 가진 내부 슬롯의 값으로 둔다.
    3. Assert: vundefined가 아니다.
    4. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  5. options를 반환한다.
표 25: ListFormat 인스턴스의 해석된 옵션
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"이다.

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

14.4 Intl.ListFormat 인스턴스의 속성

Intl.ListFormat 인스턴스는 %Intl.ListFormat.prototype%로부터 속성을 상속받는다.

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

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

  • [[Locale]]는 목록 서식 스타일에 사용되는 로케일의 String 값이며, 해당 로케일의 언어 태그를 가진다.
  • [[Type]]은 사용되는 목록 타입을 식별하는 문자열 값 "conjunction", "disjunction", "unit" 중 하나이다.
  • [[Style]]은 사용된 목록 서식 스타일을 식별하는 문자열 값 "long", "short", "narrow" 중 하나이다.
  • [[Templates]]ListFormat 템플릿 집합이다.

14.5 ListFormat 객체를 위한 추상 연산

14.5.1 DeconstructPattern ( pattern, placeables )

추상 연산 DeconstructPattern은 인수 pattern (Pattern String)과 placeables (Record)를 받아 List를 반환한다.

이 연산은 패턴 문자열을 파트들의 List로 분해한다.

placeables는 패턴 문자열에서 사용되는 치환 토큰들을 키로, 결과 List에서 해당 토큰 파트를 나타내기 위해 사용될 (PartitionPattern에서와 같은) 파트 Records를 값으로 가지는 Record이다. 예:

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

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

호출 시 다음 단계를 수행한다:

  1. patternPartsPartitionPattern(pattern)로 둔다.
  2. result를 새로운 빈 List로 둔다.
  3. patternParts의 각 Record { [[Type]], [[Value]] } patternPart에 대해,
    1. partpatternPart.[[Type]]로 둔다.
    2. part"literal"이면,
      1. resultRecord { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }를 추가한다.
    3. 그 밖에는,
      1. Assert: placeables는 [[<part>]] 필드를 가진다.
      2. substplaceables.[[<part>]]로 둔다.
      3. substList이면,
        1. subst의 각 요소 s에 대해,
          1. results를 추가한다.
      4. 그 밖에는,
        1. resultsubst를 추가한다.
  4. result를 반환한다.

14.5.2 CreatePartsFromList ( listFormat, list )

추상 연산 CreatePartsFromList는 인수 listFormat (Intl.ListFormat)과 list (Strings의 List)를 받아 List를 반환한다. 이 List는 Records로 구성되고 [[Type]] ("element" 또는 "literal")과 [[Value]] (String) 필드를 갖는다. 이 연산은 유효 로케일과 listFormat의 서식 옵션에 따라 해당 파트들의 List를 생성한다. 호출 시 다음 단계를 수행한다:

  1. sizelist의 요소 개수로 둔다.
  2. size가 0이면,
    1. 새로운 빈 List를 반환한다.
  3. size가 2이면,
    1. nlistFormat.[[Locale]], list[0], list[1]에 기반하여 listFormat.[[Templates]]의 인덱스로 둔다.
    2. patternlistFormat.[[Templates]][n].[[Pair]]로 둔다.
    3. firstRecord { [[Type]]: "element", [[Value]]: list[0] }로 둔다.
    4. secondRecord { [[Type]]: "element", [[Value]]: list[1] }로 둔다.
    5. placeablesRecord { [[0]]: first, [[1]]: second }로 둔다.
    6. DeconstructPattern(pattern, placeables)를 반환한다.
  4. lastRecord { [[Type]]: "element", [[Value]]: list[size - 1] }로 둔다.
  5. parts를 « last »로 둔다.
  6. isize - 2로 둔다.
  7. i ≥ 0 인 동안 반복한다,
    1. headRecord { [[Type]]: "element", [[Value]]: list[i] }로 둔다.
    2. n구현 정의 인덱스로 둔다. 이 인덱스는 listFormat.[[Locale]], head, parts에 기반하여 listFormat.[[Templates]]에서 선택된다.
    3. i가 0이면,
      1. patternlistFormat.[[Templates]][n].[[Start]]로 둔다.
    4. 그 밖에 isize - 2보다 작으면,
      1. patternlistFormat.[[Templates]][n].[[Middle]]로 둔다.
    5. 그 밖에는,
      1. patternlistFormat.[[Templates]][n].[[End]]로 둔다.
    6. placeablesRecord { [[0]]: head, [[1]]: parts }로 둔다.
    7. partsDeconstructPattern(pattern, placeables)로 설정한다.
    8. i를 1 감소시킨다.
  8. parts를 반환한다.
참고
여러 템플릿 중에서 선택하기 위한 인덱스 n을 두는 것은, 스페인어처럼 접속사가 문맥에 따라 달라질 수 있도록 한다. 예를 들어, 뒤따르는 단어에 따라 "y" 또는 "e"를 선택한다.

14.5.3 FormatList ( listFormat, list )

추상 연산 FormatList는 인수 listFormat (Intl.ListFormat)과 list (Strings의 List)를 받아 String을 반환한다. 호출 시 다음 단계를 수행한다:

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

14.5.4 FormatListToParts ( listFormat, list )

추상 연산 FormatListToParts는 인수 listFormat (Intl.ListFormat)과 list (Strings의 List)를 받아 Array를 반환한다. 호출 시 다음 단계를 수행한다:

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

14.5.5 StringListFromIterable ( iterable )

추상 연산 StringListFromIterable은 인수 iterable (ECMAScript 언어 값)을 받아 Strings의 List를 포함하는 정상 완료throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

  1. iterableundefined이면,
    1. 새로운 빈 List를 반환한다.
  2. iteratorRecord를 ? GetIterator(iterable, sync)로 둔다.
  3. list를 새로운 빈 List로 둔다.
  4. 반복한다,
    1. next를 ? IteratorStepValue(iteratorRecord)로 둔다.
    2. nextdone이면,
      1. list를 반환한다.
    3. nextString이 아니면,
      1. error를 새로 생성된 TypeError 객체로서의 ThrowCompletion로 둔다.
      2. IteratorClose(iteratorRecord, error)를 반환한다.
    4. listnext를 추가한다.
참고

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

15 Locale 객체

15.1 Intl.Locale 생성자

Intl.Locale 생성자:

  • %Intl.Locale%이다.
  • "Locale" 속성의 초기 값이며, Intl 객체에 해당한다.

15.1.1 Intl.Locale ( tag [ , options ] )

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

  1. NewTarget이 undefined이면, TypeError 예외를 던진다.
  2. localeExtensionKeys%Intl.Locale%.[[LocaleExtensionKeys]]로 둔다.
  3. internalSlotsList를 « [[InitializedLocale]], [[Locale]], [[Calendar]], [[Collation]], [[HourCycle]], [[NumberingSystem]] »로 둔다.
  4. localeExtensionKeys"kf"를 포함하면,
    1. [[CaseFirst]]internalSlotsList에 추가한다.
  5. localeExtensionKeys"kn"를 포함하면,
    1. [[Numeric]]internalSlotsList에 추가한다.
  6. locale를 ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.Locale.prototype%", internalSlotsList)로 둔다.
  7. tagString이 아니고, tagObject도 아니면, TypeError 예외를 던진다.
  8. tagObject이고 tag[[InitializedLocale]] 내부 슬롯이 있으면,
    1. tagtag.[[Locale]]로 둔다.
  9. 그 밖에는,
    1. tag를 ? ToString(tag)로 둔다.
  10. options를 ? CoerceOptionsToObject(options)로 설정한다.
  11. IsStructurallyValidLanguageTag(tag)가 false이면, RangeError 예외를 던진다.
  12. tagCanonicalizeUnicodeLocaleId(tag)로 설정한다.
  13. tag를 ? UpdateLanguageId(tag, options)로 설정한다.
  14. opt를 새로운 Record로 둔다.
  15. calendar를 ? GetOption(options, "calendar", string, empty, undefined)로 둔다.
  16. calendarundefined가 아니면,
    1. calendartype Unicode 로케일 비단말에 매칭될 수 없으면, RangeError 예외를 던진다.
  17. opt.[[ca]]calendar로 설정한다.
  18. collation을 ? GetOption(options, "collation", string, empty, undefined)으로 둔다.
  19. collationundefined가 아니면,
    1. collationtype Unicode 로케일 비단말에 매칭될 수 없으면, RangeError 예외를 던진다.
  20. opt.[[co]]collation으로 설정한다.
  21. hc를 ? GetOption(options, "hourCycle", string, « "h11", "h12", "h23", "h24" », undefined)로 둔다.
  22. opt.[[hc]]hc로 설정한다.
  23. kf를 ? GetOption(options, "caseFirst", string, « "upper", "lower", "false" », undefined)로 둔다.
  24. opt.[[kf]]kf로 설정한다.
  25. kn을 ? GetOption(options, "numeric", boolean, empty, undefined)으로 둔다.
  26. knundefined가 아니면, kn을 ! ToString(kn)으로 설정한다.
  27. opt.[[kn]]kn으로 설정한다.
  28. numberingSystem을 ? GetOption(options, "numberingSystem", string, empty, undefined)으로 둔다.
  29. numberingSystemundefined가 아니면,
    1. numberingSystemtype Unicode 로케일 비단말에 매칭될 수 없으면, RangeError 예외를 던진다.
  30. opt.[[nu]]numberingSystem으로 설정한다.
  31. rMakeLocaleRecord(tag, opt, localeExtensionKeys)로 둔다.
  32. locale.[[Locale]]r.[[locale]]로 설정한다.
  33. locale.[[Calendar]]r.[[ca]]로 설정한다.
  34. locale.[[Collation]]r.[[co]]로 설정한다.
  35. locale.[[HourCycle]]r.[[hc]]로 설정한다.
  36. localeExtensionKeys"kf"를 포함하면,
    1. locale.[[CaseFirst]]r.[[kf]]로 설정한다.
  37. localeExtensionKeys"kn"를 포함하면,
    1. SameValue(r.[[kn]], "true")가 true이거나 r.[[kn]]이 빈 문자열이면,
      1. locale.[[Numeric]]true로 설정한다.
    2. 그 밖에는,
      1. locale.[[Numeric]]false로 설정한다.
  38. locale.[[NumberingSystem]]r.[[nu]]로 설정한다.
  39. locale를 반환한다.

15.1.2 UpdateLanguageId ( tag, options )

추상 연산 UpdateLanguageId는 인수 tag (Unicode 정규화된 로케일 식별자)와 options (Object)을 받아, language tag를 포함하는 정상 완료throw 완료를 반환한다. 이 연산은 tagunicode_language_id subtagsoptions의 해당 프로퍼티로부터 업데이트하고, 구조적으로 유효하나 비정규화된 결과를 반환한다. 호출 시 다음 단계를 수행한다:

  1. baseNameGetLocaleBaseName(tag)로 둔다.
  2. language를 ? GetOption(options, "language", string, empty, GetLocaleLanguage(baseName))로 둔다.
  3. languageunicode_language_subtag Unicode 로케일 비단말에 매칭될 수 없으면, RangeError 예외를 던진다.
  4. script를 ? GetOption(options, "script", string, empty, GetLocaleScript(baseName))로 둔다.
  5. scriptundefined가 아니면,
    1. scriptunicode_script_subtag Unicode 로케일 비단말에 매칭될 수 없으면, RangeError 예외를 던진다.
  6. region을 ? GetOption(options, "region", string, empty, GetLocaleRegion(baseName))로 둔다.
  7. regionundefined가 아니면,
    1. regionunicode_region_subtag Unicode 로케일 비단말에 매칭될 수 없으면, RangeError 예외를 던진다.
  8. variants를 ? GetOption(options, "variants", string, empty, GetLocaleVariants(baseName))로 둔다.
  9. variantsundefined가 아니면,
    1. variants가 빈 문자열이면, RangeError 예외를 던진다.
    2. lowerVariantsvariantsASCII-소문자 형태로 둔다.
    3. variantSubtagsStringSplitToList(lowerVariants, "-")로 둔다.
    4. variantSubtags의 각 요소 variant에 대해,
      1. variantunicode_variant_subtag Unicode 로케일 비단말에 매칭될 수 없으면, RangeError 예외를 던진다.
    5. variantSubtags에 중복 요소가 있으면, RangeError 예외를 던진다.
  10. allExtensionstag에서 baseName 뒤의 접미사로 둔다.
  11. newTaglanguage로 둔다.
  12. scriptundefined가 아니면, newTag문자열 연결(newTag, "-", script)의 결과로 설정한다.
  13. regionundefined가 아니면, newTag문자열 연결(newTag, "-", region)의 결과로 설정한다.
  14. variantsundefined가 아니면, newTag문자열 연결(newTag, "-", variants)의 결과로 설정한다.
  15. newTag문자열 연결(newTag, allExtensions)의 결과로 설정한다.
  16. newTag를 반환한다.

15.1.3 MakeLocaleRecord ( tag, options, localeExtensionKeys )

추상 연산 MakeLocaleRecord는 인수 tag (language tag), options (Record), localeExtensionKeys (Strings의 List)를 받아 Record를 반환한다. 이 연산은 tagUnicode 로케일 확장 시퀀스에서 데이터를 가져오되 options의 해당 필드로 이를 재정의하여, localeExtensionKeys의 각 요소가 해당 필드를 정의하는 Record를 구성하고 반환한다. 또한 그 필드들을 tag에 반영하여 얻은 [[locale]] 필드(이는 Unicode 정규화된 로케일 식별자)를 포함해야 한다. 호출 시 다음 단계를 수행한다:

  1. tagsubstring으로 Unicode 로케일 확장 시퀀스가 포함되어 있으면,
    1. extensiontag 내의 Unicode 로케일 확장 시퀀스에 해당하는 substring의 String 값으로 둔다.
    2. componentsUnicodeExtensionComponents(extension)로 둔다.
    3. attributescomponents.[[Attributes]]로 둔다.
    4. keywordscomponents.[[Keywords]]로 둔다.
  2. 그 밖에는,
    1. attributes를 새로운 빈 List로 둔다.
    2. keywords를 새로운 빈 List로 둔다.
  3. result를 새로운 Record로 둔다.
  4. localeExtensionKeys의 각 요소 key에 대해,
    1. keywords[[Key]]key인 요소가 있으면,
      1. entrykeywords에서 [[Key]]key인 요소로 둔다.
      2. valueentry.[[Value]]로 둔다.
    2. 그 밖에는,
      1. entryempty로 둔다.
      2. valueundefined로 둔다.
    3. Assert: options에는 [[<key>]] 필드가 있다.
    4. overrideValueoptions.[[<key>]]로 둔다.
    5. overrideValueundefined가 아니면,
      1. valueCanonicalizeUValue(key, overrideValue)로 설정한다.
      2. entryempty가 아니면,
        1. entry.[[Value]]value로 설정한다.
      3. 그 밖에는,
        1. keywordsRecord { [[Key]]: key, [[Value]]: value }를 추가한다.
    6. result.[[<key>]]를 value로 설정한다.
  5. localetag에서 모든 Unicode 로케일 확장 시퀀스를 제거한 String 값으로 둔다.
  6. attributes가 비어 있지 않거나 keywords가 비어 있지 않으면,
    1. result.[[locale]]InsertUnicodeExtensionAndCanonicalize(locale, attributes, keywords)로 설정한다.
  7. 그 밖에는,
    1. result.[[locale]]CanonicalizeUnicodeLocaleId(locale)로 설정한다.
  8. result를 반환한다.

15.2 Intl.Locale 생성자의 속성

Intl.Locale 생성자:

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

15.2.1 Intl.Locale.prototype

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

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

15.2.2 내부 슬롯

[[LocaleExtensionKeys]] 내부 슬롯의 값은 List이며, 반드시 « "ca", "co", "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접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

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

15.3.3 get Intl.Locale.prototype.calendar

Intl.Locale.prototype.calendar접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

  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접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

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

15.3.5 get Intl.Locale.prototype.collation

Intl.Locale.prototype.collation접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

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

15.3.6 get Intl.Locale.prototype.hourCycle

Intl.Locale.prototype.hourCycle접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

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

15.3.7 get Intl.Locale.prototype.language

Intl.Locale.prototype.language접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

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

15.3.8 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.9 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.10 get Intl.Locale.prototype.numberingSystem

Intl.Locale.prototype.numberingSystem접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

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

15.3.11 get Intl.Locale.prototype.numeric

이 프로퍼티는 %Intl.Locale%.[[LocaleExtensionKeys]]"kn"를 포함하는 경우에만 존재한다.

Intl.Locale.prototype.numeric접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

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

15.3.12 get Intl.Locale.prototype.region

Intl.Locale.prototype.region접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

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

15.3.13 get Intl.Locale.prototype.script

Intl.Locale.prototype.script접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

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

15.3.14 Intl.Locale.prototype.toString ( )

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

15.3.15 get Intl.Locale.prototype.variants

Intl.Locale.prototype.variants접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

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

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

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

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

15.4 Intl.Locale 인스턴스의 속성

Intl.Locale 인스턴스는 일반 객체이며, %Intl.Locale.prototype%로부터 속성을 상속받는다.

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

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

  • [[Locale]]는 서식에 사용되는 로케일의 String 값이며, 해당 로케일의 언어 태그를 가진다.
  • [[Calendar]]undefined이거나, 정규형의 올바른 Unicode Calendar Identifier를 나타내는 String 값이다.
  • [[Collation]]undefined이거나, 정규형의 올바른 Unicode Collation Identifier를 나타내는 String 값이다.
  • [[HourCycle]]undefined이거나, 정규형의 올바른 Unicode Hour Cycle Identifier를 나타내는 String 값이다.
  • [[NumberingSystem]]undefined이거나, 정규형의 올바른 Unicode Number System Identifier를 나타내는 String 값이다.
  • [[CaseFirst]]undefined이거나 문자열 값 "upper", "lower", "false" 중 하나이다. 이 내부 슬롯은 %Intl.Locale%[[LocaleExtensionKeys]] 내부 슬롯에 "kf"가 포함되는 경우에만 존재한다.
  • [[Numeric]]undefined이거나, 로케일에서 숫자 정렬 사용 여부를 지정하는 Boolean 값이다. 이 내부 슬롯은 %Intl.Locale%[[LocaleExtensionKeys]] 내부 슬롯에 "kn"가 포함되는 경우에만 존재한다.

15.5 Locale 객체를 위한 추상 연산

15.5.1 GetLocaleBaseName ( locale )

추상 연산 GetLocaleBaseName은 인수 locale (String)을 받아 String을 반환한다. 호출 시 다음 단계를 수행한다:

  1. Assert: localeunicode_locale_id Unicode 로케일 비단말에 매칭될 수 있다.
  2. locale에서 unicode_language_id Unicode 로케일 비단말에 매칭되는 가장 긴 접두사를 반환한다.

15.5.2 GetLocaleLanguage ( locale )

추상 연산 GetLocaleLanguage는 인수 locale (String)을 받아 String을 반환한다. 호출 시 다음 단계를 수행한다:

  1. baseNameGetLocaleBaseName(locale)로 둔다.
  2. Assert: baseName의 첫 번째 subtagunicode_language_subtag Unicode 로케일 비단말에 매칭될 수 있다.
  3. baseName의 첫 번째 subtag를 반환한다.

15.5.3 GetLocaleScript ( locale )

추상 연산 GetLocaleScript는 인수 locale (String)을 받아 String 또는 undefined를 반환한다. 호출 시 다음 단계를 수행한다:

  1. baseNameGetLocaleBaseName(locale)로 둔다.
  2. Assert: baseName에는 unicode_script_subtag Unicode 로케일 비단말에 매칭될 수 있는 subtag가 최대 하나만 존재한다.
  3. baseNameunicode_script_subtag Unicode 로케일 비단말에 매칭되는 subtag가 있으면, 그 subtag를 반환한다.
  4. undefined를 반환한다.

15.5.4 GetLocaleRegion ( locale )

추상 연산 GetLocaleRegion은 인수 locale (String)을 받아 String 또는 undefined를 반환한다. 호출 시 다음 단계를 수행한다:

  1. baseNameGetLocaleBaseName(locale)로 둔다.
  2. 참고: unicode_region_subtag subtag는 초기 unicode_language_subtag subtag 바로 뒤에서만 유효하며, 그 사이에 단 하나의 unicode_script_subtag subtag가 있을 수 있다. 이 위치에서 unicode_region_subtag는 다른 유효한 subtag들과 혼동될 수 없는데, 그 생산 규칙들이 서로 소(disjoint)하기 때문이다.
  3. Assert: baseName의 첫 번째 subtagunicode_language_subtag Unicode 로케일 비단말에 매칭될 수 있다.
  4. baseNameTailbaseName의 첫 번째 subtag 뒤의 접미사로 둔다.
  5. Assert: baseNameTail에는 unicode_region_subtag Unicode 로케일 비단말에 매칭될 수 있는 subtag가 최대 하나만 존재한다.
  6. baseNameTailunicode_region_subtag Unicode 로케일 비단말에 매칭되는 subtag가 있으면, 그 subtag를 반환한다.
  7. undefined를 반환한다.

15.5.5 GetLocaleVariants ( locale )

추상 연산 GetLocaleVariants는 인수 locale (String)을 받아 String 또는 undefined를 반환한다. 호출 시 다음 단계를 수행한다:

  1. baseNameGetLocaleBaseName(locale)로 둔다.
  2. 참고: baseName에서 "-"로 시작하는 각 subtagunicode_script_subtag, unicode_region_subtag, 또는 unicode_variant_subtag 중 하나이지만, unicode_variant_subtag에 매칭되는 어떤 substring도 다른 생산 규칙으로 매칭될 수 있는 그 어떤 접두사보다 항상 더 길다.
  3. variantsbaseName의 접미사 중, "-"로 시작하고 이어지는 substringunicode_variant_subtag Unicode 로케일 비단말에 매칭되는 가장 긴 접미사로 둔다. 그러한 접미사가 없으면 undefined를 반환한다.
  4. variants의 1부터의 부분 문자열을 반환한다.

16 NumberFormat 객체

16.1 Intl.NumberFormat 생성자

Intl.NumberFormat 생성자:

  • %Intl.NumberFormat%이다.
  • "NumberFormat" 속성의 초기 값이며, Intl 객체에 해당한다.

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"이면,
    1. currencynumberFormat.[[Currency]]로 둔다.
    2. cDigitsCurrencyDigits(currency)로 둔다.
    3. mnfdDefaultcDigits로 둔다.
    4. mxfdDefaultcDigits로 둔다.
  14. 그 밖에는,
    1. mnfdDefault를 0으로 둔다.
    2. style"percent"이면,
      1. mxfdDefault를 0으로 둔다.
    3. 그 밖에는,
      1. mxfdDefault를 3으로 둔다.
  15. SetNumberFormatDigitOptions(numberFormat, options, mnfdDefault, mxfdDefault, notation)를 수행한다.
  16. compactDisplay를 ? GetOption(options, "compactDisplay", string, « "short", "long" », "short")로 둔다.
  17. defaultUseGrouping"auto"로 둔다.
  18. notation"compact"이면,
    1. numberFormat.[[CompactDisplay]]compactDisplay로 설정한다.
    2. defaultUseGrouping"min2"로 설정한다.
  19. 참고: 역사적 이유로, 문자열 "true""false"는 허용되며 기본값으로 대체된다.
  20. useGrouping을 ? GetBooleanOrStringNumberFormatOption(options, "useGrouping", « "min2", "auto", "always", "true", "false" », defaultUseGrouping)로 둔다.
  21. useGrouping"true" 또는 useGrouping"false"이면, useGroupingdefaultUseGrouping으로 설정한다.
  22. useGroupingtrue이면, useGrouping"always"로 설정한다.
  23. numberFormat.[[UseGrouping]]useGrouping으로 설정한다.
  24. signDisplay를 ? GetOption(options, "signDisplay", string, « "auto", "never", "always", "exceptZero", "negative" », "auto")로 둔다.
  25. numberFormat.[[SignDisplay]]signDisplay로 설정한다.
  26. 구현이 생성자의 규범적 선택 사양 4.3 참고 1을 지원하면,
    1. thisthis 값으로 둔다.
    2. ChainNumberFormat(numberFormat, NewTarget, this)를 반환한다.
  27. numberFormat을 반환한다.

16.1.1.1 ChainNumberFormat ( numberFormat, newTarget, this )

추상 연산 ChainNumberFormat은 인수 numberFormat (Intl.NumberFormat), newTarget (ECMAScript 언어 값), this (ECMAScript 언어 값)를 받아, 정상 완료로 Object나 throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

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

추상 연산 SetNumberFormatDigitOptions는 인수 intlObj (Object), options (Object), mnfdDefault (integer), mxfdDefault (integer), notation (String)을 받아 정상 완료unused 또는 throw 완료를 반환한다. 이 연산은 intlObj의 로케일 독립적 숫자 반올림에 영향을 주는 내부 슬롯을 채운다(16.5.3 참조). 호출 시 다음 단계를 수행한다:

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

16.1.3 SetNumberFormatUnitOptions ( intlObj, options )

추상 연산 SetNumberFormatUnitOptions는 인수 intlObj (Intl.NumberFormat), options (Object)를 받아, 정상 완료unused 또는 throw 완료를 반환한다. 이 연산은 단위 관련 사용자 지정 옵션을 intlObj에 반영한다. 호출 시 다음 단계를 수행한다:

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

16.2 Intl.NumberFormat 생성자의 속성

Intl.NumberFormat 생성자:

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

16.2.1 Intl.NumberFormat.prototype

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

이 속성의 특성(attribute)은 { [[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" } »이다.

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

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 참고 1을 지원하면,
    1. nf를 ? UnwrapNumberFormat(nf)로 둔다.
  3. RequireInternalSlot(nf, [[InitializedNumberFormat]])를 수행한다.
  4. optionsOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  5. 표 26의 각 행(헤더 행 제외)을 표의 순서대로 순회하며, 다음을 수행한다:
    1. p를 현재 행의 Property 값으로 둔다.
    2. vnf의 현재 행의 Internal Slot 이름을 가진 내부 슬롯의 값으로 둔다.
    3. vundefined가 아니면,
      1. 현재 행에 Conversion 값이 있으면,
        1. Assert: 현재 행의 Conversion 값은 number이다.
        2. v𝔽(v)로 설정한다.
      2. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  6. options를 반환한다.
표 26: NumberFormat 인스턴스의 해석된 옵션
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은 접근자 프로퍼티이며, 설정 접근자 함수는 undefined이다. 그 가져오기 접근자 함수는 다음 단계를 수행한다:

  1. nfthis 값으로 둔다.
  2. 구현이 생성자의 규범적 선택 사양 4.3 참고 1을 지원하면,
    1. nf를 ? UnwrapNumberFormat(nf)로 둔다.
  3. RequireInternalSlot(nf, [[InitializedNumberFormat]])를 수행한다.
  4. nf.[[BoundFormat]]undefined이면,
    1. F를 Number Format Functions (16.5.2)에 정의된 새 내장 함수 객체로 둔다.
    2. F.[[NumberFormat]]nf로 설정한다.
    3. nf.[[BoundFormat]]F로 설정한다.
  5. nf.[[BoundFormat]]를 반환한다.
참고
반환된 함수는 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 예외를 던진다.
  4. x를 ? ToIntlMathematicalValue(start)로 둔다.
  5. y를 ? ToIntlMathematicalValue(end)로 둔다.
  6. FormatNumericRange(nf, x, y)를 반환한다.

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

formatRangeToParts 메서드가 startend 인수로 호출되면, 다음 단계를 수행한다:

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

16.3.6 Intl.NumberFormat.prototype.formatToParts ( value )

formatToParts 메서드가 선택적 인수 value로 호출되면, 다음 단계를 수행한다:

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

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

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

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

16.4 Intl.NumberFormat 인스턴스의 속성

Intl.NumberFormat 인스턴스는 일반 객체이며, %Intl.NumberFormat.prototype%로부터 속성을 상속받는다.

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

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

  • [[Locale]] String 값이며, 서식에 사용되는 로케일의 언어 태그를 가진다.
  • [[LocaleData]]는 서식에 대해 구현체가 사용할 수 있는 데이터를 나타내는 Record이다. 이는 %Intl.NumberFormat%.[[LocaleData]]에서 [[Locale]] 값이나 그 접두사에 해당하는 엔트리의 값이다.
  • [[NumberingSystem]] String 값으로, 서식에 사용되는 Unicode Number System Identifier를 나타낸다.
  • [[Style]]"decimal", "currency", "percent", "unit" 중 하나의 문자열 값이며, 측정되는 양의 타입을 식별한다.
  • [[Currency]] String 값으로, "currency" 단위 타입으로 서식화할 때 사용할 통화를 식별하는 통화 코드이다. [[Style]]"currency"일 때만 사용된다.
  • [[CurrencyDisplay]]"code", "symbol", "narrowSymbol", "name" 중 하나의 문자열 값이며, "currency" 스타일로 서식화할 때 통화를 ISO 4217 알파벳 통화 코드, 로케일화된 통화 기호, 또는 로케일화된 통화 이름으로 표시할지 지정한다. [[Style]]"currency"일 때만 사용된다.
  • [[CurrencySign]]"standard" 또는 "accounting" 중 하나의 문자열 값이며, 음수를 회계 방식(종종 괄호로 표시)으로 렌더링할지 여부를 지정한다. [[Style]]"currency"이고 [[SignDisplay]]"never"가 아닐 때만 사용된다.
  • [[Unit]]core unit identifier이다. [[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]]는 보여줄 최소/최대 유효 자릿수를 나타내는 양수 정수이다. 지정된 유효 자릿수를 표시하는 데 필요한 만큼의 소수 자릿수를 사용한다. 이 속성은 [[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" 중 하나의 문자열 값으로, 서식화된 숫자를 스케일링 없이, 과학적 표기법으로 십의 제곱수로, 엔지니어링 표기법으로 천 단위로 십의 제곱수로, 또는 ILD compact decimal notation 십의 제곱수로 compact decimal notation 접미사와 함께 표시할지 지정한다.
  • [[CompactDisplay]]"short" 또는 "long" 중 하나의 문자열 값으로, "compact" 표기법으로 서식화할 때 compact notation 접미사를 짧게("5K") 또는 길게("5천") 표시할지 지정한다. [[Notation]]"compact"일 때만 사용된다.
  • [[SignDisplay]]"auto", "always", "never", "exceptZero", "negative" 중 하나의 문자열 값으로, 부호를 언제 포함할지 지정한다(각 옵션은 항상, 절대 안 함, 0이 아닐 때만, 음수이면서 0이 아닐 때만 포함됨에 대응). 과학적 표기법에서는 이 슬롯이 맨티사의 부호 표시에는 영향을 주지만 지수에는 영향을 주지 않는다.
  • [[RoundingIncrement]]는 10, 100, 1000 또는 10000을 10분의 1, 5분의 1, 4분의 1, 2분의 1로 정수로 나눌 수 있는 정수이다. 이는 반올림을 계산된 반올림 크기에서 얼마 단위로 할지 지정한다. 예를 들어, [[MaximumFractionDigits]]가 2이고 [[RoundingIncrement]]가 5면, 숫자는 소수점 두 자리에서 0.05 단위로 반올림된다("nickel rounding").
  • [[RoundingMode]]반올림 모드이며, 표 27의 Identifier 열에 나오는 문자열 값 중 하나이다.
  • [[TrailingZeroDisplay]]"auto" 또는 "stripIfInteger" 중 하나의 문자열 값으로, 서식화된 숫자가 정수(즉, 0이 아닌 소수 자릿수가 없음)일 때 끝의 0을 제거할지 여부를 지정한다.
표 27: Intl.NumberFormat의 반올림 모드
Identifier 설명 예시: 소수 자릿수 0으로 반올림
-1.5 0.4 0.5 0.6 1.5
"ceil" 양의 무한대 방향으로 ⬆️ [-1] ⬆️ [1] ⬆️ [1] ⬆️ [1] ⬆️ [2]
"floor" 음의 무한대 방향으로 ⬇️ [-2] ⬇️ [0] ⬇️ [0] ⬇️ [0] ⬇️ [1]
"expand" 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]
참고
예시는 각 옵션의 독특한 동작을 보여주기 위한 것이다. ⬆️는 "양의 무한대로"를 의미하고, ⬇️는 "음의 무한대로"를 의미한다.

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

16.5 NumberFormat 객체를 위한 추상 연산

16.5.1 CurrencyDigits ( currency )

구현 정의 추상 연산 CurrencyDigits는 인수 currency (문자열)를 받아 음이 아닌 정수를 반환한다. 호출 시 다음 단계를 수행한다:

  1. Assert: IsWellFormedCurrencyCode(currency) 가 true임을 보장한다.
  2. currency에 해당하는 통화의 양을 서식화할 때 사용되는 소수 자릿수 개수를 나타내는 음이 아닌 정수를 반환한다. 사용할 자릿수 정보가 없으면 2를 반환한다.

16.5.2 숫자 서식 함수(Number Format Functions)

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

숫자 서식 함수 F가 선택적 인수 value로 호출되면, 다음 단계를 수행한다:

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

숫자 서식 함수의 "length" 속성은 1𝔽이다.

16.5.3 FormatNumericToString ( intlObject, x )

추상 연산 FormatNumericToString은 인수 intlObject (객체)와 x (수학적 값 또는 negative-zero)를 받아, [[RoundedNumber]] (수학적 값 또는 negative-zero)와 [[FormattedString]] (문자열) 필드를 가진 Record를 반환한다. xintlObject의 내부 슬롯에 따라 Intl 수학적 값으로 반올림한다. [[RoundedNumber]] 필드는 반올림된 값, [[FormattedString]] 필드는 해당 값을 intlObject의 내부 슬롯에 따라 서식화한 문자열 표현을 담는다. 호출 시 다음 단계를 수행한다:

  1. Assert: intlObject[[RoundingMode]], [[RoundingType]], [[MinimumSignificantDigits]], [[MaximumSignificantDigits]], [[MinimumIntegerDigits]], [[MinimumFractionDigits]], [[MaximumFractionDigits]], [[RoundingIncrement]], [[TrailingZeroDisplay]] 내부 슬롯을 가진다.
  2. xnegative-zero이면,
    1. signnegative로 둔다.
    2. x를 0으로 설정한다.
  3. 그 밖에는,
    1. Assert: x수학적 값임을 보장한다.
    2. x < 0이면 signnegative로, 아니면 positive로 둔다.
    3. signnegative이면,
      1. x를 -x로 설정한다.
  4. unsignedRoundingModeGetUnsignedRoundingMode(intlObject.[[RoundingMode]], sign)로 둔다.
  5. intlObject.[[RoundingType]]significant-digits이면,
    1. resultToRawPrecision(x, intlObject.[[MinimumSignificantDigits]], intlObject.[[MaximumSignificantDigits]], unsignedRoundingMode)로 둔다.
  6. 그 밖에 intlObject.[[RoundingType]]fraction-digits이면,
    1. resultToRawFixed(x, intlObject.[[MinimumFractionDigits]], intlObject.[[MaximumFractionDigits]], intlObject.[[RoundingIncrement]], unsignedRoundingMode)로 둔다.
  7. 그 밖에는,
    1. sResultToRawPrecision(x, intlObject.[[MinimumSignificantDigits]], intlObject.[[MaximumSignificantDigits]], unsignedRoundingMode)로 둔다.
    2. fResultToRawFixed(x, intlObject.[[MinimumFractionDigits]], intlObject.[[MaximumFractionDigits]], intlObject.[[RoundingIncrement]], unsignedRoundingMode)로 둔다.
    3. fResult.[[RoundingMagnitude]] < sResult.[[RoundingMagnitude]]이면, fixedIsMorePrecisetrue로, 아니면 false로 둔다.
    4. intlObject.[[RoundingType]]more-precision이고 fixedIsMorePrecisetrue이면,
      1. resultfResult로 둔다.
    5. 그 밖에 intlObject.[[RoundingType]]less-precision이고 fixedIsMorePrecisefalse이면,
      1. resultfResult로 둔다.
    6. 그 밖에는,
      1. resultsResult로 둔다.
  8. xresult.[[RoundedNumber]]로 설정한다.
  9. stringresult.[[FormattedString]]로 둔다.
  10. intlObject.[[TrailingZeroDisplay]]"stripIfInteger"이고 x modulo 1 = 0이면,
    1. iStringIndexOf(string, ".", 0)로 둔다.
    2. inot-found가 아니면, stringstring의 0부터 i까지의 부분 문자열로 설정한다.
  11. intresult.[[IntegerDigitsCount]]로 둔다.
  12. minIntegerintlObject.[[MinimumIntegerDigits]]로 둔다.
  13. int < minInteger이면,
    1. forwardZerosminInteger - int만큼 0x0030(DIGIT ZERO) 코드 유닛이 반복된 문자열로 둔다.
    2. string문자열 연결(forwardZeros, string)로 설정한다.
  14. signnegative이면,
    1. x가 0이면 xnegative-zero로, 아니면 x를 -x로 설정한다.
  15. Record { [[RoundedNumber]]: x, [[FormattedString]]: string }를 반환한다.

16.5.4 PartitionNumberPattern ( numberFormat, x )

추상 연산 PartitionNumberPattern은 인수 numberFormat (초기화된 NumberFormat 객체)과 x (Intl 수학적 값)를 받아, x수학적 값을 유효 로케일과 numberFormat의 서식 옵션에 따라 나타내는 [[Type]] (문자열) 및 [[Value]] (문자열) 필드를 가진 List를 반환한다. 호출 시 다음 단계를 수행한다:

  1. exponent를 0으로 둔다.
  2. xnot-a-number이면,
    1. nILD 문자열 값으로, NaN 값을 나타낸다.
  3. 그 밖에 xpositive-infinity이면,
    1. nILD 문자열 값으로, 양의 무한대를 나타낸다.
  4. 그 밖에 xnegative-infinity이면,
    1. nILD 문자열 값으로, 음의 무한대를 나타낸다.
  5. 그 밖에는,
    1. xnegative-zero가 아니면,
      1. Assert: x수학적 값임을 보장한다.
      2. numberFormat.[[Style]]"percent"이면, x를 100 × x로 설정한다.
      3. exponentComputeExponent(numberFormat, x)로 설정한다.
      4. xx × 10-exponent로 설정한다.
    2. formatNumberResultFormatNumericToString(numberFormat, x)로 둔다.
    3. nformatNumberResult.[[FormattedString]]로 둔다.
    4. xformatNumberResult.[[RoundedNumber]]로 설정한다.
  6. patternGetNumberFormatPattern(numberFormat, x)로 둔다.
  7. result를 새로운 빈 List로 둔다.
  8. patternPartsPartitionPattern(pattern)로 둔다.
  9. patternParts의 각 Record { [[Type]], [[Value]] } patternPart에 대해,
    1. ppatternPart.[[Type]]로 둔다.
    2. p"literal"이면,
      1. resultRecord { [[Type]]: "literal", [[Value]]: patternPart.[[Value]] }를 추가한다.
    3. 그 밖에 p"number"이면,
      1. notationSubPartsPartitionNotationSubPattern(numberFormat, x, n, exponent)로 둔다.
      2. result리스트 연결(result, notationSubParts)로 설정한다.
    4. 그 밖에 p"plusSign"이면,
      1. plusSignSymbolILND 문자열로, 플러스 기호를 나타낸다.
      2. resultRecord { [[Type]]: "plusSign", [[Value]]: plusSignSymbol }를 추가한다.
    5. 그 밖에 p"minusSign"이면,
      1. minusSignSymbolILND 문자열로, 마이너스 기호를 나타낸다.
      2. resultRecord { [[Type]]: "minusSign", [[Value]]: minusSignSymbol }를 추가한다.
    6. 그 밖에 p"percentSign"이고 numberFormat.[[Style]]"percent"이면,
      1. percentSignSymbolILND 문자열로, 퍼센트 기호를 나타낸다.
      2. resultRecord { [[Type]]: "percentSign", [[Value]]: percentSignSymbol } 를 추가한다.
    7. 그 밖에 p"unitPrefix"이고 numberFormat.[[Style]]"unit"이면,
      1. unitnumberFormat.[[Unit]]로 둔다.
      2. unitDisplaynumberFormat.[[UnitDisplay]]로 둔다.
      3. muILD 문자열 값으로, unitDisplay 형태의 unitx 앞에 위치하며, 복수형이 다른 언어의 경우 x에 따라 달라질 수 있다.
      4. resultRecord { [[Type]]: "unit", [[Value]]: mu }를 추가한다.
    8. 그 밖에 p"unitSuffix"이고 numberFormat.[[Style]]"unit"이면,
      1. unitnumberFormat.[[Unit]]로 둔다.
      2. unitDisplaynumberFormat.[[UnitDisplay]]로 둔다.
      3. muILD 문자열 값으로, unitDisplay 형태의 unitx 뒤에 위치하며, 복수형이 다른 언어의 경우 x에 따라 달라질 수 있다.
      4. resultRecord { [[Type]]: "unit", [[Value]]: mu }를 추가한다.
    9. 그 밖에 p"currencyCode"이고 numberFormat.[[Style]]"currency"이면,
      1. currencynumberFormat.[[Currency]]로 둔다.
      2. cdcurrency로 둔다.
      3. resultRecord { [[Type]]: "currency", [[Value]]: cd }를 추가한다.
    10. 그 밖에 p"currencyPrefix"이고 numberFormat.[[Style]]"currency"이면,
      1. currencynumberFormat.[[Currency]]로 둔다.
      2. currencyDisplaynumberFormat.[[CurrencyDisplay]]로 둔다.
      3. cdILD 문자열 값으로, currencyDisplay 형태의 currencyx 앞에 위치하며, 복수형이 다른 언어의 경우 x에 따라 달라질 수 있다.
      4. resultRecord { [[Type]]: "currency", [[Value]]: cd }를 추가한다.
    11. 그 밖에 p"currencySuffix"이고 numberFormat.[[Style]]"currency"이면,
      1. currencynumberFormat.[[Currency]]로 둔다.
      2. currencyDisplaynumberFormat.[[CurrencyDisplay]]로 둔다.
      3. cdILD 문자열 값으로, currencyDisplay 형태의 currencyx 뒤에 위치하며, 복수형이 다른 언어의 경우 x에 따라 달라질 수 있다. 구현에 해당 표현이 없으면 currency 자체를 사용한다.
      4. resultRecord { [[Type]]: "currency", [[Value]]: cd }를 추가한다.
    12. 그 밖에는,
      1. unknownILND xp에 기반한 문자열로 둔다.
      2. resultRecord { [[Type]]: "unknown", [[Value]]: unknown }를 추가한다.
  10. result를 반환한다.

16.5.5 PartitionNotationSubPattern ( numberFormat, x, n, exponent )

추상 연산 PartitionNotationSubPattern은 인수 numberFormat (Intl.NumberFormat), x (Intl 수학적 값), n (문자열), exponent (정수)를 받아 List를 반환한다. 이 List는 Records로 구성되고 [[Type]] (문자열), [[Value]] (문자열) 필드를 갖는다. x는 반올림이 적용된 Intl 수학적 값이며, n은 중간 서식 문자열이다. 이 연산은 유효 로케일과 numberFormat의 서식 옵션에 따라 숫자 및 표기법에 대한 파트를 생성한다. 호출 시 다음 단계를 수행한다:

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

16.5.6 FormatNumeric ( numberFormat, x )

추상 연산 FormatNumeric은 인수 numberFormat (Intl.NumberFormat 객체)와 x (Intl 수학적 값)를 받아 문자열을 반환한다. 호출 시 다음 단계를 수행한다:

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

16.5.7 FormatNumericToParts ( numberFormat, x )

추상 연산 FormatNumericToParts는 인수 numberFormat (Intl.NumberFormat 객체)와 x (Intl 수학적 값)를 받아 배열을 반환한다. 호출 시 다음 단계를 수행한다:

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

16.5.8 ToRawPrecision ( x, minPrecision, maxPrecision, unsignedRoundingMode )

추상 연산 ToRawPrecision은 인수 x (음이 아닌 수학적 값), minPrecision (정수, 1~21 범위), maxPrecision (정수, 1~21 범위), unsignedRoundingMode (표29의 Unsigned Rounding Mode 열 값 또는 undefined)를 받아 Record를 반환한다. 이 Record는 [[FormattedString]] (문자열), [[RoundedNumber]] (수학적 값), [[IntegerDigitsCount]] (정수), [[RoundingMagnitude]] (정수) 필드를 가진다.

다음 식을 풀어 유효한 수학적 값을 반환한다 (정수 입력):

ToRawPrecisionFn(n, e, p) = n × 10ep+1
여기서 10p–1n < 10p

호출 시 다음 단계를 수행한다:

  1. pmaxPrecision으로 둔다.
  2. x = 0이면,
    1. mp번 0x0030(DIGIT ZERO) 코드 유닛으로 이루어진 문자열로 둔다.
    2. e를 0으로 둔다.
    3. xFinal을 0으로 둔다.
  3. 그 밖에는,
    1. n1, e1를 각각 정수로, r1수학적 값으로 둔다. r1 = ToRawPrecisionFn(n1, e1, p)이며, r1x이고 r1이 최대가 되도록 한다.
    2. n2, e2를 각각 정수로, r2수학적 값으로 둔다. r2 = ToRawPrecisionFn(n2, e2, p)이며, r2x이고 r2가 최소가 되도록 한다.
    3. xFinalApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode)로 둔다.
    4. xFinalr1이면,
      1. nn1로 둔다.
      2. ee1로 둔다.
    5. 그 밖에는,
      1. nn2로 둔다.
      2. ee2로 둔다.
    6. mn의 10진수 표현의 각 자릿수(앞의 0 없음)로 이루어진 문자열로 둔다.
  4. e ≥ (p - 1)이면,
    1. m문자열 연결(m, e - p + 1번 0x0030(DIGIT ZERO))로 설정한다.
    2. inte + 1로 둔다.
  5. 그 밖에 e ≥ 0이면,
    1. m문자열 연결(m의 앞 e + 1 코드 유닛, 0x002E(FULL STOP), m의 나머지 p - (e + 1) 코드 유닛)로 설정한다.
    2. inte + 1로 둔다.
  6. 그 밖에는,
    1. Assert: e < 0.
    2. m문자열 연결("0.", -(e + 1)번 0x0030(DIGIT ZERO), m)로 설정한다.
    3. int를 1로 둔다.
  7. m에 0x002E(FULL STOP)가 포함되어 있고 maxPrecision > minPrecision이면,
    1. cutmaxPrecision - minPrecision로 둔다.
    2. cut > 0이고 m의 마지막 코드 유닛이 0x0030(DIGIT ZERO)인 동안 반복한다,
      1. m의 마지막 코드 유닛을 제거한다.
      2. cutcut - 1로 설정한다.
    3. m의 마지막 코드 유닛이 0x002E(FULL STOP)이면,
      1. 마지막 코드 유닛을 제거한다.
  8. Record { [[FormattedString]]: m, [[RoundedNumber]]: xFinal, [[IntegerDigitsCount]]: int, [[RoundingMagnitude]]: ep+1 }를 반환한다.

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

추상 연산 ToRawFixed는 인수 x (음이 아닌 수학적 값), minFraction (정수, 0~100 범위), maxFraction (정수, 0~100 범위), roundingIncrement (정수), unsignedRoundingMode (표29의 Unsigned Rounding Mode 열 값 또는 undefined)를 받아 Record를 반환한다. 이 Record는 [[FormattedString]] (문자열), [[RoundedNumber]] (수학적 값), [[IntegerDigitsCount]] (정수), [[RoundingMagnitude]] (정수) 필드를 가진다.

다음 식을 풀어 유효한 수학적 값을 반환한다 (정수 입력):

ToRawFixedFn(n, f) = n × 10f

호출 시 다음 단계를 수행한다:

  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. xFinalApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode)로 둔다.
  5. xFinalr1이면 nn1로, 아니면 nn2로 둔다.
  6. n = 0이면 m"0"로, 아니면 mn의 10진수 표현 각 자릿수(앞의 0 없음) 문자열로 둔다.
  7. f ≠ 0이면,
    1. km의 길이로 둔다.
    2. kf이면,
      1. zf + 1 - k번 0x0030(DIGIT ZERO) 코드 유닛으로 이루어진 문자열로 둔다.
      2. m문자열 연결(z, m)로 설정한다.
      3. kf + 1로 둔다.
    3. am의 앞 k - f 코드 유닛, b를 나머지 f 코드 유닛으로 둔다.
    4. m문자열 연결(a, ".", b)로 설정한다.
    5. inta의 길이로 둔다.
  8. 그 밖에는,
    1. intm의 길이로 둔다.
  9. cutmaxFraction - minFraction로 둔다.
  10. cut > 0이고 m의 마지막 코드 유닛이 0x0030(DIGIT ZERO)인 동안 반복한다,
    1. 마지막 코드 유닛을 m에서 제거한다.
    2. cutcut - 1로 설정한다.
  11. m의 마지막 코드 유닛이 0x002E(FULL STOP)이면,
    1. 마지막 코드 유닛을 m에서 제거한다.
  12. Record { [[FormattedString]]: m, [[RoundedNumber]]: xFinal, [[IntegerDigitsCount]]: int, [[RoundingMagnitude]]: –f }를 반환한다.
규범적 선택 사양

16.5.10 UnwrapNumberFormat ( nf )

추상 연산 UnwrapNumberFormat은 인수 nf (ECMAScript 언어 값)를 받아 정상 완료ECMAScript 언어 값를 반환하거나 throw 완료를 반환한다. 입력 객체의 NumberFormat 인스턴스를 반환하는데, 이는 값 자체이거나 %Intl.NumberFormat%생성자의 규범적 선택 사양(4.3 참고 1)에 따라 연결한 값이다. 호출 시 다음 단계를 수행한다:

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

16.5.11 GetNumberFormatPattern ( numberFormat, x )

추상 연산 GetNumberFormatPattern은 인수 numberFormat (Intl.NumberFormat)과 x (Intl 수학적 값)를 받아 문자열을 반환한다. 이 연산은 numberFormat 객체의 최종 단위 관련 옵션들과 서식화되는 최종 스케일 및 반올림된 숫자(Intl 수학적 값)를 고려하여, 16.2.3에서 설명된 패턴(문자열 값)을 반환한다. 호출 시 다음 단계를 수행한다:

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

16.5.12 GetNotationSubPattern ( numberFormat, exponent )

추상 연산 GetNotationSubPattern은 인수 numberFormat (Intl.NumberFormat)과 exponent (정수)를 받아 문자열을 반환한다. 이 연산은 해석된 notation과 exponent를 고려하여, 16.2.3에서 설명된 notation sub pattern용 문자열 값을 반환한다. 호출 시 다음 단계를 수행한다:

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

16.5.13 ComputeExponent ( numberFormat, x )

추상 연산 ComputeExponent는 인수 numberFormat (Intl.NumberFormat)과 x (수학적 값)를 받아 정수를 반환한다. 이 연산은 numberFormat 설정에 따라 x를 스케일링할 때 사용할 지수(십의 거듭제곱)를 계산한다. 999가 반올림되어 1000이 되는 경우 등, 다른 지수가 필요한 경우도 처리한다. 호출 시 다음 단계를 수행한다:

  1. x = 0이면,
    1. 0을 반환한다.
  2. x < 0이면,
    1. x = -x로 설정한다.
  3. magnitudex의 10을 밑으로 한 로그의 소수점 버림값(정수)으로 둔다.
  4. exponentComputeExponentForMagnitude(numberFormat, magnitude)로 둔다.
  5. xx × 10-exponent로 설정한다.
  6. formatNumberResultFormatNumericToString(numberFormat, x)로 둔다.
  7. formatNumberResult.[[RoundedNumber]] = 0이면,
    1. exponent를 반환한다.
  8. newMagnitudeformatNumberResult.[[RoundedNumber]]의 10을 밑으로 한 로그의 소수점 버림값(정수)으로 둔다.
  9. newMagnitudemagnitude - exponent이면,
    1. exponent를 반환한다.
  10. ComputeExponentForMagnitude(numberFormat, magnitude + 1)을 반환한다.

16.5.14 ComputeExponentForMagnitude ( numberFormat, magnitude )

추상 연산 ComputeExponentForMagnitude는 인수 numberFormat (Intl.NumberFormat)과 magnitude (정수)를 받아 정수를 반환한다. 이 연산은 로케일과 지정된 표기법(과학적, 엔지니어링, compact)에 따라, 가장 높은 자릿수의 십의 거듭제곱(magnitude)을 가진 숫자를 스케일링할 때 쓸 지수를 계산한다. 호출 시 다음 단계를 수행한다:

  1. notationnumberFormat.[[Notation]]로 둔다.
  2. notation"standard"이면,
    1. 0을 반환한다.
  3. 그 밖에 notation"scientific"이면,
    1. magnitude를 반환한다.
  4. 그 밖에 notation"engineering"이면,
    1. thousandsmagnitude / 3을 넘지 않는 최대 정수로 둔다.
    2. thousands × 3을 반환한다.
  5. 그 밖에는,
    1. Assert: notation"compact"임.
    2. exponent를 현재 로케일의 compact 표기법에서 주어진 magnitude에 대해 스케일하는 데 사용할 ILD 정수로 둔다.
    3. exponent를 반환한다.

16.5.15 Runtime Semantics: StringIntlMV

구문 지향 연산 StringIntlMV는 인수를 받지 않는다.

참고

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

다음 생성식에 대해 조각별로 정의된다:

StringNumericLiteral ::: StrWhiteSpaceopt
  1. 0을 반환한다.
StringNumericLiteral ::: StrWhiteSpaceopt StrNumericLiteral StrWhiteSpaceopt
  1. StrNumericLiteralStringIntlMV를 반환한다.
StrNumericLiteral ::: NonDecimalIntegerLiteral
  1. NonDecimalIntegerLiteral의 MV를 반환한다.
StrDecimalLiteral ::: - StrUnsignedDecimalLiteral
  1. aStringIntlMV of StrUnsignedDecimalLiteral로 둔다.
  2. a가 0이면 negative-zero를 반환한다.
  3. apositive-infinity이면 negative-infinity를 반환한다.
  4. -a를 반환한다.
StrUnsignedDecimalLiteral ::: Infinity
  1. positive-infinity를 반환한다.
StrUnsignedDecimalLiteral ::: DecimalDigits . DecimalDigitsopt ExponentPartopt
  1. a를 첫 번째 DecimalDigits의 MV로 둔다.
  2. 두 번째 DecimalDigits가 있으면,
    1. b를 두 번째 DecimalDigits의 MV로 둔다.
    2. n을 두 번째 DecimalDigits의 코드 포인트 개수로 둔다.
  3. 그 밖에는,
    1. b를 0으로 둔다.
    2. n을 0으로 둔다.
  4. ExponentPart가 있으면 e를 MV로, 없으면 e를 0으로 둔다.
  5. (a + (b × 10-n)) × 10e를 반환한다.
StrUnsignedDecimalLiteral ::: . DecimalDigits ExponentPartopt
  1. bDecimalDigits의 MV로 둔다.
  2. ExponentPart가 있으면 e를 MV로, 없으면 e를 0으로 둔다.
  3. nDecimalDigits의 코드 포인트 개수로 둔다.
  4. b × 10e - n를 반환한다.
StrUnsignedDecimalLiteral ::: DecimalDigits ExponentPartopt
  1. aDecimalDigits의 MV로 둔다.
  2. ExponentPart가 있으면 e를 MV로, 없으면 e를 0으로 둔다.
  3. a × 10e를 반환한다.

16.5.16 ToIntlMathematicalValue ( value )

추상 연산 ToIntlMathematicalValue는 인수 value (ECMAScript 언어 값)를 받아 정상 완료Intl 수학적 값 또는 throw 완료를 반환한다. 이 연산은 valueIntl 수학적 값으로 변환하여 반환한다. 이 값은 수학적 값positive-infinity, negative-infinity, not-a-number, negative-zero를 포함한다. 이 추상 연산은 7.1.3과 유사하지만, Number나 BigInt 대신 수학적 값을 반환할 수 있어서 정확한 소수 값을 표현할 수 있다. 호출 시 다음 단계를 수행한다:

  1. primValue를 ? ToPrimitive(value, number)로 둔다.
  2. primValueBigInt이면, (primValue)를 반환한다.
  3. primValue문자열이면,
    1. strprimValue로 둔다.
  4. 그 밖에는,
    1. x를 ? ToNumber(primValue)로 둔다.
    2. x-0𝔽이면, negative-zero를 반환한다.
    3. strNumber::toString(x, 10)으로 둔다.
  5. textStringToCodePoints(str)로 둔다.
  6. literalParseText(text, StringNumericLiteral)로 둔다.
  7. literal오류 리스트면, not-a-number를 반환한다.
  8. intlMVStringIntlMV(literal)로 둔다.
  9. intlMV수학적 값이면,
    1. roundedRoundMVResult(abs(intlMV))로 둔다.
    2. rounded+∞𝔽이고 intlMV < 0이면, negative-infinity를 반환한다.
    3. rounded+∞𝔽이면, positive-infinity를 반환한다.
    4. rounded+0𝔽이고 intlMV < 0이면, negative-zero를 반환한다.
    5. rounded+0𝔽이면, 0을 반환한다.
  10. intlMV를 반환한다.

16.5.17 GetUnsignedRoundingMode ( roundingMode, sign )

추상 연산 GetUnsignedRoundingMode는 인수 roundingMode (반올림 모드)와 sign (negative 또는 positive)를 받아 표29의 Unsigned Rounding Mode 열의 명세 타입을 반환한다. 이 연산은 절대값에 적용할 반올림 모드를 반환하여, roundingMode가 부호값에 적용될 때와 동일한 결과를 얻을 수 있게 한다 (음수면 negative, 아니면 양수). 호출 시 다음 단계를 수행한다:

  1. roundingMode 값이 Identifier 열, sign 값이 Sign 열인 행의 Unsigned Rounding Mode 열의 명세 타입을 표29에서 반환한다.
표 29: 반올림 모드에서 unsigned 반올림 모드로의 변환
Identifier Sign Unsigned Rounding Mode
"ceil" positive infinity
negative zero
"floor" positive zero
negative infinity
"expand" positive infinity
negative infinity
"trunc" positive zero
negative zero
"halfCeil" positive half-infinity
negative half-zero
"halfFloor" positive half-zero
negative half-infinity
"halfExpand" positive half-infinity
negative half-infinity
"halfTrunc" positive half-zero
negative half-zero
"halfEven" positive half-even
negative half-even

16.5.18 ApplyUnsignedRoundingMode ( x, r1, r2, unsignedRoundingMode )

추상 연산 ApplyUnsignedRoundingMode는 인수 x (수학적 값), r1 (수학적 값), r2 (수학적 값), unsignedRoundingMode (표29의 Unsigned Rounding Mode 열의 명세 타입 또는 undefined)를 받아 수학적 값를 반환한다. xr1r2 사이에 있고, unsignedRoundingMode에 따라 r1 또는 r2를 반환한다. 호출 시 다음 단계를 수행한다:

  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 )

추상 연산 PartitionNumberRangePattern은 인수 numberFormat (Intl.NumberFormat), x (Intl 수학적 값), y (Intl 수학적 값)를 받아 정상 완료List (필드: [[Type]] 문자열, [[Value]] 문자열, [[Source]] 문자열) 또는 throw 완료를 반환한다. 이 연산은 x, y, numberFormat의 서식 옵션에 따라 지역화된 숫자 범위 파트를 생성한다. 호출 시 다음 단계를 수행한다:

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

16.5.20 FormatApproximately ( numberFormat, result )

추상 연산 FormatApproximately는 인수 numberFormat (Intl.NumberFormat), result (List로서 각 원소는 [[Type]][[Value]] 문자열 필드를 가진 Record)를 받아 List를 반환한다. 이 연산은 PartitionNumberPattern에서 기술된 Record 리스트 result를 수정하여, 약자 기호용 Record를 추가한다(이 기호는 numberFormat에 따라 달라질 수 있다). 호출 시 다음 단계를 수행한다:

  1. approximatelySignILND 문자열 값으로, 약자임을 표시한다.
  2. approximatelySign이 비어 있지 않으면, Record { [[Type]]: "approximatelySign", [[Value]]: approximatelySign }를 ILND 인덱스에 result에 삽입한다. 예를 들어 numberFormat[[Locale]]"en-US", [[NumberingSystem]]"latn", [[Style]]"decimal"이면, 새 Recordresult의 첫 번째 원소 앞에 삽입될 수 있다.
  3. result를 반환한다.

16.5.21 CollapseNumberRange ( numberFormat, result )

구현 정의 추상 연산 CollapseNumberRange는 numberFormat (Intl.NumberFormat)과 result (List로, 각 원소는 Record이고 [[Type]] (문자열), [[Value]] (문자열), [[Source]] (문자열) 필드를 가진다)를 인수로 받아 List를 반환한다. 반환되는 List는 Record로 구성되며 [[Type]], [[Value]], [[Source]] 필드를 가진다. 이 연산은 result (List, Record로, PartitionNumberRangePattern에서 생성) 를 유효 로케일과 numberFormat의 서식 옵션에 따라 수정한다. 수정 방식은 중복 정보 제거, 내부 불일치 해결, 필요한 경우 문자 대체 및 공백 삽입 등이다. 그리고 수정된 List를 반환한다. 알고리즘은 ILND이지만, Intl.NumberFormat.prototype.formatRange ( start, end )를 호출할 때, List « start1, end1 »와 « start2, end2 »가 CollapseNumberRange의 trivial 구현(항상 result를 그대로 반환)에서 같지 않은 경우 결과가 같아지는 모호성을 만들어서는 안 된다.

예를 들어, 구현체는 range separator 뒤의 통화 기호를 나타내는 Record를 제거해서, results List"$3–$5"를 나타내던 것을 "$3–5"로 바꿀 수 있다.

또한, 구현체는 문법적 올바름을 위해 Record[[Value]] 필드를 수정할 수 있다. 예, results List"0.5 miles–1 mile"을 나타내던 것을 "0.5–1 miles"로 바꿀 수 있다.

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

16.5.22 FormatNumericRange ( numberFormat, x, y )

추상 연산 FormatNumericRange는 numberFormat (Intl.NumberFormat), x (Intl 수학적 값), y (Intl 수학적 값)를 인수로 받아 정상 완료로 문자열 또는 throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

16.5.23 FormatNumericRangeToParts ( numberFormat, x, y )

추상 연산 FormatNumericRangeToParts는 numberFormat (Intl.NumberFormat), x (Intl 수학적 값), y (Intl 수학적 값)를 인수로 받아 정상 완료로 배열 또는 throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

  1. parts를 ? PartitionNumberRangePattern(numberFormat, x, y)로 둔다.
  2. result를 ! ArrayCreate(0)로 둔다.
  3. n을 0으로 둔다.
  4. parts의 각 원소 part에 대해,
    1. OOrdinaryObjectCreate(%Object.prototype%)로 둔다.
    2. CreateDataPropertyOrThrow(O, "type", part.[[Type]])를 수행한다.
    3. CreateDataPropertyOrThrow(O, "value", part.[[Value]])를 수행한다.
    4. CreateDataPropertyOrThrow(O, "source", part.[[Source]])를 수행한다.
    5. CreateDataPropertyOrThrow(result, ! ToString(𝔽(n)), O)를 수행한다.
    6. n을 1 증가시킨다.
  5. result를 반환한다.

17 PluralRules 객체

17.1 Intl.PluralRules 생성자

Intl.PluralRules 생성자:

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

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

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

Intl.PluralRules 함수가 선택적 인수 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. pluralRules.[[CompactDisplay]]compactDisplay로 설정한다.
  13. SetNumberFormatDigitOptions(pluralRules, options, 0, 3, notation)를 수행한다.
  14. pluralRules를 반환한다.

17.2 Intl.PluralRules 생성자의 속성

Intl.PluralRules 생성자:

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

17.2.1 Intl.PluralRules.prototype

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

이 속성의 특성(attribute)은 { [[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]] 내부 슬롯의 값은 « »이다.

참고 1
Unicode Technical Standard #35 Part 1 Core, Section 3.6.1 Key and Type Definitions에서는 복수 처리에 관련된 로케일 확장 키가 정의되어 있지 않다.

[[LocaleData]] 내부 슬롯의 값은 구현 정의이며, 9.1에 설명된 제약 내에 있어야 한다.

참고 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. pluralCategoriesList로 두고, 선택된 로케일 pr.[[Locale]]에 대해 PluralRuleSelect의 모든 가능한 결과를 포함하며, 다음 순서대로 정렬한다: "zero", "one", "two", "few", "many", "other".
  5. 표 30의 각 행(헤더 제외)을 표의 순서대로 순회하며, 다음을 수행한다:
    1. p를 현재 행의 Property 값으로 둔다.
    2. p"pluralCategories"이면,
      1. vCreateArrayFromList(pluralCategories)로 둔다.
    3. 그 밖에는,
      1. vpr의 현재 행의 Internal Slot 이름을 가진 내부 슬롯 값으로 둔다.
    4. vundefined가 아니면,
      1. 현재 행에 Conversion 값이 있으면,
        1. Assert: 현재 행의 Conversion 값은 number이다.
        2. v𝔽(v)로 설정한다.
      2. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  6. options를 반환한다.
표 30: PluralRules 인스턴스의 해석된 옵션
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을 ? ToNumber(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를 ? ToNumber(start)로 둔다.
  5. y를 ? ToNumber(end)로 둔다.
  6. ResolvePluralRange(pr, x, y)를 반환한다.

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

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

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

17.4 Intl.PluralRules 인스턴스의 속성

Intl.PluralRules 인스턴스는 일반 객체이고, %Intl.PluralRules.prototype%로부터 속성을 상속받는다.

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

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

  • [[Locale]] 는 문자열(String) 값이며, 복수 규칙(plural rules)에 의해 지역화가 사용되는 언어 태그를 가진다.
  • [[Type]]"cardinal" 또는 "ordinal" 중 하나의 문자열(String) 값이며, 사용되는 복수 규칙을 식별한다.
  • [[Notation]]"standard", "scientific", "engineering", "compact" 중 하나의 문자열(String) 값이며, 사용되는 표기법을 식별한다.
  • [[CompactDisplay]]"short" 또는 "long" 중 하나의 문자열(String) 값이며, "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" 중 하나의 문자열(String) 값이다. 17.3.2에서 [[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" 중 하나의 문자열(String) 값이며, 포매팅된 숫자가 정수(즉, 0이 아닌 소수 자릿수가 없는 경우)일 때 뒤쪽 0을 제거할지 여부를 나타낸다.

17.5 PluralRules 객체를 위한 추상 연산

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

구현 정의 추상 연산 PluralRuleSelect은 locale (언어 태그), type ("cardinal" 또는 "ordinal"), notation (문자열), compactDisplay ("short" 또는 "long"), s (소수 문자열)을 인자로 받고, "zero", "one", "two", "few", "many", "other" 중 하나를 반환한다. 반환되는 문자열은 type, notation, compactDisplay에 따라 해당 locale에서 s가 속하는 복수 범주를 나타낸다.

17.5.2 ResolvePlural ( pluralRules, n )

추상 연산 ResolvePlural은 pluralRules (Intl.PluralRules)와 n (숫자)을 인자로 받고, Record를 반환한다. 이 Record에는 [[PluralCategory]] ("zero", "one", "two", "few", "many", "other")와 [[FormattedString]] (문자열) 필드가 있다. 반환되는 Recordn에 대해 적용되는 locale 및 pluralRules의 옵션에 따라 두 개의 문자열 필드로 설명된다: [[PluralCategory]]복수 범주를 나타내고, [[FormattedString]]는 포맷된 표현을 포함한다. 호출 시 아래 단계들을 수행한다:

  1. n유한 숫자가 아니면,
    1. s를 ! ToString(n)으로 설정한다.
    2. Record { [[PluralCategory]]: "other", [[FormattedString]]: s }를 반환한다.
  2. resFormatNumericToString(pluralRules, (n))으로 설정한다.
  3. sres.[[FormattedString]]로 설정한다.
  4. localepluralRules.[[Locale]]로 설정한다.
  5. typepluralRules.[[Type]]로 설정한다.
  6. notationpluralRules.[[Notation]]로 설정한다.
  7. compactDisplaypluralRules.[[CompactDisplay]]로 설정한다.
  8. pPluralRuleSelect(locale, type, notation, compactDisplay, s)로 설정한다.
  9. Record { [[PluralCategory]]: p, [[FormattedString]]: s }를 반환한다.

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

구현 정의 추상 연산 PluralRuleSelectRange는 locale (언어 태그), type ("cardinal" 또는 "ordinal"), notation (문자열), compactDisplay ("short" 또는 "long"), xp ("zero", "one", "two", "few", "many", "other"), yp ("zero", "one", "two", "few", "many", "other")을 인자로 받고, "zero", "one", "two", "few", "many", "other" 중 하나를 반환한다. 구현에 따라 복수 범주 문자열 값 xpyp가 각각 범위의 시작과 끝을 나타내며, 해당 locale에서 type, notation, compactDisplay에 대해 전체 범위의 복수 형태로 매핑되거나 "other" 문자열 값으로 매핑된다.

17.5.4 ResolvePluralRange ( pluralRules, x, y )

추상 연산 ResolvePluralRange는 pluralRules (Intl.PluralRules), x (숫자), y (숫자)를 인자로 받고, 정상 완료(값 포함)"zero", "one", "two", "few", "many", "other" 중 하나 또는 throw 완료를 반환한다. 반환되는 문자열 값은 x에서 y까지의 범위의 복수 형태를 해당 locale 및 pluralRules의 옵션에 따라 나타낸다. 호출 시 아래 단계들을 수행한다:

  1. xNaN이거나 yNaN이면, RangeError 예외를 발생시킨다.
  2. xpResolvePlural(pluralRules, x)로 설정한다.
  3. ypResolvePlural(pluralRules, y)로 설정한다.
  4. xp.[[FormattedString]]yp.[[FormattedString]]과 같으면,
    1. xp.[[PluralCategory]]를 반환한다.
  5. localepluralRules.[[Locale]]로 설정한다.
  6. typepluralRules.[[Type]]로 설정한다.
  7. notationpluralRules.[[Notation]]로 설정한다.
  8. compactDisplaypluralRules.[[CompactDisplay]]로 설정한다.
  9. 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 예외를 던진다.
  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 생성자:

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

18.2.1 Intl.RelativeTimeFormat.prototype

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

이 속성의 특성(attribute)은 { [[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" } »이다.

참고 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" 문자열을 이어 붙인 추가 필드가 존재할 수 있다. 이들 필드에 대응하는 값은 두 가지 범주의 필드를 포함하는 Records이다:
    • "future""past" 필드는 locale에 관련된 모든 복수 범주에 대한 필드를 가진 Records이며, 해당 필드의 값은 서식화된 숫자로 대체될 수 있는 "{0}"을 포함할 수 있는 패턴이다.
    • 선택적으로, 키가 Number의 ToString 결과이고 값이 템플릿으로 취급되지 않는 리터럴 문자열인 추가 필드가 있을 수 있다.
  • [[LocaleData]]의 어떤 로케일 필드의 "nu" 필드 값인 List에는 "native", "traditio", "finance" 값을 포함해서는 안 된다.
참고 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. 표 31의 각 행(헤더 제외)을 표의 순서대로 순회하며, 다음을 수행한다:
    1. p를 현재 행의 Property 값으로 둔다.
    2. v를 현재 행의 Internal Slot 값에 해당하는 이름을 가진 relativeTimeFormat의 내부 슬롯 값으로 둔다.
    3. Assert: vundefined가 아니다.
    4. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  5. options를 반환한다.
표 31: RelativeTimeFormat 인스턴스의 해석된 옵션
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"이다.

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

18.4 Intl.RelativeTimeFormat 인스턴스의 속성

Intl.RelativeTimeFormat 인스턴스는 일반 객체이며, %Intl.RelativeTimeFormat.prototype%로부터 속성을 상속받는다.

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

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

  • [[Locale]] 문자열 값이며, 서식에 사용되는 로케일의 언어 태그를 가진다.
  • [[LocaleData]]는 서식을 위해 구현이 사용할 수 있는 데이터를 나타내는 Record이다. 이는 %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 )

추상 연산 SingularRelativeTimeUnit은 인수 unit (문자열)을 받아 정상 완료로 문자열 또는 throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

18.5.2 PartitionRelativeTimePattern ( relativeTimeFormat, value, unit )

추상 연산 PartitionRelativeTimePattern은 인수 relativeTimeFormat (Intl.RelativeTimeFormat), value (Number), unit (문자열)을 받아 정상 완료List 또는 throw 완료를 반환한다. 이 List[[Type]] (문자열), [[Value]] (문자열), [[Unit]] (문자열 또는 empty) 필드를 가진 Records로 구성된다. 반환된 List는 유효 로케일과 relativeTimeFormat의 서식 옵션에 따라 value를 나타낸다. 호출 시 다음 단계를 수행한다:

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

18.5.3 MakePartsList ( pattern, unit, parts )

추상 연산 MakePartsList는 인수 pattern (Pattern String), unit (문자열), parts (서식화된 Number를 나타내는 ListRecords)를 받아, [[Type]] (문자열), [[Value]] (문자열), [[Unit]] (문자열 또는 empty) 필드를 가진 List를 반환한다. 호출 시 다음 단계를 수행한다:

  1. patternPartsPartitionPattern(pattern)로 둔다.
  2. result를 새로운 빈 List로 둔다.
  3. patternParts의 각 Record { [[Type]], [[Value]] } patternPart에 대해,
    1. patternPart.[[Type]]"literal"이면,
      1. resultRecord { [[Type]]: "literal", [[Value]]: patternPart.[[Value]], [[Unit]]: empty }를 추가한다.
    2. 그 밖에는,
      1. Assert: patternPart.[[Type]]"0"이다.
      2. parts의 각 Record { [[Type]], [[Value]] } part에 대해,
        1. resultRecord { [[Type]]: part.[[Type]], [[Value]]: part.[[Value]], [[Unit]]: unit }를 추가한다.
  4. result를 반환한다.
참고
예:
  1. MakePartsList("AA{0}BB", "hour", « Record { [[Type]]: "integer", [[Value]]: "15" } »)를 반환한다.
이는 다음과 같은 ListRecords를 반환한다: « { [[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 )

추상 연산 FormatRelativeTime은 인수 relativeTimeFormat (Intl.RelativeTimeFormat), value (Number), unit (문자열)을 받아 정상 완료로 문자열 또는 throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

18.5.5 FormatRelativeTimeToParts ( relativeTimeFormat, value, unit )

추상 연산 FormatRelativeTimeToParts는 인수 relativeTimeFormat (Intl.RelativeTimeFormat), value (Number), unit (문자열)을 받아 정상 완료로 배열 또는 throw 완료를 반환한다. 호출 시 다음 단계를 수행한다:

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

19 Segmenter 객체

19.1 Intl.Segmenter 생성자

Intl.Segmenter 생성자:

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

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

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

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

  1. NewTarget이 undefined이면 TypeError 예외를 던진다.
  2. internalSlotsList를 « [[InitializedSegmenter]], [[Locale]], [[SegmenterGranularity]] »로 둔다.
  3. segmenter를 ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.Segmenter.prototype%", internalSlotsList)로 둔다.
  4. optionsResolution를 ? ResolveOptions(%Intl.Segmenter%, %Intl.Segmenter%.[[LocaleData]], locales, options)로 둔다.
  5. optionsoptionsResolution.[[Options]]로 설정한다.
  6. 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 생성자:

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

19.2.1 Intl.Segmenter.prototype

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

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

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

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

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

19.2.3 내부 슬롯

[[AvailableLocales]] 내부 슬롯의 값은 구현 정의이며, 9.1에 설명된 제약 내에 있어야 한다.

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

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

참고
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. 표 32의 각 행(헤더 제외)을 표의 순서대로 순회하며, 다음을 수행한다:
    1. p를 현재 행의 Property 값으로 둔다.
    2. v를 현재 행의 Internal Slot 값에 해당하는 이름을 가진 segmenter의 내부 슬롯 값으로 둔다.
    3. Assert: vundefined가 아니다.
    4. CreateDataPropertyOrThrow(options, p, v)를 수행한다.
  5. options를 반환한다.
표 32: Segmenter 인스턴스의 해석된 옵션
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"이다.

이 속성의 특성(attribute)은 { [[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 )

추상 연산 CreateSegmentsObject는 인수 segmenter (Intl.Segmenter)와 string (문자열)을 받아 Segments 인스턴스를 반환한다. 반환된 Segments 인스턴스segmenterstring을 참조한다. 호출 시 다음 단계를 수행한다:

  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로 호출되어, 해당 Segments 인스턴스를 생성한 Intl.Segmenter 인스턴스의 로케일과 옵션에 따라 지정된 인덱스의 코드 유닛이 포함된 세그먼트를 설명하는 Segment Data 객체를 반환한다. 다음 단계를 수행한다:

  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 인스턴스에서 호출되어, 이를 생성한 Intl.Segmenter 인스턴스의 로케일과 옵션을 사용하여 해당 문자열에 대한 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 )

추상 연산 CreateSegmentIterator는 인수 segmenter (Intl.Segmenter)와 string (문자열)을 받아 Segment Iterator를 반환한다. 반환된 Segment Iteratorsegmenter의 로케일과 옵션을 사용하여 string을 순회한다. 호출 시 다음 단계를 수행한다:

  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이면,
    1. CreateIteratorResultObject(undefined, true)를 반환한다.
  8. endIndexFindBoundary(segmenter, string, startIndex, after)로 둔다.
  9. iterator.[[IteratedStringNextSegmentCodeUnitIndex]]endIndex로 설정한다.
  10. segmentDataCreateSegmentDataObject(segmenter, string, startIndex, endIndex)로 둔다.
  11. CreateIteratorResultObject(segmentData, false)를 반환한다.

19.6.2.2 %IntlSegmentIteratorPrototype% [ %Symbol.toStringTag% ]

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

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

19.6.3 Segment Iterator 인스턴스의 속성

Segment Iterator 인스턴스는 일반 객체이며 %SegmentIteratorPrototype%으로부터 속성을 상속한다. Segment Iterator 인스턴스는 처음 생성될 때 표 33에 설명된 내부 슬롯을 가진다.

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

19.7 Segment Data 객체

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

19.7.1 CreateSegmentDataObject ( segmenter, string, startIndex, endIndex )

추상 연산 CreateSegmentDataObject는 인수 segmenter (Intl.Segmenter), string (문자열), startIndex (0 이상의 정수), endIndex (0 이상의 정수)를 받아 Segment Data 객체를 반환한다. 반환된 Segment Data 객체segmenter의 로케일에 따라 string 내에서 startIndexendIndex로 경계 지어진 세그먼트를 설명한다. 호출 시 다음 단계를 수행한다:

  1. lenstring의 길이로 둔다.
  2. Assert: endIndexlen.
  3. Assert: startIndex < endIndex.
  4. resultOrdinaryObjectCreate(%Object.prototype%)로 둔다.
  5. segmentsubstring(string, startIndex, endIndex)로 둔다.
  6. CreateDataPropertyOrThrow(result, "segment", segment)를 수행한다.
  7. CreateDataPropertyOrThrow(result, "index", 𝔽(startIndex))를 수행한다.
  8. CreateDataPropertyOrThrow(result, "input", string)를 수행한다.
  9. granularitysegmenter.[[SegmenterGranularity]]로 둔다.
  10. granularity"word"이면,
    1. isWordLike를, 로케일 segmenter.[[Locale]]에 따라 stringsegment가 "단어 유사(word-like)"인지 나타내는 불리언 값으로 둔다.
    2. CreateDataPropertyOrThrow(result, "isWordLike", isWordLike)를 수행한다.
  11. result를 반환한다.
참고
세그먼트가 "단어 유사"인지 여부는 구현 의존이며, 구현에서는 로케일에 민감한 조정을 사용하는 것이 권장된다. 일반적으로 공백 및/또는 문장부호로만 이루어진 세그먼트(예: ICU [International Components for Unicode, https://unicode-org.github.io/icu-docs/에 문서화됨]에서 "WORD_NONE" 경계로 끝나는 것)는 "단어 유사"로 간주되지 않는다.

19.8 Segmenter 객체를 위한 추상 연산

19.8.1 FindBoundary ( segmenter, string, startIndex, direction )

추상 연산 FindBoundary는 인수 segmenter (Intl.Segmenter), string (문자열), startIndex (0 이상의 정수), direction (before 또는 after)을 받아 0 이상의 정수를 반환한다. 이는 segmenter의 로케일과 옵션에 따라 string에서 startIndex 인덱스의 코드 유닛으로부터 지정된 direction으로 세그먼트 경계를 찾아, 그 직후의 코드 유닛 인덱스를 반환한다. 호출 시 다음 단계를 수행한다:

  1. lenstring의 길이로 둔다.
  2. Assert: startIndex < len.
  3. localesegmenter.[[Locale]]로 둔다.
  4. granularitysegmenter.[[SegmenterGranularity]]로 둔다.
  5. directionbefore이면,
    1. 로케일 locale과 텍스트 요소 세분성 granularity를 사용하여, 문자열의 시작으로부터 최대 startIndex 코드 유닛만큼 앞서 있는 마지막 세그먼트 경계를 string에서 찾는다.
    2. 경계를 찾으면, 그 경계 이전의 string 내 코드 유닛 수를 반환한다.
    3. 0을 반환한다.
  6. Assert: directionafter이다.
  7. 로케일 locale과 텍스트 요소 세분성 granularity를 사용하여, 인덱스 startIndex의 코드 유닛 다음에 오는 첫 번째 세그먼트 경계를 string에서 찾는다.
  8. 경계를 찾으면, 그 경계 이전의 string 내 코드 유닛 수를 반환한다.
  9. len을 반환한다.
참고
경계 결정은 구현 의존이지만, 일반적인 기본 알고리즘은 Unicode Standard Annex #29에 명시되어 있다. 구현에서는 Common Locale Data Repository(https://cldr.unicode.org에서 제공)를 사용하는 등 로케일에 민감한 조정을 사용하는 것이 권장된다.

20 ECMAScript 언어 사양의 로케일 민감 함수

ECMA-262는 여러 로케일-민감 함수를 설명한다. 이 사양을 구현하는 ECMAScript 구현은 여기에서 설명한 대로 이러한 함수들을 구현해야 한다.

참고
이 절의 알고리즘에서 생성되는 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𝔽이다.

참고 1
localeCompare 메서드 자체는 Array.prototype.sort의 인수로 직접적으로 적합하지 않다. 후자는 두 개의 인수를 받는 함수를 요구하기 때문이다.
참고 2
localeCompare 함수는 의도적으로 제네릭이다. this 값이 String 객체일 것을 요구하지 않는다. 따라서 메서드로 사용하기 위해 다른 종류의 객체로 이전할 수 있다.

20.1.2 String.prototype.toLocaleLowerCase ( [ locales ] )

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

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

  1. O를 ? RequireObjectCoercible(this 값)로 둔다.
  2. S를 ? ToString(O)로 둔다.
  3. TransformCase(S, locales, lower)를 반환한다.
참고
toLocaleLowerCase 함수는 의도적으로 제네릭이다. this 값이 String 객체일 것을 요구하지 않는다. 따라서 메서드로 사용하기 위해 다른 종류의 객체로 이전할 수 있다.

20.1.2.1 TransformCase ( S, locales, targetCase )

추상 연산 TransformCase는 인수 S (문자열), locales (ECMAScript 언어 값), targetCase (lower 또는 upper)를 받는다. 이는 ECMA-262, 6.1.4에 설명된 대로 S를 UTF-16 인코딩된 코드 포인트 시퀀스로 해석하고, ILD 변환의 결과를 targetCase로 새 문자열 값으로 반환한다. 호출 시 다음 단계를 수행한다:

  1. requestedLocales를 ? CanonicalizeLocaleList(locales)로 둔다.
  2. requestedLocales가 빈 List가 아니면,
    1. requestedLocalerequestedLocales[0]으로 둔다.
  3. 그 밖에는,
    1. requestedLocaleDefaultLocale()로 둔다.
  4. availableLocales를, Unicode Character Database가 언어-민감 대소문자 매핑을 포함하는 언어 태그를 포함하는 사용 가능한 로케일 목록으로 둔다. 구현이 추가적인 로케일-민감 대소문자 매핑을 지원하는 경우, availableLocales에는 해당하는 언어 태그도 포함되어야 한다.
  5. matchLookupMatchingLocaleByPrefix(availableLocales, « requestedLocale »)로 둔다.
  6. matchundefined가 아니면 localematch.[[locale]]로, 그렇지 않으면 locale"und"로 둔다.
  7. codePointsStringToCodePoints(S)로 둔다.
  8. targetCaselower이면,
    1. newCodePoints를, locale을 사용한 구현 파생 알고리즘 또는 Unicode 기본 대소문자 변환 알고리즘에 따라 codePoints를 소문자로 변환한 결과 요소들로 이루어진 List로 둔다.
  9. 그 밖에는,
    1. Assert: targetCaseupper이다.
    2. newCodePoints를, locale을 사용한 구현 파생 알고리즘 또는 Unicode 기본 대소문자 변환 알고리즘에 따라 codePoints를 대문자로 변환한 결과 요소들로 이루어진 List로 둔다.
  10. CodePointsToString(newCodePoints)를 반환한다.

코드 포인트 매핑은 Unicode Standard의 기본 대소문자 변환 알고리즘의 맞춤(tailored) 버전에 따라 파생될 수 있다. 구현은 Unicode Character Database의 SpecialCasing.txt 및/또는 CLDR 및/또는 기타 사용자 정의 맞춤을 사용할 수 있다. 맞춤 여부와 상관없이, 적합한 구현의 대소문자 변환 알고리즘은 동일한 입력 코드 포인트, 로케일, 대상 대소문자에 대해 항상 동일한 결과를 산출해야 한다.

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

20.1.3 String.prototype.toLocaleUpperCase ( [ locales ] )

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

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

  1. O를 ? RequireObjectCoercible(this 값)로 둔다.
  2. S를 ? ToString(O)로 둔다.
  3. TransformCase(S, locales, upper)를 반환한다.
참고
toLocaleUpperCase 함수는 의도적으로 제네릭이다. this 값이 String 객체일 것을 요구하지 않는다. 따라서 메서드로 사용하기 위해 다른 종류의 객체로 이전할 수 있다.

20.2 Number 프로토타입 객체의 속성

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

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

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

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

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

20.3 BigInt 프로토타입 객체의 속성

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

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

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

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

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

20.4 Date 프로토타입 객체의 속성

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

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

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

toLocaleString 메서드가 선택적 인수 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인 동안 반복한다,
    1. k > 0이면,
      1. RRseparator문자열 연결로 설정한다.
    2. nextElement를 ? Get(array, ! ToString(𝔽(k)))로 둔다.
    3. nextElementundefined 또는 null이 아니면,
      1. S를 ? ToString(? Invoke(nextElement, "toLocaleString", « locales, options »))로 둔다.
      2. RRS문자열 연결로 설정한다.
    4. kk + 1로 설정한다.
  7. R를 반환한다.
참고 1
이 알고리즘의 단계는 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] )에서 수행되는 단계들과 유사하나, 여기서는 Invoke(nextElement, "toLocaleString")이 localesoptions를 인수로 받는다는 점이 다르다.
참고 2
배열의 각 요소는 그들의 toLocaleString 메서드를 사용해 문자열로 변환되고, 이 문자열들이 구현-정의된 로케일-민감 구분자 문자열로 구분되어 연결된다. 이 함수는 toString과 유사하지만, 호스트 환경의 현재 로케일 관례에 대응하는 로케일-민감 결과를 생성하도록 의도되었다.
참고 3
toLocaleString 함수는 의도적으로 제네릭이다. this 값이 Array 객체일 것을 요구하지 않는다. 따라서 메서드로 사용하기 위해 다른 종류의 객체로 이전할 수 있다.

Annex A (informative) 구현 의존 동작

이 사양의 다음 측면들은 구현 의존적이다:

Annex B (informative) 이전 판과의 비호환성을 초래하는 추가 및 변경 사항

Annex C (informative) 콜로폰

이 사양은 평문 소스 형식인 Ecmarkup으로 GitHub에서 작성된다. Ecmarkup은 HTML과 Markdown 방언으로, 평문으로 ECMAScript 사양을 작성하고, 본 문서의 편집 규칙을 따르는 기능이 완비된 HTML 렌더링으로 처리하기 위한 프레임워크와 도구 모음을 제공한다. Ecmarkup은 구문 정의를 위한 Grammarkdown과 알고리즘 단계를 작성하기 위한 Ecmarkdown을 포함한 여러 형식과 기술 위에 구축되고 이를 통합한다. 이 사양의 PDF 렌더링은 HTML 렌더링을 PDF로 인쇄하여 생성된다.

이전 판의 사양은 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.