mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Simpify calendar generation, single loop handles both first week and subsequent weeks.
This commit is contained in:
parent
f6b2005687
commit
218bb3bc2b
@ -61,21 +61,13 @@ std::string calendar_text(const waybar_time& wtime, const date::weekday& first_d
|
||||
if (empty_days > 0) {
|
||||
os << std::string(empty_days * 3 - 1, ' ');
|
||||
}
|
||||
auto d = date::day(1);
|
||||
do {
|
||||
if (wd != first_dow) os << ' ';
|
||||
if (d == curr_day) {
|
||||
os << "<b><u>" << date::format("%e", d) << "</u></b>";
|
||||
} else {
|
||||
os << date::format("%e", d);
|
||||
}
|
||||
++d;
|
||||
} while (++wd != first_dow);
|
||||
|
||||
// Following weeks.
|
||||
auto last_day = (ym/date::literals::last).day();
|
||||
for ( ; d <= last_day; ++d, ++wd) {
|
||||
os << ((wd == first_dow) ? '\n' : ' ');
|
||||
for (auto d = date::day(1); d <= last_day; ++d, ++wd) {
|
||||
if (wd != first_dow) {
|
||||
os << ' ';
|
||||
} else if (unsigned(d) != 1) {
|
||||
os << '\n';
|
||||
}
|
||||
if (d == curr_day) {
|
||||
os << "<b><u>" << date::format("%e", d) << "</u></b>";
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user