@@ -208,11 +208,31 @@ function adjustFormatterTimeZone(
208
208
if ( ! timeZone ) return formatter ;
209
209
const options = formatter . resolvedOptions ( ) ;
210
210
if ( options . timeZone === timeZone ) return formatter ;
211
- // Existing Intl isn't typed to accept Temporal-specific options, but will not
212
- // break at runtime if we pass them. Also, the lib types for resolved options
213
- // are less restrictive than the types for options. For example, `weekday` is
211
+ // Existing Intl isn't typed to accept Temporal-specific options and the lib
212
+ // types for resolved options are less restrictive than the types for options.
213
+ // For example, `weekday` is
214
214
// `'long' | 'short' | 'narrow'` in options but `string` in resolved options.
215
215
// TODO: investigate why, and file an issue against TS if it's a bug.
216
+ if ( ( options as any ) [ 'dateStyle' ] || ( options as any ) [ 'timeStyle' ] ) {
217
+ // Unfortunately, Safari's resolvedOptions include parameters that will
218
+ // cause errors at runtime if passed along with
219
+ // dateStyle or timeStyle options as per
220
+ // https://tc39.es/proposal-intl-datetime-style/#table-datetimeformat-components.
221
+ // This has been fixed in newer versions of Safari:
222
+ // https://bugs.webkit.org/show_bug.cgi?id=231041
223
+ delete options [ 'weekday' ] ;
224
+ delete options [ 'era' ] ;
225
+ delete options [ 'year' ] ;
226
+ delete options [ 'month' ] ;
227
+ delete options [ 'day' ] ;
228
+ delete options [ 'hour' ] ;
229
+ delete options [ 'minute' ] ;
230
+ delete options [ 'second' ] ;
231
+ delete options [ 'timeZoneName' ] ;
232
+ delete ( options as any ) [ 'hourCycle' ] ;
233
+ delete options [ 'hour12' ] ;
234
+ delete ( options as any ) [ 'dayPeriod' ] ;
235
+ }
216
236
return new IntlDateTimeFormat ( options . locale , { ...( options as globalThis . Intl . DateTimeFormatOptions ) , timeZone } ) ;
217
237
}
218
238
0 commit comments