From 82802f7f4753c16e3ec0839a93b3687123422772 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 16 Jul 2015 16:14:34 -0400 Subject: [PATCH] CmdInfo: Properly formats ISO durations --- src/commands/CmdInfo.cpp | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 259396f72..ee11a3801 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -351,25 +352,33 @@ int CmdInfo::execute (std::string& output) std::string type; for (auto& att: all) { - type = context.config.get ("uda." + att + ".type"); - if (type != "") + Column* col = context.columns[att]; + if (col && col->is_uda ()) { - Column* col = context.columns[att]; - if (col) + std::string value = task.get (att); + if (value != "") { - std::string value = task.get (att); - if (value != "") + row = view.addRow (); + view.set (row, 0, col->label ()); + + if (type == "date") + value = Date (value).toString (dateformat); + else if (type == "duration") { - row = view.addRow (); - view.set (row, 0, col->label ()); - - if (type == "date") - value = Date (value).toString (dateformat); - 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 (); - - view.set (row, 1, value); } + + view.set (row, 1, value); } } }