1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 18:27:39 +00:00

js: Implement print function for Date objects

This commit is contained in:
Linus Groh 2020-03-31 18:43:45 +01:00 committed by Andreas Kling
parent 839beb52f3
commit 632231cc0c
3 changed files with 23 additions and 12 deletions

View file

@ -35,11 +35,16 @@ public:
virtual ~Date() override;
Core::DateTime& datetime() { return m_datetime; }
const Core::DateTime& datetime() const { return m_datetime; }
u16 milliseconds() { return m_milliseconds; }
String date_string() { return m_datetime.to_string("%a %b %d %Y"); }
String date_string() const { return m_datetime.to_string("%a %b %d %Y"); }
// FIXME: Deal with timezones once SerenityOS has a working tzset(3)
String time_string() { return m_datetime.to_string("%T GMT+0000 (UTC)"); }
String time_string() const { return m_datetime.to_string("%T GMT+0000 (UTC)"); }
String string() const
{
return String::format("%s %s", date_string().characters(), time_string().characters());
}
virtual Value value_of() const override
{