mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Adapt standard overlap resolution
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
parent
4aacba47df
commit
1c1066ae6c
1 changed files with 3 additions and 25 deletions
|
@ -97,6 +97,8 @@ static void autoAdjust (
|
||||||
Database& database,
|
Database& database,
|
||||||
Interval& interval)
|
Interval& interval)
|
||||||
{
|
{
|
||||||
|
const bool verbose = rules.getBoolean ("verbose");
|
||||||
|
|
||||||
Interval overlaps_filter {interval.start, interval.end};
|
Interval overlaps_filter {interval.start, interval.end};
|
||||||
auto overlaps = getTracked (database, rules, overlaps_filter);
|
auto overlaps = getTracked (database, rules, overlaps_filter);
|
||||||
|
|
||||||
|
@ -113,33 +115,9 @@ static void autoAdjust (
|
||||||
debug (" " + overlap.dump ());
|
debug (" " + overlap.dump ());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto verbose = rules.getBoolean ("verbose");
|
|
||||||
|
|
||||||
if (! adjust)
|
if (! adjust)
|
||||||
{
|
{
|
||||||
// standard overlap resolution: an open interval can truncate another open interval
|
throw std::string ("You cannot overlap intervals. Correct the start/end time, or specify the :adjust hint.");
|
||||||
if (overlaps.size () == 1)
|
|
||||||
{
|
|
||||||
auto overlap = overlaps[0];
|
|
||||||
|
|
||||||
if (overlap.is_open () && interval.is_open () && interval.startsWithin (overlap))
|
|
||||||
{
|
|
||||||
// start date of new interval within old interval
|
|
||||||
Interval modified {overlap};
|
|
||||||
modified.end = interval.start;
|
|
||||||
database.modifyInterval (overlap, modified, verbose);
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
{
|
|
||||||
std::cout << '\n' << intervalSummarize (database, rules, modified);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw std::string("You cannot overlap intervals. Correct the start/end "
|
|
||||||
"time, or specify the :adjust hint.");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue