LibJS: Pad abs(year) < 1000 with zeros in Date.prototype.toString()

This commit is contained in:
Linus Groh 2021-07-10 18:51:30 +01:00
commit 674f3d0347
Notes: sideshowbarker 2024-07-18 09:24:26 +09:00

View file

@ -53,7 +53,8 @@ public:
m_milliseconds = milliseconds;
}
String date_string() const { return m_datetime.to_string("%a %b %d %Y"); }
// FIXME: Support %04Y in Core::DateTime::to_string()
String date_string() const { return String::formatted(m_datetime.to_string("%a %b %d {:04}"), m_datetime.year()); }
// FIXME: Deal with timezones once SerenityOS has a working tzset(3)
String time_string() const { return m_datetime.to_string("%T GMT+0000 (UTC)"); }
String string() const