Performance improvements:

- Added parse-free convenience functions
This commit is contained in:
Paul Beckingham 2012-05-05 13:24:11 -04:00
parent 53d829cfc1
commit 873376c287
6 changed files with 61 additions and 25 deletions

View file

@ -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