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

LibC+LibCore: Change a.m./p.m. to AM/PM

This commit is contained in:
cflip 2022-04-12 18:00:10 -06:00 committed by Tim Flynn
parent 0500d49acb
commit b2ef7ee531
2 changed files with 10 additions and 10 deletions

View file

@ -173,13 +173,13 @@ String DateTime::to_string(StringView format) const
builder.append('\n');
break;
case 'p':
builder.append(tm.tm_hour < 12 ? "a.m." : "p.m.");
builder.append(tm.tm_hour < 12 ? "AM" : "PM");
break;
case 'r': {
int display_hour = tm.tm_hour % 12;
if (display_hour == 0)
display_hour = 12;
builder.appendff("{:02}:{:02}:{:02} {}", display_hour, tm.tm_min, tm.tm_sec, tm.tm_hour < 12 ? "a.m." : "p.m.");
builder.appendff("{:02}:{:02}:{:02} {}", display_hour, tm.tm_min, tm.tm_sec, tm.tm_hour < 12 ? "AM" : "PM");
break;
}
case 'R':
@ -427,19 +427,19 @@ Optional<DateTime> DateTime::parse(StringView format, String const& string)
}
break;
case 'p': {
auto ampm = string.substring_view(string_pos, 4);
if (ampm == "p.m." && tm.tm_hour < 12) {
auto ampm = string.substring_view(string_pos, 2);
if (ampm == "PM" && tm.tm_hour < 12) {
tm.tm_hour += 12;
}
string_pos += 4;
string_pos += 2;
break;
}
case 'r': {
auto ampm = string.substring_view(string_pos, 4);
if (ampm == "p.m." && tm.tm_hour < 12) {
auto ampm = string.substring_view(string_pos, 2);
if (ampm == "PM" && tm.tm_hour < 12) {
tm.tm_hour += 12;
}
string_pos += 4;
string_pos += 2;
break;
}
case 'R': {