diff --git a/src/commands/CmdChart.cpp b/src/commands/CmdChart.cpp index 82460652..54d22873 100644 --- a/src/commands/CmdChart.cpp +++ b/src/commands/CmdChart.cpp @@ -41,7 +41,7 @@ int renderChart (const CLI&, const std::string&, Interv static void determineHourRange (const std::string&, const Rules&, const std::vector &, int&, int&); static void renderAxis (const std::string&, const Rules&, Palette&, const std::string&, int, int); static std::string renderMonth (const std::string&, const Rules&, const Datetime&, const Datetime&); -static std::string renderDayName (const std::string&, const Rules&, Datetime&, Color&); +static std::string renderDayName (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 &, Palette&, const Datetime&, int, int, const std::vector &); @@ -106,6 +106,7 @@ int renderChart ( auto palette = createPalette (rules); auto tag_colors = createTagColorMap (rules, palette, tracked); Color colorToday (palette.enabled ? rules.get ("theme.colors.today") : ""); + Color colorHoliday (palette.enabled ? rules.get ("theme.colors.holiday") : ""); // Determine hours shown. int first_hour = 0; @@ -167,7 +168,7 @@ int renderChart ( } auto labelMonth = renderMonth (type, rules, previous, day); - auto labelDay = renderDayName (type, rules, day, colorToday); + auto labelDay = renderDayName (type, rules, day, colorToday, colorHoliday); std::cout << labelMonth << labelDay @@ -275,32 +276,26 @@ static std::string renderDayName ( const std::string& type, const Rules& rules, Datetime& day, - Color& color) + Color& colorToday, + Color& colorHoliday) { auto showDay = rules.getBoolean ("reports." + type + ".day"); auto showWeekday = rules.getBoolean ("reports." + type + ".weekday"); - std::stringstream out; + Color color; if (day.sameDay (Datetime ())) - { - if (showWeekday) - out << color.colorize (day.dayNameShort (day.dayOfWeek ())) - << ' '; + color = colorToday; + else if (dayIsHoliday (rules, day)) + color = colorHoliday; - if (showDay) - out << color.colorize (rightJustify (day.day (), 2)) - << ' '; - } - else - { - if (showWeekday) - out << day.dayNameShort (day.dayOfWeek ()) - << ' '; + std::stringstream out; + if (showWeekday) + out << color.colorize (day.dayNameShort (day.dayOfWeek ())) + << ' '; - if (showDay) - out << rightJustify (day.day (), 2) - << ' '; - } + if (showDay) + out << color.colorize (rightJustify (day.day (), 2)) + << ' '; return out.str (); } diff --git a/src/helper.cpp b/src/helper.cpp index 7c77ae3f..2781af41 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -235,3 +235,12 @@ int quantizeTo15Minutes (const int minutes) } //////////////////////////////////////////////////////////////////////////////// +bool dayIsHoliday (const Rules& rules, const Datetime& day) +{ + // TODO Look up exclusions. + + + return false; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/timew.h b/src/timew.h index 51ca3833..fd9e8da1 100644 --- a/src/timew.h +++ b/src/timew.h @@ -70,6 +70,7 @@ std::string jsonFromIntervals (const std::vector &); Palette createPalette (const Rules&); std::map createTagColorMap (const Rules&, Palette&, const std::vector &); int quantizeTo15Minutes (const int); +bool dayIsHoliday (const Rules&, const Datetime&); // utiƀ.cpp std::string osName ();