Split renderDayName into renderWeekday and renderDay

This commit is contained in:
Thomas Lauf 2018-12-28 11:08:08 +01:00
parent 227344063e
commit 12140859dc

View file

@ -40,7 +40,8 @@ static std::pair<int, int> determineHourRange (const std::string&, const Rules&,
static void renderAxis (const std::string&, const Rules&, bool, const std::string&, int, int);
static std::string renderMonth (const Datetime&, const Datetime&);
static std::string renderWeek (const Datetime&, const Datetime&);
static std::string renderDayName (const std::string&, const Rules&, Datetime&, Color&, Color&);
static std::string renderWeekday (const std::string&, const Rules&, Datetime&, Color&, Color&);
static std::string renderDay (const std::string&, const Rules&, Datetime&, Color&, Color&);
static std::string renderTotal (const std::string&, const Rules&, time_t);
static std::string renderSubTotal (const std::string&, const Rules&, int, int, time_t);
static void renderExclusionBlocks (const std::string&, const Rules&, std::vector <Composite>&, bool, const Datetime&, int, int, const std::vector <Range>&);
@ -201,10 +202,12 @@ int renderChart (
auto labelMonth = with_month ? renderMonth (previous, day) : "";
auto labelWeek = with_week ? renderWeek (previous, day) : "";
auto labelDay = renderDayName (type, rules, day, colorToday, colorHoliday);
auto labelWeekday = renderWeekday (type, rules, day, colorToday, colorHoliday);
auto labelDay = renderDay (type, rules, day, colorToday, colorHoliday);
std::cout << labelMonth
<< labelWeek
<< labelWeekday
<< labelDay
<< lines[0].str ();
@ -377,14 +380,13 @@ static std::string renderWeek (const Datetime &previous, const Datetime &day)
////////////////////////////////////////////////////////////////////////////////
// Today should be highlighted.
// Includes trailing separator space.
static std::string renderDayName (
static std::string renderWeekday (
const std::string& type,
const Rules& rules,
Datetime& day,
Color& colorToday,
Color& colorHoliday)
{
auto showDay = rules.getBoolean ("reports." + type + ".day");
auto showWeekday = rules.getBoolean ("reports." + type + ".weekday");
Color color;
@ -398,6 +400,26 @@ static std::string renderDayName (
out << color.colorize (Datetime::dayNameShort (day.dayOfWeek ()))
<< ' ';
return out.str ();
}
////////////////////////////////////////////////////////////////////////////////
static std::string renderDay (
const std::string& type,
const Rules& rules,
Datetime& day,
Color& colorToday,
Color& colorHoliday)
{
auto showDay = rules.getBoolean ("reports." + type + ".day");
Color color;
if (day.sameDay (Datetime ()))
color = colorToday;
else if (dayIsHoliday (rules, day))
color = colorHoliday;
std::stringstream out;
if (showDay)
out << color.colorize (rightJustify (day.day (), 2))
<< ' ';