diff --git a/src/commands/CmdChart.cpp b/src/commands/CmdChart.cpp index dbe4caa5..423a7b28 100644 --- a/src/commands/CmdChart.cpp +++ b/src/commands/CmdChart.cpp @@ -40,7 +40,8 @@ static std::pair 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 &, bool, const Datetime&, int, int, const std::vector &); @@ -199,12 +200,14 @@ int renderChart ( const auto with_month = rules.getBoolean ("reports." + type + ".month"); const auto with_week = rules.getBoolean ("reports." + type + ".week"); - auto labelMonth = with_month ? renderMonth (previous, day) : ""; - auto labelWeek = with_week ? renderWeek (previous, day) : ""; - auto labelDay = renderDayName (type, rules, day, colorToday, colorHoliday); + auto labelMonth = with_month ? renderMonth (previous, day) : ""; + auto labelWeek = with_week ? renderWeek (previous, day) : ""; + 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)) << ' ';