LibWeb: Preserve unit when serializing time values

Previously, when serializing a time value, we would always convert it
to seconds. We now canonicalize the time value only when serializing
its computed value.
This commit is contained in:
Tim Ledbetter 2025-03-19 16:48:33 +00:00 committed by Sam Atkins
parent 2672fe99b7
commit d0be5a0cdf
Notes: github-actions[bot] 2025-03-20 17:00:33 +00:00
4 changed files with 35 additions and 2 deletions

View file

@ -28,7 +28,7 @@ Time Time::percentage_of(Percentage const& percentage) const
String Time::to_string() const
{
return MUST(String::formatted("{}s", to_seconds()));
return MUST(String::formatted("{}{}", raw_value(), unit_name()));
}
double Time::to_seconds() const