From 63d0aa9d8a566f02281e63defafa1129e8fff71b Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Sun, 27 Nov 2022 06:42:06 -0500 Subject: [PATCH] LibCore: Add %l conversion specification to DateTime Replaced by the hour as a decimal 1-12 in which single digits are preceded by a blank --- Userland/Libraries/LibCore/DateTime.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Userland/Libraries/LibCore/DateTime.cpp b/Userland/Libraries/LibCore/DateTime.cpp index 350e076658..4e55a34a5b 100644 --- a/Userland/Libraries/LibCore/DateTime.cpp +++ b/Userland/Libraries/LibCore/DateTime.cpp @@ -163,6 +163,13 @@ String DateTime::to_string(StringView format) const case 'j': builder.appendff("{:03}", tm.tm_yday + 1); break; + case 'l': { + int display_hour = tm.tm_hour % 12; + if (display_hour == 0) + display_hour = 12; + builder.appendff("{:2}", display_hour); + break; + } case 'm': builder.appendff("{:02}", tm.tm_mon + 1); break;