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

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.
This commit is contained in:
Timothy Flynn 2022-01-25 16:07:22 -05:00 committed by Linus Groh
parent 9605be19bb
commit 29c8ec5eb6
2 changed files with 4 additions and 1 deletions

View file

@ -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;

View file

@ -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();