CmdInfo: Properly formats ISO durations
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Filter.h>
|
#include <Filter.h>
|
||||||
|
#include <ISO8601.h>
|
||||||
#include <Date.h>
|
#include <Date.h>
|
||||||
#include <Duration.h>
|
#include <Duration.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
@@ -350,12 +351,9 @@ int CmdInfo::execute (std::string& output)
|
|||||||
std::vector <std::string> all = task.all ();
|
std::vector <std::string> all = task.all ();
|
||||||
std::string type;
|
std::string type;
|
||||||
for (auto& att: all)
|
for (auto& att: all)
|
||||||
{
|
|
||||||
type = context.config.get ("uda." + att + ".type");
|
|
||||||
if (type != "")
|
|
||||||
{
|
{
|
||||||
Column* col = context.columns[att];
|
Column* col = context.columns[att];
|
||||||
if (col)
|
if (col && col->is_uda ())
|
||||||
{
|
{
|
||||||
std::string value = task.get (att);
|
std::string value = task.get (att);
|
||||||
if (value != "")
|
if (value != "")
|
||||||
@@ -366,13 +364,24 @@ int CmdInfo::execute (std::string& output)
|
|||||||
if (type == "date")
|
if (type == "date")
|
||||||
value = Date (value).toString (dateformat);
|
value = Date (value).toString (dateformat);
|
||||||
else if (type == "duration")
|
else if (type == "duration")
|
||||||
|
{
|
||||||
|
if (value[0] == 'P')
|
||||||
|
{
|
||||||
|
ISO8601p iso;
|
||||||
|
std::string::size_type cursor = 0;
|
||||||
|
if (iso.parse (value, cursor))
|
||||||
|
value = (std::string) Variant ((time_t) iso._value, Variant::type_duration);
|
||||||
|
else
|
||||||
|
value = "PT0S";
|
||||||
|
}
|
||||||
|
else
|
||||||
value = Duration (value).formatCompact ();
|
value = Duration (value).formatCompact ();
|
||||||
|
}
|
||||||
|
|
||||||
view.set (row, 1, value);
|
view.set (row, 1, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Show any orphaned UDAs, which are identified by not being represented in
|
// Show any orphaned UDAs, which are identified by not being represented in
|
||||||
// the context.columns map.
|
// the context.columns map.
|
||||||
|
|||||||
Reference in New Issue
Block a user