mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Task: Duration handling improvements
- Separated handling for 'recur' (store in raw form) and type 'duration' attributes (store formatted). - Added missing storage handling for type duration attributes.
This commit is contained in:
parent
76d3efe313
commit
6890fd32c7
1 changed files with 23 additions and 2 deletions
25
src/Task.cpp
25
src/Task.cpp
|
@ -2002,8 +2002,7 @@ void Task::modify (modType type, bool text_required /* = false */)
|
|||
|
||||
// Special case: type duration.
|
||||
// Note: "recur" is marked as type "string" to force storage in raw form.
|
||||
else if (name == "recur" ||
|
||||
column->type () == "duration")
|
||||
else if (name == "recur")
|
||||
{
|
||||
// The duration is stored in raw form, but it must still be valid,
|
||||
// and therefore is parsed first.
|
||||
|
@ -2025,6 +2024,28 @@ void Task::modify (modType type, bool text_required /* = false */)
|
|||
throw format (STRING_TASK_INVALID_DUR, value);
|
||||
}
|
||||
|
||||
else if (column->type () == "duration")
|
||||
{
|
||||
// The duration is stored in raw form, but it must still be valid,
|
||||
// and therefore is parsed first.
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
e.addSource (namedDates);
|
||||
contextTask = *this;
|
||||
|
||||
Variant v;
|
||||
e.evaluateInfixExpression (value, v);
|
||||
if (v.type () == Variant::type_duration)
|
||||
{
|
||||
// Store the raw value, for 'recur'.
|
||||
context.debug (label + name + " <-- " + (std::string)v + " <-- '" + value + "'");
|
||||
set (name, v);
|
||||
++modCount;
|
||||
}
|
||||
else
|
||||
throw format (STRING_TASK_INVALID_DUR, value);
|
||||
}
|
||||
|
||||
// Need handling for numeric types, used by UDAs.
|
||||
else if (column->type () == "numeric")
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue