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);
|
||||
|
||||
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 (
|
||||
|
@ -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 labelWeek = with_week ? renderWeek (previous, day) : "";
|
||||
|
@ -414,25 +415,22 @@ static std::string renderDay (Datetime& day, const Color& color)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color getDayColor (
|
||||
const Datetime& day,
|
||||
const Datetime& now,
|
||||
const std::vector <std::string>& holidays,
|
||||
const Color& colorToday,
|
||||
const Color& colorHoliday)
|
||||
{
|
||||
Color color;
|
||||
|
||||
if (day.sameDay (Datetime ()))
|
||||
if (day.sameDay (now))
|
||||
{
|
||||
color = colorToday;
|
||||
return colorToday;
|
||||
}
|
||||
else
|
||||
|
||||
if (dayIsHoliday (day, holidays))
|
||||
{
|
||||
if (dayIsHoliday (day, holidays))
|
||||
{
|
||||
color = colorHoliday;
|
||||
}
|
||||
return colorHoliday;
|
||||
}
|
||||
|
||||
return color;
|
||||
return Color {};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue