mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
helper: Added intervalsFromHolidays
This commit is contained in:
parent
6e70c49c7f
commit
f9aac25c55
2 changed files with 22 additions and 0 deletions
|
@ -401,3 +401,24 @@ std::string jsonFromIntervals (const std::vector <Interval>& intervals)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::vector <Interval> intervalsFromHolidays (const Rules& rules)
|
||||||
|
{
|
||||||
|
std::vector <Interval> results;
|
||||||
|
for (auto& holiday : rules.all ("holidays."))
|
||||||
|
{
|
||||||
|
auto lastDot = holiday.rfind ('.');
|
||||||
|
if (lastDot != std::string::npos)
|
||||||
|
{
|
||||||
|
Interval h;
|
||||||
|
Datetime d (holiday.substr (lastDot + 1), "Y_M_D");
|
||||||
|
h.start (d);
|
||||||
|
++d;
|
||||||
|
h.end (d);
|
||||||
|
results.push_back (h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -54,6 +54,7 @@ Timeline createTimelineFromData (const Rules&, Database&, const Filter&);
|
||||||
Interval getLatestInterval (Database&);
|
Interval getLatestInterval (Database&);
|
||||||
bool intervalMatchesFilter (const Interval&, const Filter&);
|
bool intervalMatchesFilter (const Interval&, const Filter&);
|
||||||
std::string jsonFromIntervals (const std::vector <Interval>&);
|
std::string jsonFromIntervals (const std::vector <Interval>&);
|
||||||
|
std::vector <Interval> intervalsFromHolidays (const Rules&);
|
||||||
|
|
||||||
// utiŀ.cpp
|
// utiŀ.cpp
|
||||||
std::string osName ();
|
std::string osName ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue