CmdInfo: Converted from ISO8601 to Datetime/Duration

This commit is contained in:
Paul Beckingham 2016-12-11 22:27:18 -05:00
parent c8bdfab4b4
commit 72076abc74

View file

@ -31,7 +31,8 @@
#include <math.h>
#include <Context.h>
#include <Filter.h>
#include <ISO8601.h>
#include <Datetime.h>
#include <Duration.h>
#include <main.h>
#include <shared.h>
#include <format.h>
@ -114,7 +115,7 @@ int CmdInfo::execute (std::string& output)
view.colorHeader (label);
}
ISO8601d now;
Datetime now;
// id
int row = view.addRow ();
@ -134,7 +135,7 @@ int CmdInfo::execute (std::string& output)
for (auto& anno : annotations)
description += '\n'
+ std::string (indent, ' ')
+ ISO8601d (anno.first.substr (11)).toString (dateformatanno)
+ Datetime (anno.first.substr (11)).toString (dateformatanno)
+ ' '
+ anno.second;
@ -222,15 +223,15 @@ int CmdInfo::execute (std::string& output)
// entry
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_ENTERED);
ISO8601d dt (task.get_date ("entry"));
Datetime dt (task.get_date ("entry"));
std::string entry = dt.toString (dateformat);
std::string age;
std::string created = task.get ("entry");
if (created.length ())
{
ISO8601d dt (strtol (created.c_str (), NULL, 10));
age = ISO8601p (now - dt).formatVague ();
Datetime dt (strtol (created.c_str (), NULL, 10));
age = Duration (now - dt).formatVague ();
}
view.set (row, 1, entry + " (" + age + ')');
@ -240,7 +241,7 @@ int CmdInfo::execute (std::string& output)
{
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_WAITING);
view.set (row, 1, ISO8601d (task.get_date ("wait")).toString (dateformat));
view.set (row, 1, Datetime (task.get_date ("wait")).toString (dateformat));
}
// scheduled
@ -248,7 +249,7 @@ int CmdInfo::execute (std::string& output)
{
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_SCHED);
view.set (row, 1, ISO8601d (task.get_date ("scheduled")).toString (dateformat));
view.set (row, 1, Datetime (task.get_date ("scheduled")).toString (dateformat));
}
// start
@ -256,7 +257,7 @@ int CmdInfo::execute (std::string& output)
{
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_START);
view.set (row, 1, ISO8601d (task.get_date ("start")).toString (dateformat));
view.set (row, 1, Datetime (task.get_date ("start")).toString (dateformat));
}
// due (colored)
@ -264,7 +265,7 @@ int CmdInfo::execute (std::string& output)
{
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_DUE);
view.set (row, 1, ISO8601d (task.get_date ("due")).toString (dateformat));
view.set (row, 1, Datetime (task.get_date ("due")).toString (dateformat));
}
// end
@ -272,7 +273,7 @@ int CmdInfo::execute (std::string& output)
{
row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_END);
view.set (row, 1, ISO8601d (task.get_date ("end")).toString (dateformat));
view.set (row, 1, Datetime (task.get_date ("end")).toString (dateformat));
}
// until
@ -280,7 +281,7 @@ int CmdInfo::execute (std::string& output)
{
row = view.addRow ();
view.set (row, 0, STRING_CMD_INFO_UNTIL);
view.set (row, 1, ISO8601d (task.get_date ("until")).toString (dateformat));
view.set (row, 1, Datetime (task.get_date ("until")).toString (dateformat));
}
// modified
@ -289,8 +290,8 @@ int CmdInfo::execute (std::string& output)
row = view.addRow ();
view.set (row, 0, STRING_CMD_INFO_MODIFIED);
ISO8601d mod (task.get_date ("modified"));
std::string age = ISO8601p (now - mod).formatVague ();
Datetime mod (task.get_date ("modified"));
std::string age = Duration (now - mod).formatVague ();
view.set (row, 1, mod.toString (dateformat) + " (" + age + ')');
}
@ -375,13 +376,13 @@ int CmdInfo::execute (std::string& output)
view.set (row, 0, col->label ());
if (type == "date")
value = ISO8601d (value).toString (dateformat);
value = Datetime (value).toString (dateformat);
else if (type == "duration")
{
ISO8601p iso;
Duration iso;
std::string::size_type cursor = 0;
if (iso.parse (value, cursor))
value = (std::string) Variant ((time_t) iso, Variant::type_duration);
value = (std::string) Variant (iso.toTime_t (), Variant::type_duration);
else
value = "PT0S";
}
@ -546,7 +547,7 @@ int CmdInfo::execute (std::string& output)
{
int row = journal.addRow ();
ISO8601d timestamp (strtol (undo[when].substr (5).c_str (), NULL, 10));
Datetime timestamp (strtol (undo[when].substr (5).c_str (), NULL, 10));
journal.set (row, 0, timestamp.toString (dateformat));
Task before (undo[previous].substr (4));