Przeglądaj źródła

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
thankyouverycool 2 lat temu
rodzic
commit
63d0aa9d8a
1 zmienionych plików z 7 dodań i 0 usunięć
  1. 7 0
      Userland/Libraries/LibCore/DateTime.cpp

+ 7 - 0
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;