From 2f61a7e946564adafce799acd375890cf8ac7603 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Wed, 5 Aug 2015 17:06:43 -0400 Subject: [PATCH] TW-1630: "Due" parsing behavior seems inconsistent - Thanks to Jim B. --- ChangeLog | 1 + src/Variant.cpp | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index becd5c72d..3bc8f404f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -81,6 +81,7 @@ - TW-1627 'mon' is replaced with date in project field (thanks to James Cline). - TW-1629 Descriptions often get overwritten with "( or )" (thanks to Jeremy John Reeder). +- TW-1630 "Due" parsing behavior seems inconsistent (thanks to Jim B). - TW-1632 Japanese translation for Taskwarrior(150713) (thanks to ribbon). - TW-1634 due.not: excludes only tasks scheduled at mitnight (thanks to Tomas Babej). diff --git a/src/Variant.cpp b/src/Variant.cpp index 87bed2898..f795e54b7 100644 --- a/src/Variant.cpp +++ b/src/Variant.cpp @@ -1942,11 +1942,32 @@ void Variant::cast (const enum type new_type) pos == _string.length ()) { _date = (time_t) iso; + break; } - else if (dateFormat != "") + + pos = 0; + ISO8601p isop; + if (isoEnabled && + isop.parse (_string, pos) && + pos == _string.length ()) { - Date d (_string, dateFormat); - _date = d.toEpoch (); + _date = Date ().toEpoch () + (time_t) isop; + break; + } + + pos = 0; + Duration dur; + if (dur.parse (_string, pos) && + pos == _string.length ()) + { + _date = Date ().toEpoch () + (time_t) dur; + break; + } + + if (dateFormat != "") + { + _date = Date (_string, dateFormat).toEpoch (); + break; } } break;