MCPcopy Create free account
hub / github.com/Alexays/Waybar / getCalendarLine

Function getCalendarLine

src/modules/clock.cpp:239–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239auto getCalendarLine(const year_month_day& currDate, const year_month ym, const unsigned line,
240 const weekday& firstdow, const std::locale* const m_locale_) -> std::string {
241 std::ostringstream os;
242
243 switch (line) {
244 // Print month and year title
245 case 0: {
246 os << date::format(*m_locale_, "{:L%B %Y}", ym);
247 break;
248 }
249 // Print weekday names title
250 case 1: {
251 auto wd{firstdow};
252 Glib::ustring wdStr;
253 Glib::ustring::size_type wdLen{0};
254 int clen{0};
255 do {
256 wdStr = date::format(*m_locale_, "{:L%a}", wd);
257 clen = ustring_clen(wdStr);
258 wdLen = wdStr.length();
259 while (clen > 2) {
260 wdStr = wdStr.substr(0, wdLen - 1);
261 --wdLen;
262 clen = ustring_clen(wdStr);
263 }
264 const std::string pad(2 - clen, ' ');
265
266 if (wd != firstdow) os << ' ';
267
268 os << pad << wdStr;
269 } while (++wd != firstdow);
270 break;
271 }
272 // Print first week prefixed with spaces if necessary
273 case 2: {
274 auto d{day{1}};
275 auto wd{weekday{ym / 1}};
276 os << std::string((wd - firstdow).count() * 3, ' ');
277
278 if (currDate != ym / d)
279 os << date::format(*m_locale_, "{:L%e}", d);
280 else
281 os << "{today}";
282
283 while (++wd != firstdow) {
284 ++d;
285
286 if (currDate != ym / d)
287 os << date::format(*m_locale_, " {:L%e}", d);
288 else
289 os << " {today}";
290 }
291 break;
292 }
293 // Print non-first week
294 default: {
295 const auto ymdTmp{cldGetWeekForLine(ym, firstdow, line)};
296 if (ymdTmp.ok()) {

Callers 1

get_calendarMethod · 0.85

Calls 5

formatFunction · 0.85
ustring_clenFunction · 0.85
cldGetWeekForLineFunction · 0.85
countMethod · 0.80
okMethod · 0.80

Tested by

no test coverage detected