mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Extract rules from renderWeek
This commit is contained in:
parent
7f7f2cb84a
commit
227344063e
1 changed files with 7 additions and 13 deletions
|
@ -38,8 +38,8 @@
|
||||||
int renderChart (const CLI&, const std::string&, Interval&, Rules&, Database&);
|
int renderChart (const CLI&, const std::string&, Interval&, Rules&, Database&);
|
||||||
static std::pair<int, int> determineHourRange (const std::string&, const Rules&, const Interval&, const std::vector <Interval>&);
|
static std::pair<int, int> determineHourRange (const std::string&, const Rules&, const Interval&, const std::vector <Interval>&);
|
||||||
static void renderAxis (const std::string&, const Rules&, bool, const std::string&, int, int);
|
static void renderAxis (const std::string&, const Rules&, bool, const std::string&, int, int);
|
||||||
static std::string renderMonth (const Datetime &previous, const Datetime &day);
|
static std::string renderMonth (const Datetime&, const Datetime&);
|
||||||
static std::string renderWeek (const std::string&, const Rules&, 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 renderDayName (const std::string&, const Rules&, Datetime&, Color&, Color&);
|
||||||
static std::string renderTotal (const std::string&, const Rules&, time_t);
|
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 std::string renderSubTotal (const std::string&, const Rules&, int, int, time_t);
|
||||||
|
@ -197,9 +197,10 @@ int renderChart (
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto with_month = rules.getBoolean ("reports." + type + ".month");
|
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 labelMonth = with_month ? renderMonth (previous, day) : "";
|
||||||
auto labelWeek = renderWeek (type, rules, previous, day);
|
auto labelWeek = with_week ? renderWeek (previous, day) : "";
|
||||||
auto labelDay = renderDayName (type, rules, day, colorToday, colorHoliday);
|
auto labelDay = renderDayName (type, rules, day, colorToday, colorHoliday);
|
||||||
|
|
||||||
std::cout << labelMonth
|
std::cout << labelMonth
|
||||||
|
@ -361,21 +362,14 @@ static std::string renderMonth (const Datetime &previous, const Datetime &day)
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Includes trailing separator space.
|
// Includes trailing separator space.
|
||||||
static std::string renderWeek (
|
static std::string renderWeek (const Datetime &previous, const Datetime &day)
|
||||||
const std::string &type,
|
|
||||||
const Rules &rules,
|
|
||||||
const Datetime &previous,
|
|
||||||
const Datetime &day)
|
|
||||||
{
|
{
|
||||||
auto with_week = rules.getBoolean ("reports." + type + ".week");
|
|
||||||
|
|
||||||
const auto show_week = previous.week () != day.week ();
|
const auto show_week = previous.week () != day.week ();
|
||||||
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
if (with_week)
|
out << (show_week ? leftJustify (format ("W{1}", day.week ()), 3) : " ")
|
||||||
out << (show_week ? leftJustify (format ("W{1}", day.week ()), 3) : " ")
|
<< ' ';
|
||||||
<< ' ';
|
|
||||||
|
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue