diff --git a/core/engine/src/builtins/intl/date_time_format/mod.rs b/core/engine/src/builtins/intl/date_time_format/mod.rs index 1090907f792..b888eebbe21 100644 --- a/core/engine/src/builtins/intl/date_time_format/mod.rs +++ b/core/engine/src/builtins/intl/date_time_format/mod.rs @@ -1025,24 +1025,6 @@ pub(crate) fn format_date_time_locale( context: &mut Context, ) -> JsResult { let options = coerce_options_to_object(options, context)?; - if format_type != FormatType::Time - && get_option::(&options, js_string!("dateStyle"), context)?.is_none() - { - options.create_data_property_or_throw( - js_string!("dateStyle"), - JsValue::from(js_string!("long")), - context, - )?; - } - if format_type != FormatType::Date - && get_option::(&options, js_string!("timeStyle"), context)?.is_none() - { - options.create_data_property_or_throw( - js_string!("timeStyle"), - JsValue::from(js_string!("long")), - context, - )?; - } let options_value = options.into(); let dtf = create_date_time_format(locales, &options_value, format_type, defaults, context)?; // FormatDateTime steps 1–2: TimeClip and NaN check (format_timestamp_with_dtf does ToLocalTime + format only). diff --git a/core/engine/src/builtins/intl/date_time_format/tests.rs b/core/engine/src/builtins/intl/date_time_format/tests.rs index 66d97ccfd99..f8af4902267 100644 --- a/core/engine/src/builtins/intl/date_time_format/tests.rs +++ b/core/engine/src/builtins/intl/date_time_format/tests.rs @@ -65,3 +65,26 @@ fn dtf_basic() { TestAction::assert_eq("result === 'Sunday, 20 December 2020 at 14:23:16'", true), ]); } + +#[cfg(feature = "intl_bundled")] +#[test] +fn date_to_locale_string() { + run_test_actions([ + TestAction::run(indoc! {" + // Setup date + const date = new Date(Date.UTC(2021, 3, 12, 6, 7)); + + let result = date.toLocaleString('en-US', { dateStyle: 'short' }); + "}), + TestAction::assert_eq("result === '4/12/21'", true), + ]); + run_test_actions([ + TestAction::run(indoc! {" + // Setup date + const date = new Date(Date.UTC(2021, 3, 12, 6, 7)); + + let result = date.toLocaleString('en-US', { timeStyle: 'short' }); + "}), + TestAction::assert_eq("result === '6:07\u{202f}AM'", true), + ]); +}