mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Extract 'now' from getDayColor
- Use early returns
This commit is contained in:
parent
c30f4b1e66
commit
ccb41e6501
1 changed files with 10 additions and 12 deletions
|
@ -51,7 +51,7 @@ static std::string renderSummary (const std::string&, const Interval&, c
|
||||||
|
|
||||||
unsigned long getIndentSize (const std::string &type, const Rules &rules);
|
unsigned long getIndentSize (const std::string &type, const Rules &rules);
|
||||||
|
|
||||||
Color getDayColor (const Datetime&, const std::vector <std::string>&, const Color&, const Color&);
|
Color getDayColor (const Datetime&, const Datetime&, const std::vector<std::string>&, const Color&, const Color&);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdChartDay (
|
int CmdChartDay (
|
||||||
|
@ -223,7 +223,8 @@ int renderChart (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto color_day = getDayColor (day, holidays, color_today, color_holiday);
|
auto now = Datetime ();
|
||||||
|
auto color_day = getDayColor (day, now, holidays, color_today, color_holiday);
|
||||||
|
|
||||||
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) : "";
|
||||||
|
@ -414,25 +415,22 @@ static std::string renderDay (Datetime& day, const Color& color)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Color getDayColor (
|
Color getDayColor (
|
||||||
const Datetime& day,
|
const Datetime& day,
|
||||||
|
const Datetime& now,
|
||||||
const std::vector <std::string>& holidays,
|
const std::vector <std::string>& holidays,
|
||||||
const Color& colorToday,
|
const Color& colorToday,
|
||||||
const Color& colorHoliday)
|
const Color& colorHoliday)
|
||||||
{
|
{
|
||||||
Color color;
|
if (day.sameDay (now))
|
||||||
|
|
||||||
if (day.sameDay (Datetime ()))
|
|
||||||
{
|
{
|
||||||
color = colorToday;
|
return colorToday;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (dayIsHoliday (day, holidays))
|
||||||
{
|
{
|
||||||
if (dayIsHoliday (day, holidays))
|
return colorHoliday;
|
||||||
{
|
|
||||||
color = colorHoliday;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return color;
|
return Color {};
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue