mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-27 12:16:25 +02:00
Interval: Added ::jsn
This commit is contained in:
parent
85c5140f2c
commit
9753a63eb8
2 changed files with 34 additions and 0 deletions
|
@ -197,6 +197,39 @@ std::string Interval::serialize () const
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string Interval::json () const
|
||||||
|
{
|
||||||
|
std::stringstream out;
|
||||||
|
out << "{\"type\":\"inc\"";
|
||||||
|
|
||||||
|
if (_start.toEpoch ())
|
||||||
|
out << ",\"start\":\"" << _start.toISO () << "\"";
|
||||||
|
|
||||||
|
if (_end.toEpoch ())
|
||||||
|
out << ",\"end\":\"" << _end.toISO () << "\"";
|
||||||
|
|
||||||
|
if (_tags.size ())
|
||||||
|
{
|
||||||
|
|
||||||
|
std::string tags;
|
||||||
|
for (auto& tag : _tags)
|
||||||
|
{
|
||||||
|
if (tags[0])
|
||||||
|
tags += ",";
|
||||||
|
|
||||||
|
tags += "\"" + tag + "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
out << ",\"tags\":["
|
||||||
|
<< tags
|
||||||
|
<< "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
out << "}";
|
||||||
|
return out.str ();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Interval::dump () const
|
std::string Interval::dump () const
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
|
|
||||||
std::string summarize () const;
|
std::string summarize () const;
|
||||||
std::string serialize () const;
|
std::string serialize () const;
|
||||||
|
std::string json () const;
|
||||||
std::string dump () const;
|
std::string dump () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue