From 2b135ed3c22518aac29a6f565d7a3a46424e24bb Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 9 Jul 2011 09:03:15 -0400 Subject: [PATCH] Expressions - Variants can now construct dates and duration from std::string. --- src/Variant.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Variant.cpp b/src/Variant.cpp index 4e048bbfd..5c186f126 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -590,8 +590,21 @@ void Variant::input (const std::string& input) return; } - // TODO Attempt Date (input) parse. - // TODO Attempt Duration (input) parse. + // Attempt Date (input) parse. + if (Date::valid (input, context.config.get ("dateformat"))) + { + _type = v_date; + _date = Date (input); + return; + } + + // Attempt Duration (input) parse. + if (Duration::valid (input)) + { + _type = v_duration; + _duration = Duration (input); + return; + } bool numeric = true; bool period = false;