CmdChart: Observes data range when 'report.<type>.hours = auto'

This commit is contained in:
Paul Beckingham 2016-06-04 11:43:32 -04:00
parent 4f18649945
commit 29ac612614

View file

@ -45,7 +45,7 @@ static std::string renderDayName (const std::string&, const Rules&, Date
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>&, Palette&, const Datetime&, int, int, const std::vector <Range>&);
static void renderInterval (const std::string&, const Rules&, std::vector <Composite>&, const Datetime&, const Interval&, Palette&, std::map <std::string, Color>&, time_t&);
static void renderInterval (const std::string&, const Rules&, std::vector <Composite>&, const Datetime&, const Interval&, Palette&, std::map <std::string, Color>&, int, time_t&);
std::string renderHolidays (const std::string&, const Rules&, const Interval&);
static std::string renderSummary (const std::string&, const Rules&, const std::string&, const Interval&, const std::vector <Range>&, const std::vector <Interval>&, bool);
@ -174,7 +174,7 @@ int renderChart (
for (auto& track : tracked)
{
time_t interval_work = 0;
renderInterval (type, rules, lines, day, track, palette, tag_colors, interval_work);
renderInterval (type, rules, lines, day, track, palette, tag_colors, first_hour, interval_work);
work += interval_work;
}
}
@ -208,6 +208,8 @@ int renderChart (
}
////////////////////////////////////////////////////////////////////////////////
// Scan all tracked intervals, looking for the earliest and latest hour into
// which an interval extends.
static void determineHourRange (
const std::string& type,
const Rules& rules,
@ -217,6 +219,7 @@ static void determineHourRange (
{
if (rules.get ("reports." + type + ".hours") == "auto")
{
// Default to the full day.
first_hour = 0;
last_hour = 23;
@ -443,6 +446,7 @@ static void renderInterval (
const Interval& track,
Palette& palette,
std::map <std::string, Color>& tag_colors,
int first_hour,
time_t& work)
{
auto spacing = rules.getInteger ("reports." + type + ".spacing");
@ -457,8 +461,8 @@ static void renderInterval (
if (track.range.is_open ())
clipped.range.end = Datetime ();
auto start_mins = clipped.range.start.hour () * 60 + clipped.range.start.minute ();
auto end_mins = clipped.range.end.hour () * 60 + clipped.range.end.minute ();
auto start_mins = (clipped.range.start.hour () - first_hour) * 60 + clipped.range.start.minute ();
auto end_mins = (clipped.range.end.hour () - first_hour) * 60 + clipped.range.end.minute ();
if (end_mins == 0)
end_mins = (23 * 60) + 59;