diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-01-25 16:07:22 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-01-25 23:21:30 +0000 |
commit | 29c8ec5eb6fa86657cc15ffd5d2fb868128611b4 (patch) | |
tree | 3c60ed0019fa9c048f1790aa4d3bdaa42fd34ae6 | |
parent | 9605be19bb41f89ec23706cfb8ea14773f49351b (diff) | |
download | serenity-29c8ec5eb6fa86657cc15ffd5d2fb868128611b4.zip |
LibCore: Support (and use) DateTime string formatting of the form %Z
This formats the time zone name. This is now used in the default format
string because DateTime is meant to represent local time; it only makes
sense to include the time zone by default now that we support non-UTC.
-rw-r--r-- | Userland/Libraries/LibCore/DateTime.cpp | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibCore/DateTime.h | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/Userland/Libraries/LibCore/DateTime.cpp b/Userland/Libraries/LibCore/DateTime.cpp index 490a27d2f6..dce43d57b5 100644 --- a/Userland/Libraries/LibCore/DateTime.cpp +++ b/Userland/Libraries/LibCore/DateTime.cpp @@ -246,6 +246,9 @@ String DateTime::to_string(const String& format) const format_time_zone_offset(true); break; + case 'Z': + builder.append(tzname[0]); + break; case '%': builder.append('%'); break; diff --git a/Userland/Libraries/LibCore/DateTime.h b/Userland/Libraries/LibCore/DateTime.h index 30ac5227af..628dd7e343 100644 --- a/Userland/Libraries/LibCore/DateTime.h +++ b/Userland/Libraries/LibCore/DateTime.h @@ -30,7 +30,7 @@ public: bool is_leap_year() const; void set_time(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0); - String to_string(const String& format = "%Y-%m-%d %H:%M:%S") const; + String to_string(const String& format = "%Y-%m-%d %H:%M:%S %Z") const; static DateTime create(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0); static DateTime now(); |