@@ -3,12 +3,7 @@ import { MessageResolutionError } from '../errors.js';
33import type { MessageExpressionPart } from '../formatted-parts.js' ;
44import type { MessageValue } from '../message-value.js' ;
55import type { MessageFunctionContext } from '../resolve/function-context.js' ;
6- import {
7- asBoolean ,
8- asPositiveInteger ,
9- asString ,
10- mergeLocales
11- } from './utils.js' ;
6+ import { asBoolean , asPositiveInteger , asString } from './utils.js' ;
127
138/** @beta */
149export interface MessageDateTime extends MessageValue {
@@ -51,7 +46,7 @@ export const datetime = (
5146 options : Record < string , unknown > ,
5247 input ?: unknown
5348) : MessageDateTime =>
54- dateTimeImplementation ( ctx , options , input , res => {
49+ dateTimeImplementation ( ctx , input , res => {
5550 for ( const [ name , value ] of Object . entries ( options ) ) {
5651 if ( value === undefined ) continue ;
5752 try {
@@ -91,7 +86,7 @@ export const date = (
9186 options : Record < string , unknown > ,
9287 input ?: unknown
9388) : MessageDateTime =>
94- dateTimeImplementation ( ctx , options , input , res => {
89+ dateTimeImplementation ( ctx , input , res => {
9590 const ds = options . style ?? res . dateStyle ?? 'medium' ;
9691 for ( const name of Object . keys ( res ) ) {
9792 if ( ! localeOptions . includes ( name ) ) delete res [ name ] ;
@@ -115,7 +110,7 @@ export const time = (
115110 options : Record < string , unknown > ,
116111 input ?: unknown
117112) : MessageDateTime =>
118- dateTimeImplementation ( ctx , options , input , res => {
113+ dateTimeImplementation ( ctx , input , res => {
119114 const ts = options . style ?? res . timeStyle ?? 'short' ;
120115 for ( const name of Object . keys ( res ) ) {
121116 if ( ! localeOptions . includes ( name ) ) delete res [ name ] ;
@@ -130,12 +125,10 @@ export const time = (
130125
131126function dateTimeImplementation (
132127 ctx : MessageFunctionContext ,
133- options : Record < string , unknown > ,
134128 input : unknown ,
135129 parseOptions : ( res : Record < string , unknown > ) => void
136130) : MessageDateTime {
137131 const { localeMatcher, locales, source } = ctx ;
138- const lc = mergeLocales ( locales , input , options ) ;
139132 const opt : Intl . DateTimeFormatOptions = { localeMatcher } ;
140133 if ( input && typeof input === 'object' ) {
141134 if ( input && 'options' in input ) Object . assign ( opt , input . options ) ;
@@ -174,13 +167,16 @@ function dateTimeImplementation(
174167 return dir ;
175168 } ,
176169 get locale ( ) {
177- return ( locale ??= Intl . DateTimeFormat . supportedLocalesOf ( lc , opt ) [ 0 ] ) ;
170+ return ( locale ??= Intl . DateTimeFormat . supportedLocalesOf (
171+ locales ,
172+ opt
173+ ) [ 0 ] ) ;
178174 } ,
179175 get options ( ) {
180176 return { ...opt } ;
181177 } ,
182178 toParts ( ) {
183- dtf ??= new Intl . DateTimeFormat ( lc , opt ) ;
179+ dtf ??= new Intl . DateTimeFormat ( locales , opt ) ;
184180 const parts = dtf . formatToParts ( date ) ;
185181 locale ??= dtf . resolvedOptions ( ) . locale ;
186182 dir ??= getLocaleDir ( locale ) ;
@@ -189,7 +185,7 @@ function dateTimeImplementation(
189185 : [ { type : 'datetime' , source, locale, parts } ] ;
190186 } ,
191187 toString ( ) {
192- dtf ??= new Intl . DateTimeFormat ( lc , opt ) ;
188+ dtf ??= new Intl . DateTimeFormat ( locales , opt ) ;
193189 str ??= dtf . format ( date ) ;
194190 return str ;
195191 } ,
0 commit comments