Skip to content

Commit 32f92b1

Browse files
committed
Intl.DateTimeFormat: support Temporal types in format/formatRange
- Add IntlDateTimeInput enum to dispatch Legacy, Instant, and Plain Temporal inputs - Add IntlTemporalDateTimeKind and IntlTemporalDateTimeFields structs for Temporal field representation - Add intl_temporal_fields_from_{date,datetime,time,year_month,month_day} converters - Add intl_date_time_format_input / intl_date_time_format_required_input dispatchers - Add intl_temporal_normalized_formatter, intl_temporal_instant_formatter helpers - Add intl_date_time_format_parts_for_temporal and intl_temporal_style_parts for Temporal-aware rendering - Add intl_date_time_range_parts_from_values and intl_can_collapse_date_time_range_prefix for range formatting - Update format/formatToParts/formatRange/formatRangeToParts to handle all Temporal types - Add kind-mismatch check in formatRange for mixed Temporal/non-Temporal arguments - Expose temporal_expect_{instant,plain_date,plain_date_time,plain_time,year_month,month_day} as pub(super) - Add temporal_value_kind helper to identify Temporal object kind - Wire all Temporal toLocaleString methods to Intl.DateTimeFormat with locale/options args - Add temporal_instant_to_locale_string and temporal_duration_to_locale_string helpers - Fix date.rs needs_defaults to account for dateStyle/timeStyle options
1 parent 1d4aae3 commit 32f92b1

4 files changed

Lines changed: 1274 additions & 86 deletions

File tree

src/core/vm/date.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,17 @@ impl<'gc> VM<'gc> {
274274
let value = self.read_named_property(ctx, &boxed_options, key);
275275
self.pending_throw.is_none() && !matches!(value, Value::Undefined)
276276
});
277+
let date_style = self.read_named_property(ctx, &boxed_options, "dateStyle");
278+
let time_style = self.read_named_property(ctx, &boxed_options, "timeStyle");
277279
if let Some(thrown) = self.pending_throw.take() {
278280
return Err(thrown);
279281
}
282+
let has_date_style = !matches!(date_style, Value::Undefined);
283+
let has_time_style = !matches!(time_style, Value::Undefined);
280284
let needs_defaults = match mode {
281-
"date" => !has_date_fields,
282-
"time" => !has_time_fields,
283-
_ => !has_date_fields && !has_time_fields,
285+
"date" => !has_date_fields && !has_date_style,
286+
"time" => !has_time_fields && !has_time_style,
287+
_ => !has_date_fields && !has_time_fields && !has_date_style && !has_time_style,
284288
};
285289
if !needs_defaults {
286290
return Ok(vec![locales, boxed_options]);

0 commit comments

Comments
 (0)