mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Performance improvements:
- Added parse-free convenience functions
This commit is contained in:
parent
53d829cfc1
commit
873376c287
6 changed files with 61 additions and 25 deletions
|
@ -386,7 +386,7 @@ int getDueState (const std::string& due)
|
|||
Date dt (::atoi (due.c_str ()));
|
||||
|
||||
// rightNow is the current date + time.
|
||||
Date rightNow;
|
||||
static Date rightNow;
|
||||
Date thisDay (rightNow.month (), rightNow.day (), rightNow.year ());
|
||||
|
||||
if (dt < rightNow)
|
||||
|
@ -408,6 +408,36 @@ int getDueState (const std::string& due)
|
|||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Determines whether a task is overdue. Returns
|
||||
// 0 = not due at all
|
||||
// 1 = imminent
|
||||
// 2 = today
|
||||
// 3 = overdue
|
||||
int getDueState (const Date& due)
|
||||
{
|
||||
// rightNow is the current date + time.
|
||||
static Date rightNow;
|
||||
Date thisDay (rightNow.month (), rightNow.day (), rightNow.year ());
|
||||
|
||||
if (due < rightNow)
|
||||
return 3;
|
||||
|
||||
if (rightNow.sameDay (due))
|
||||
return 2;
|
||||
|
||||
int imminentperiod = context.config.getInteger ("due");
|
||||
|
||||
if (imminentperiod == 0)
|
||||
return 1;
|
||||
|
||||
Date imminentDay = thisDay + imminentperiod * 86400;
|
||||
if (due < imminentDay)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Returns a Boolean indicator as to whether a nag message was generated, so
|
||||
// that commands can control the number of nag messages displayed (ie one is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue