From 6890fd32c7d97dacba9bb70a1617a790f0ba210c Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 16 Jul 2015 16:15:47 -0400 Subject: [PATCH] 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. --- src/Task.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Task.cpp b/src/Task.cpp index 26a066742..15cea7b42 100644 --- a/src/Task.cpp +++ b/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") {