mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-04 03:18:33 +02:00
Duration
- Allowed durations to be specified numerically as seconds, in string form. This flexibility allows the removal of special-case handling that stores recurrence periods in raw form ('monthly'), reducing code size. As a consequence this means that recurrence may now be rendered according to Duration::formatCompact, which is desirable. - Added supporting unit tests.
This commit is contained in:
parent
9a126ce717
commit
1714601ce4
2 changed files with 18 additions and 2 deletions
|
@ -134,7 +134,13 @@ Duration::Duration (const std::string& input)
|
|||
: mSecs (0)
|
||||
, mNegative (false)
|
||||
{
|
||||
parse (input);
|
||||
if (digitsOnly (input))
|
||||
{
|
||||
mSecs = (time_t) strtol (input.c_str (), NULL, 10);
|
||||
mNegative = false;
|
||||
}
|
||||
else
|
||||
parse (input);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -342,6 +348,12 @@ bool Duration::valid (const std::string& input)
|
|||
std::string units;
|
||||
n.getUntilEOS (units);
|
||||
|
||||
// Non-trivial value with no units means the duration is specified in
|
||||
// seconds, and therefore a time_t. Consider it valid.
|
||||
if (value != 0.0 &&
|
||||
units == "")
|
||||
return true;
|
||||
|
||||
// Auto complete against all supported durations.
|
||||
std::vector <std::string> supported;
|
||||
for (unsigned int i = 0; i < NUM_DURATIONS; ++i)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue