summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Runtime/Date.h
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-03-31 18:43:45 +0100
committerAndreas Kling <kling@serenityos.org>2020-03-31 21:19:21 +0200
commit632231cc0c1520f51b713df2b55ef3a34513d496 (patch)
tree6d13dbb62e67ea4011aeea2ef998e3585c647b15 /Libraries/LibJS/Runtime/Date.h
parent839beb52f372c90ae258ae4a9496c5a854351be2 (diff)
downloadserenity-632231cc0c1520f51b713df2b55ef3a34513d496.zip
js: Implement print function for Date objects
Diffstat (limited to 'Libraries/LibJS/Runtime/Date.h')
-rw-r--r--Libraries/LibJS/Runtime/Date.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/Libraries/LibJS/Runtime/Date.h b/Libraries/LibJS/Runtime/Date.h
index 875f8bf5d2..557af7ce2c 100644
--- a/Libraries/LibJS/Runtime/Date.h
+++ b/Libraries/LibJS/Runtime/Date.h
@@ -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
{