mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
helper: Added intervalMatchesFilter()
This commit is contained in:
parent
2e8082a2ab
commit
b554b299a1
2 changed files with 19 additions and 0 deletions
|
@ -173,3 +173,21 @@ Interval getLatestInterval (
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// An interval matches a filter if the start/end overlaps, and all filter tags
|
||||||
|
// are found in the interval.
|
||||||
|
bool intervalMatchesFilter (const Interval& interval, const Filter& filter)
|
||||||
|
{
|
||||||
|
if (interval.end () > filter.start () &&
|
||||||
|
interval.start () < filter.end ())
|
||||||
|
{
|
||||||
|
for (auto& tag : filter.tags ())
|
||||||
|
if (! interval.hasTag (tag))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -50,6 +50,7 @@ void expandIntervalHint (const std::string&, std::string&, std::string&);
|
||||||
Filter createFilterFromCLI (const CLI&);
|
Filter createFilterFromCLI (const CLI&);
|
||||||
Timeline createTimelineFromData (const Rules&, Database&, const Filter&);
|
Timeline createTimelineFromData (const Rules&, Database&, const Filter&);
|
||||||
Interval getLatestInterval (Timeline&, Database&, const Filter&);
|
Interval getLatestInterval (Timeline&, Database&, const Filter&);
|
||||||
|
bool intervalMatchesFilter (const Interval&, const Filter&);
|
||||||
|
|
||||||
// utiŀ.cpp
|
// utiŀ.cpp
|
||||||
std::string osName ();
|
std::string osName ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue