cal: Center the month-year text

For now this only has an effect when displaying two-digit years, but
when month names get implemented this will be helpful.
This commit is contained in:
Karol Baraniecki 2023-03-04 00:01:42 +01:00 committed by Andrew Kaster
parent 119dc042ab
commit 905f2ca152
Notes: sideshowbarker 2024-07-17 00:16:31 +09:00

View file

@ -29,7 +29,7 @@ static ErrorOr<Vector<String>> month_lines_to_print(int month, int year)
Vector<String> lines;
// FIXME: Both the month name and month header text should be provided by a locale
TRY(lines.try_append(TRY(String::formatted(" {:02} - {:02} ", month, year))));
TRY(lines.try_append(TRY(String::formatted("{:^20s}", TRY(String::formatted("{:02} - {:02}", month, year))))));
TRY(lines.try_append(TRY(String::from_utf8("Su Mo Tu We Th Fr Sa"sv))));
int day_to_print = 1;