mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Split renderDayName into renderWeekday and renderDay
This commit is contained in:
parent
227344063e
commit
12140859dc
1 changed files with 28 additions and 6 deletions
|
@ -40,7 +40,8 @@ static std::pair<int, int> determineHourRange (const std::string&, const Rules&,
|
||||||
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&, const Datetime&);
|
static std::string renderMonth (const Datetime&, const Datetime&);
|
||||||
static std::string renderWeek (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 renderWeekday (const std::string&, const Rules&, Datetime&, Color&, Color&);
|
||||||
|
static std::string renderDay (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);
|
||||||
static void renderExclusionBlocks (const std::string&, const Rules&, std::vector <Composite>&, bool, const Datetime&, int, int, const std::vector <Range>&);
|
static void renderExclusionBlocks (const std::string&, const Rules&, std::vector <Composite>&, bool, const Datetime&, int, int, const std::vector <Range>&);
|
||||||
|
@ -201,10 +202,12 @@ int renderChart (
|
||||||
|
|
||||||
auto labelMonth = with_month ? renderMonth (previous, day) : "";
|
auto labelMonth = with_month ? renderMonth (previous, day) : "";
|
||||||
auto labelWeek = with_week ? renderWeek (previous, day) : "";
|
auto labelWeek = with_week ? renderWeek (previous, day) : "";
|
||||||
auto labelDay = renderDayName (type, rules, day, colorToday, colorHoliday);
|
auto labelWeekday = renderWeekday (type, rules, day, colorToday, colorHoliday);
|
||||||
|
auto labelDay = renderDay (type, rules, day, colorToday, colorHoliday);
|
||||||
|
|
||||||
std::cout << labelMonth
|
std::cout << labelMonth
|
||||||
<< labelWeek
|
<< labelWeek
|
||||||
|
<< labelWeekday
|
||||||
<< labelDay
|
<< labelDay
|
||||||
<< lines[0].str ();
|
<< lines[0].str ();
|
||||||
|
|
||||||
|
@ -377,14 +380,13 @@ static std::string renderWeek (const Datetime &previous, const Datetime &day)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Today should be highlighted.
|
// Today should be highlighted.
|
||||||
// Includes trailing separator space.
|
// Includes trailing separator space.
|
||||||
static std::string renderDayName (
|
static std::string renderWeekday (
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const Rules& rules,
|
const Rules& rules,
|
||||||
Datetime& day,
|
Datetime& day,
|
||||||
Color& colorToday,
|
Color& colorToday,
|
||||||
Color& colorHoliday)
|
Color& colorHoliday)
|
||||||
{
|
{
|
||||||
auto showDay = rules.getBoolean ("reports." + type + ".day");
|
|
||||||
auto showWeekday = rules.getBoolean ("reports." + type + ".weekday");
|
auto showWeekday = rules.getBoolean ("reports." + type + ".weekday");
|
||||||
|
|
||||||
Color color;
|
Color color;
|
||||||
|
@ -398,6 +400,26 @@ static std::string renderDayName (
|
||||||
out << color.colorize (Datetime::dayNameShort (day.dayOfWeek ()))
|
out << color.colorize (Datetime::dayNameShort (day.dayOfWeek ()))
|
||||||
<< ' ';
|
<< ' ';
|
||||||
|
|
||||||
|
return out.str ();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
static std::string renderDay (
|
||||||
|
const std::string& type,
|
||||||
|
const Rules& rules,
|
||||||
|
Datetime& day,
|
||||||
|
Color& colorToday,
|
||||||
|
Color& colorHoliday)
|
||||||
|
{
|
||||||
|
auto showDay = rules.getBoolean ("reports." + type + ".day");
|
||||||
|
|
||||||
|
Color color;
|
||||||
|
if (day.sameDay (Datetime ()))
|
||||||
|
color = colorToday;
|
||||||
|
else if (dayIsHoliday (rules, day))
|
||||||
|
color = colorHoliday;
|
||||||
|
|
||||||
|
std::stringstream out;
|
||||||
if (showDay)
|
if (showDay)
|
||||||
out << color.colorize (rightJustify (day.day (), 2))
|
out << color.colorize (rightJustify (day.day (), 2))
|
||||||
<< ' ';
|
<< ' ';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue