mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CmdChart: Added optional holiday table
This commit is contained in:
parent
db79917bc1
commit
5b75ba4571
1 changed files with 29 additions and 0 deletions
|
@ -46,6 +46,7 @@ static std::string renderTotal (const std::string&, const Rules&, time
|
|||
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 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);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -204,6 +205,7 @@ int renderChart (
|
|||
}
|
||||
|
||||
std::cout << renderSubTotal (type, rules, first_hour, last_hour, total_work)
|
||||
<< renderHolidays (type, rules, filter)
|
||||
<< renderSummary (type, rules, std::string (indent, ' '), filter, exclusions, tracked, blank);
|
||||
|
||||
return 0;
|
||||
|
@ -505,6 +507,33 @@ static void renderInterval (
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static std::string renderHolidays (
|
||||
const std::string& type,
|
||||
const Rules& rules,
|
||||
const Interval& filter)
|
||||
{
|
||||
std::stringstream out;
|
||||
if (rules.getBoolean ("reports." + type + ".holidays"))
|
||||
{
|
||||
for (auto& entry : rules.all ("holidays."))
|
||||
{
|
||||
auto last_dot = entry.rfind ('.');
|
||||
if (last_dot != std::string::npos)
|
||||
{
|
||||
auto date = entry.substr (last_dot + 1);
|
||||
std::replace (date.begin (), date.end (), '_', '-');
|
||||
Datetime holiday (date);
|
||||
if (holiday >= filter.range.start &&
|
||||
holiday <= filter.range.end)
|
||||
out << Datetime (date).toString ("Y-M-D") << ' ' << rules.get (entry) << '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
static std::string renderSummary (
|
||||
const std::string& type,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue