mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CmdInfo: Converted from ISO8601 to Datetime/Duration
This commit is contained in:
parent
c8bdfab4b4
commit
72076abc74
1 changed files with 19 additions and 18 deletions
|
@ -31,7 +31,8 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Filter.h>
|
#include <Filter.h>
|
||||||
#include <ISO8601.h>
|
#include <Datetime.h>
|
||||||
|
#include <Duration.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <shared.h>
|
#include <shared.h>
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
|
@ -114,7 +115,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
view.colorHeader (label);
|
view.colorHeader (label);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISO8601d now;
|
Datetime now;
|
||||||
|
|
||||||
// id
|
// id
|
||||||
int row = view.addRow ();
|
int row = view.addRow ();
|
||||||
|
@ -134,7 +135,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
for (auto& anno : annotations)
|
for (auto& anno : annotations)
|
||||||
description += '\n'
|
description += '\n'
|
||||||
+ std::string (indent, ' ')
|
+ std::string (indent, ' ')
|
||||||
+ ISO8601d (anno.first.substr (11)).toString (dateformatanno)
|
+ Datetime (anno.first.substr (11)).toString (dateformatanno)
|
||||||
+ ' '
|
+ ' '
|
||||||
+ anno.second;
|
+ anno.second;
|
||||||
|
|
||||||
|
@ -222,15 +223,15 @@ int CmdInfo::execute (std::string& output)
|
||||||
// entry
|
// entry
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, STRING_COLUMN_LABEL_ENTERED);
|
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 entry = dt.toString (dateformat);
|
||||||
|
|
||||||
std::string age;
|
std::string age;
|
||||||
std::string created = task.get ("entry");
|
std::string created = task.get ("entry");
|
||||||
if (created.length ())
|
if (created.length ())
|
||||||
{
|
{
|
||||||
ISO8601d dt (strtol (created.c_str (), NULL, 10));
|
Datetime dt (strtol (created.c_str (), NULL, 10));
|
||||||
age = ISO8601p (now - dt).formatVague ();
|
age = Duration (now - dt).formatVague ();
|
||||||
}
|
}
|
||||||
|
|
||||||
view.set (row, 1, entry + " (" + age + ')');
|
view.set (row, 1, entry + " (" + age + ')');
|
||||||
|
@ -240,7 +241,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, STRING_COLUMN_LABEL_WAITING);
|
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
|
// scheduled
|
||||||
|
@ -248,7 +249,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, STRING_COLUMN_LABEL_SCHED);
|
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
|
// start
|
||||||
|
@ -256,7 +257,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, STRING_COLUMN_LABEL_START);
|
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)
|
// due (colored)
|
||||||
|
@ -264,7 +265,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, STRING_COLUMN_LABEL_DUE);
|
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
|
// end
|
||||||
|
@ -272,7 +273,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, STRING_COLUMN_LABEL_END);
|
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
|
// until
|
||||||
|
@ -280,7 +281,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, STRING_CMD_INFO_UNTIL);
|
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
|
// modified
|
||||||
|
@ -289,8 +290,8 @@ int CmdInfo::execute (std::string& output)
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, STRING_CMD_INFO_MODIFIED);
|
view.set (row, 0, STRING_CMD_INFO_MODIFIED);
|
||||||
|
|
||||||
ISO8601d mod (task.get_date ("modified"));
|
Datetime mod (task.get_date ("modified"));
|
||||||
std::string age = ISO8601p (now - mod).formatVague ();
|
std::string age = Duration (now - mod).formatVague ();
|
||||||
view.set (row, 1, mod.toString (dateformat) + " (" + age + ')');
|
view.set (row, 1, mod.toString (dateformat) + " (" + age + ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,13 +376,13 @@ int CmdInfo::execute (std::string& output)
|
||||||
view.set (row, 0, col->label ());
|
view.set (row, 0, col->label ());
|
||||||
|
|
||||||
if (type == "date")
|
if (type == "date")
|
||||||
value = ISO8601d (value).toString (dateformat);
|
value = Datetime (value).toString (dateformat);
|
||||||
else if (type == "duration")
|
else if (type == "duration")
|
||||||
{
|
{
|
||||||
ISO8601p iso;
|
Duration iso;
|
||||||
std::string::size_type cursor = 0;
|
std::string::size_type cursor = 0;
|
||||||
if (iso.parse (value, cursor))
|
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
|
else
|
||||||
value = "PT0S";
|
value = "PT0S";
|
||||||
}
|
}
|
||||||
|
@ -546,7 +547,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int row = journal.addRow ();
|
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));
|
journal.set (row, 0, timestamp.toString (dateformat));
|
||||||
|
|
||||||
Task before (undo[previous].substr (4));
|
Task before (undo[previous].substr (4));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue