LibWeb/HTML: Reuse number to date string conversion helper

This shares the code to convert to a date string for this algorithm
and the valueAsNumber implementation.
This commit is contained in:
Shannon Booth 2025-03-06 15:29:46 +13:00 committed by Tim Flynn
parent 13f9670f20
commit f344eca39d
Notes: github-actions[bot] 2025-03-06 14:02:26 +00:00

View file

@ -2289,7 +2289,7 @@ String HTMLInputElement::covert_date_to_string(GC::Ref<JS::Date> input) const
if (type_state() == TypeAttributeState::Date) {
// Return a valid date string that represents the date current at the time represented by input in the UTC time zone.
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
return MUST(String::formatted("{:04d}-{:02d}-{:02d}", JS::year_from_time(input->date_value()), JS::month_from_time(input->date_value()) + 1, JS::date_from_time(input->date_value())));
return convert_number_to_date_string(input->date_value());
}
// https://html.spec.whatwg.org/multipage/input.html#time-state-(type=time):concept-input-value-string-date