mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 13:37:20 +02:00
Taskd
- Modified Task::composeJSON to use ISO 8601 date format, and the new hierarchical annotation format.
This commit is contained in:
parent
c08c280dd9
commit
68fe437889
1 changed files with 60 additions and 6 deletions
56
src/Task.cpp
56
src/Task.cpp
|
@ -430,17 +430,71 @@ std::string Task::composeJSON () const
|
|||
std::stringstream out;
|
||||
out << "{";
|
||||
|
||||
// Used for determining type.
|
||||
Att att;
|
||||
|
||||
// First the non-annotations.
|
||||
int attributes_written = 0;
|
||||
int annotation_count = 0;
|
||||
std::map <std::string, Att>::const_iterator i;
|
||||
for (i = this->begin (); i != this->end (); ++i)
|
||||
{
|
||||
if (i != this->begin ())
|
||||
if (attributes_written)
|
||||
out << ",";
|
||||
|
||||
if (i->second.name ().substr (0, 11) == "annotation_")
|
||||
{
|
||||
++annotation_count;
|
||||
}
|
||||
else if (att.type (i->second.name ()) == "date")
|
||||
{
|
||||
Date d (i->second.value ());
|
||||
out << "\""
|
||||
<< i->second.name ()
|
||||
<< "\":\""
|
||||
<< d.toISO ()
|
||||
<< "\"";
|
||||
|
||||
++attributes_written;
|
||||
}
|
||||
else
|
||||
{
|
||||
out << "\""
|
||||
<< i->second.name ()
|
||||
<< "\":\""
|
||||
<< i->second.value ()
|
||||
<< "\"";
|
||||
|
||||
++attributes_written;
|
||||
}
|
||||
}
|
||||
|
||||
// Now the annotations, if any.
|
||||
if (annotation_count)
|
||||
{
|
||||
out << ","
|
||||
<< "\"annotations\":[";
|
||||
|
||||
int annotations_written = 0;
|
||||
for (i = this->begin (); i != this->end (); ++i)
|
||||
{
|
||||
if (i->second.name ().substr (0, 11) == "annotation_")
|
||||
{
|
||||
if (annotations_written)
|
||||
out << ",";
|
||||
|
||||
Date d (i->second.name ().substr (11));
|
||||
out << "{\"entry\":\""
|
||||
<< d.toISO ()
|
||||
<< "\",\"description\":\""
|
||||
<< i->second.value ()
|
||||
<< "\"}";
|
||||
|
||||
++annotations_written;
|
||||
}
|
||||
}
|
||||
|
||||
out << "]";
|
||||
}
|
||||
|
||||
out << "}";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue