CmdEdit: Duration replaced by ISO8601p

This commit is contained in:
Paul Beckingham 2015-08-12 10:17:58 -04:00
parent e8fe7f0304
commit 830b3e9562

View file

@ -31,7 +31,7 @@
#include <cstring> #include <cstring>
#include <algorithm> #include <algorithm>
#include <unistd.h> #include <unistd.h>
#include <Duration.h> #include <ISO8601.h>
#include <Context.h> #include <Context.h>
#include <Filter.h> #include <Filter.h>
#include <Nibbler.h> #include <Nibbler.h>
@ -184,8 +184,8 @@ std::string CmdEdit::formatDuration (
std::string value = task.get (attribute); std::string value = task.get (attribute);
if (value.length ()) if (value.length ())
{ {
Duration dur (value); ISO8601p dur (value);
value = dur.formatSeconds (); value = dur.format ();
} }
return value; return value;
@ -546,9 +546,9 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
{ {
if (value != "") if (value != "")
{ {
Duration d; ISO8601p p;
std::string::size_type idx = 0; std::string::size_type idx = 0;
if (d.parse (value, idx)) if (p.parse (value, idx))
{ {
context.footnote (STRING_EDIT_RECUR_MOD); context.footnote (STRING_EDIT_RECUR_MOD);
if (task.get ("due") != "") if (task.get ("due") != "")
@ -686,7 +686,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
if ((task.get (col.first) != value) && (type != "date" || if ((task.get (col.first) != value) && (type != "date" ||
(task.get (col.first) != Date (value, dateformat).toEpochString ())) && (task.get (col.first) != Date (value, dateformat).toEpochString ())) &&
(type != "duration" || (type != "duration" ||
(task.get (col.first) != (std::string) Duration (value)))) (task.get (col.first) != (std::string) ISO8601p (value))))
{ {
if (value != "") if (value != "")
{ {
@ -708,13 +708,11 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
} }
else if (type == "date") else if (type == "date")
{ {
Date d (value, dateformat); task.set (col.first, Date (value, dateformat).toEpochString ());
task.set (col.first, d.toEpochString ());
} }
else if (type == "duration") else if (type == "duration")
{ {
Duration d (value); task.set (col.first, (time_t) ISO8601p (value));
task.set (col.first, (time_t) d);
} }
} }
else else