From 61a9703ab43347d4144a71952e7e23774b7b2798 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 22 Feb 2014 11:57:21 -0500 Subject: [PATCH] Bug TW-1274 - TW-1274 Map 'modification' attribute to 'modified' (thanks to jck). --- AUTHORS | 2 +- ChangeLog | 1 + src/Task.cpp | 40 +++++++++++++++++++++++++++++++++------- src/commands/CmdInfo.cpp | 4 +--- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/AUTHORS b/AUTHORS index a85fd1d20..224452557 100644 --- a/AUTHORS +++ b/AUTHORS @@ -199,4 +199,4 @@ suggestions: Kosta H Hector Arciga Jan Kunder - + jck diff --git a/ChangeLog b/ChangeLog index b3f94007e..f13ba7c46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ Features + TW-1260 New virtual tags YESTERDAY, TOMORROW. + TW-1261 Migrate test bug.360.t to new unit testing framework (thanks to Renato Alves). + + TW-1274 Map 'modification' attribute to 'modified' (thanks to jck). + Removed deprecated 'echo.command' setting, in favor of the 'header' and 'affected' verbosity tokens. + Removed deprecated 'edit.verbose' setting, in favor of the 'edit' verbosity diff --git a/src/Task.cpp b/src/Task.cpp index dbf612c37..27149e258 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -539,6 +539,10 @@ void Task::parse (const std::string& input) value[value.length () - 1] == 'm') value += 'o'; + // TW-1274, Standardization. + if (name == "modification") + name = "modified"; + if (name.substr (0, 11) == "annotation_") ++annotation_count; @@ -596,6 +600,13 @@ void Task::parseJSON (const std::string& line) else if (i->first == "urgency") ; + // TW-1274 Standardization. + else if (i->first == "modification") + { + Date d (unquoteText (i->second->dump ())); + set ("modified", d.toEpochString ()); + } + // Dates are converted from ISO to epoch. else if (type == "date") { @@ -604,7 +615,7 @@ void Task::parseJSON (const std::string& line) } // Tags are an array of JSON strings. - else if (i->first == "tags") + else if (i->first == "tags" && i->second->type() == json::j_array) { json::array* tags = (json::array*)i->second; json_array_iter t; @@ -616,6 +627,13 @@ void Task::parseJSON (const std::string& line) addTag (tag->_data); } } + // This is a temporary measure to allow Mirakel sync, and will be removed + // in a future release. + else if (i->first == "tags" && i->second->type() == json::j_string) + { + json::string* tag = (json::string*)i->second; + addTag (tag->_data); + } // Strings are decoded. else if (type == "string") @@ -818,7 +836,10 @@ std::string Task::composeF4 () const { ff4 += (first ? "" : " ") + it->first - + ":\"" + encode (json::encode (it->second)) + "\""; + + ":\"" + + encode (json::encode (it->second)) + + "\""; + first = false; } } @@ -858,11 +879,16 @@ std::string Task::composeJSON (bool decorate /*= false*/) const if (type == "date") { Date d (i->second); - out << "\"" - << i->first - << "\":\"" - << d.toISO () - << "\""; + if (i->first == "modification") + out << "\"modified\":\"" + << d.toISO () + << "\""; + else + out << "\"" + << i->first + << "\":\"" + << d.toISO () + << "\""; ++attributes_written; } diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 1e95d63c7..76db83895 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -289,10 +289,8 @@ int CmdInfo::execute (std::string& output) view.set (row, 0, STRING_CMD_INFO_MODIFIED); Date mod (task->get_date ("modified")); - std::string age = OldDuration (now - mod).format (); - view.set (row, 1, Date (task->get_date ("modified")).toString (dateformat) + - " (" + age + ")"); + view.set (row, 1, mod.toString (dateformat) + " (" + age + ")"); } // tags ...