From 02231f0af35a4f64f1d187f90c759e721d23c126 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 24 Apr 2016 10:30:28 -0400 Subject: [PATCH] CmdReportDay: Exclusions rendered --- src/commands/CmdReportDay.cpp | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/commands/CmdReportDay.cpp b/src/commands/CmdReportDay.cpp index 09fe05cf..2786ff92 100644 --- a/src/commands/CmdReportDay.cpp +++ b/src/commands/CmdReportDay.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -91,6 +92,44 @@ int CmdReportDay ( std::cout << '\n'; + // Each day is rendered separately. + for (Datetime day = filter.range.start; day < filter.range.end; day++) + { + // Render the exclusion blocks. + Composite line1; + Composite line2; + for (int hour = first_hour; hour <= last_hour; hour++) + { + // Construct a range representing a single 'hour', of 'day'. + Range r (Datetime (day.year (), day.month (), day.day (), hour, 0, 0), + Datetime (day.year (), day.month (), day.day (), hour + 1, 0, 0)); + + for (auto& exc : excluded) + { + if (exc.overlap (r)) + { + // Determine which of the four 15-min quarters are included. + auto sub_hour = exc.intersect (r); + auto start_block = quantizeTo15Minutes (sub_hour.start.minute ()) / 15; + auto end_block = quantizeTo15Minutes (sub_hour.end.minute () == 0 ? 60 : sub_hour.end.minute ()) / 15; + + int offset = (hour - first_hour) * 5 + start_block; + std::string block (end_block - start_block, ' '); + + line1.add (block, offset, colorExc); + line2.add (block, offset, colorExc); + } + } + } + + std::cout << indent << line1.str () << '\n' + << indent << line2.str () << '\n' + << '\n'; + + line1.clear (); + line2.clear (); + } + // TODO Summary, missing. std::cout << '\n' << indent << "Tracked\n"