mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-27 19:17:19 +02:00
Code Cleanup
- Migrated the recur.cpp getDueState() function into Task::getDateState(), which can assess any date attribute. - Improved implementation to distinguish between: - not due, or not due for rc.due days - due after today - due later today - due earlier today - due before today This greater precision should address some outstanding issues.
This commit is contained in:
parent
5706cca207
commit
c933ed2cf7
6 changed files with 68 additions and 88 deletions
46
src/Task.cpp
46
src/Task.cpp
|
@ -323,6 +323,40 @@ void Task::setStatus (Task::status status)
|
|||
recalc_urgency = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Determines status of a date attribute.
|
||||
Task::dateState Task::getDateState (const std::string& name) const
|
||||
{
|
||||
std::string value = get (name);
|
||||
if (value.length ())
|
||||
{
|
||||
Date reference (value);
|
||||
Date now;
|
||||
Date today ("today");
|
||||
|
||||
if (reference < today)
|
||||
return dateBeforeToday;
|
||||
|
||||
if (reference.sameDay (now))
|
||||
{
|
||||
if (reference < now)
|
||||
return dateEarlierToday;
|
||||
else
|
||||
return dateLaterToday;
|
||||
}
|
||||
|
||||
int imminentperiod = context.config.getInteger ("due");
|
||||
if (imminentperiod == 0)
|
||||
return dateAfterToday;
|
||||
|
||||
Date imminentDay = today + imminentperiod * 86400;
|
||||
if (reference < imminentDay)
|
||||
return dateAfterToday;
|
||||
}
|
||||
|
||||
return dateNotDue;
|
||||
}
|
||||
|
||||
#ifdef PRODUCT_TASKWARRIOR
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Ready means pending, not blocked and either not scheduled or scheduled before
|
||||
|
@ -345,7 +379,9 @@ bool Task::is_due () const
|
|||
if (status != Task::completed &&
|
||||
status != Task::deleted)
|
||||
{
|
||||
if (getDueState (get ("due")) == 1)
|
||||
Task::dateState state = getDateState ("due");
|
||||
if (state == dateAfterToday ||
|
||||
state == dateLaterToday)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +417,9 @@ bool Task::is_duetoday () const
|
|||
if (status != Task::completed &&
|
||||
status != Task::deleted)
|
||||
{
|
||||
if (getDueState (get ("due")) == 2)
|
||||
Task::dateState state = getDateState ("due");
|
||||
if (state == dateEarlierToday ||
|
||||
state == dateLaterToday)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -479,7 +517,9 @@ bool Task::is_overdue () const
|
|||
if (status != Task::completed &&
|
||||
status != Task::deleted)
|
||||
{
|
||||
if (getDueState (get ("due")) == 3)
|
||||
Task::dateState state = getDateState ("due");
|
||||
if (state == dateEarlierToday ||
|
||||
state == dateBeforeToday)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue