Bug TW-1274

- TW-1274 Map 'modification' attribute to 'modified' (thanks to jck).
This commit is contained in:
Paul Beckingham 2014-02-22 11:57:21 -05:00
parent 14b1ba4151
commit 61a9703ab4
4 changed files with 36 additions and 11 deletions

View file

@ -199,4 +199,4 @@ suggestions:
Kosta H Kosta H
Hector Arciga Hector Arciga
Jan Kunder Jan Kunder
jck

View file

@ -15,6 +15,7 @@ Features
+ TW-1260 New virtual tags YESTERDAY, TOMORROW. + TW-1260 New virtual tags YESTERDAY, TOMORROW.
+ TW-1261 Migrate test bug.360.t to new unit testing framework (thanks to + TW-1261 Migrate test bug.360.t to new unit testing framework (thanks to
Renato Alves). Renato Alves).
+ TW-1274 Map 'modification' attribute to 'modified' (thanks to jck).
+ Removed deprecated 'echo.command' setting, in favor of the 'header' and + Removed deprecated 'echo.command' setting, in favor of the 'header' and
'affected' verbosity tokens. 'affected' verbosity tokens.
+ Removed deprecated 'edit.verbose' setting, in favor of the 'edit' verbosity + Removed deprecated 'edit.verbose' setting, in favor of the 'edit' verbosity

View file

@ -539,6 +539,10 @@ void Task::parse (const std::string& input)
value[value.length () - 1] == 'm') value[value.length () - 1] == 'm')
value += 'o'; value += 'o';
// TW-1274, Standardization.
if (name == "modification")
name = "modified";
if (name.substr (0, 11) == "annotation_") if (name.substr (0, 11) == "annotation_")
++annotation_count; ++annotation_count;
@ -596,6 +600,13 @@ void Task::parseJSON (const std::string& line)
else if (i->first == "urgency") 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. // Dates are converted from ISO to epoch.
else if (type == "date") else if (type == "date")
{ {
@ -604,7 +615,7 @@ void Task::parseJSON (const std::string& line)
} }
// Tags are an array of JSON strings. // 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* tags = (json::array*)i->second;
json_array_iter t; json_array_iter t;
@ -616,6 +627,13 @@ void Task::parseJSON (const std::string& line)
addTag (tag->_data); 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. // Strings are decoded.
else if (type == "string") else if (type == "string")
@ -818,7 +836,10 @@ std::string Task::composeF4 () const
{ {
ff4 += (first ? "" : " ") ff4 += (first ? "" : " ")
+ it->first + it->first
+ ":\"" + encode (json::encode (it->second)) + "\""; + ":\""
+ encode (json::encode (it->second))
+ "\"";
first = false; first = false;
} }
} }
@ -858,11 +879,16 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
if (type == "date") if (type == "date")
{ {
Date d (i->second); Date d (i->second);
out << "\"" if (i->first == "modification")
<< i->first out << "\"modified\":\""
<< "\":\"" << d.toISO ()
<< d.toISO () << "\"";
<< "\""; else
out << "\""
<< i->first
<< "\":\""
<< d.toISO ()
<< "\"";
++attributes_written; ++attributes_written;
} }

View file

@ -289,10 +289,8 @@ int CmdInfo::execute (std::string& output)
view.set (row, 0, STRING_CMD_INFO_MODIFIED); view.set (row, 0, STRING_CMD_INFO_MODIFIED);
Date mod (task->get_date ("modified")); Date mod (task->get_date ("modified"));
std::string age = OldDuration (now - mod).format (); std::string age = OldDuration (now - mod).format ();
view.set (row, 1, Date (task->get_date ("modified")).toString (dateformat) + view.set (row, 1, mod.toString (dateformat) + " (" + age + ")");
" (" + age + ")");
} }
// tags ... // tags ...