mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-25 21:27:19 +02:00
Enhancement
- Implemented Record::get_date to eliminated the need to obtain a date as a string, then convert to time_t, then instantiate a Date.
This commit is contained in:
parent
7d5f4fdfc7
commit
63f91c2f88
12 changed files with 54 additions and 42 deletions
|
@ -227,7 +227,7 @@ void Chart::scan (std::vector <Task>& tasks)
|
|||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
||||
{
|
||||
// The entry date is when the counting starts.
|
||||
Date from = quantize (Date (task->get ("entry")));
|
||||
Date from = quantize (Date (task->get_date ("entry")));
|
||||
epoch = from.toEpoch ();
|
||||
|
||||
if (bars.find (epoch) != bars.end ())
|
||||
|
@ -241,7 +241,7 @@ void Chart::scan (std::vector <Task>& tasks)
|
|||
{
|
||||
if (task->has ("start"))
|
||||
{
|
||||
Date start = quantize (Date (task->get ("start")));
|
||||
Date start = quantize (Date (task->get_date ("start")));
|
||||
while (from < start)
|
||||
{
|
||||
epoch = from.toEpoch ();
|
||||
|
@ -272,7 +272,7 @@ void Chart::scan (std::vector <Task>& tasks)
|
|||
else if (status == Task::completed)
|
||||
{
|
||||
// Truncate history so it starts at 'earliest' for completed tasks.
|
||||
Date end = quantize (Date (task->get ("end")));
|
||||
Date end = quantize (Date (task->get_date ("end")));
|
||||
epoch = end.toEpoch ();
|
||||
|
||||
if (bars.find (epoch) != bars.end ())
|
||||
|
@ -288,7 +288,7 @@ void Chart::scan (std::vector <Task>& tasks)
|
|||
|
||||
if (task->has ("start"))
|
||||
{
|
||||
Date start = quantize (Date (task->get ("start")));
|
||||
Date start = quantize (Date (task->get_date ("start")));
|
||||
while (from < start)
|
||||
{
|
||||
epoch = from.toEpoch ();
|
||||
|
@ -312,7 +312,7 @@ void Chart::scan (std::vector <Task>& tasks)
|
|||
}
|
||||
else
|
||||
{
|
||||
Date end = quantize (Date (task->get ("end")));
|
||||
Date end = quantize (Date (task->get_date ("end")));
|
||||
while (from < end)
|
||||
{
|
||||
epoch = from.toEpoch ();
|
||||
|
@ -334,7 +334,7 @@ void Chart::scan (std::vector <Task>& tasks)
|
|||
else if (status == Task::deleted)
|
||||
{
|
||||
// Skip old deleted tasks.
|
||||
Date end = quantize (Date (task->get ("end")));
|
||||
Date end = quantize (Date (task->get_date ("end")));
|
||||
epoch = end.toEpoch ();
|
||||
if (bars.find (epoch) != bars.end ())
|
||||
++bars[epoch].removed;
|
||||
|
@ -344,7 +344,7 @@ void Chart::scan (std::vector <Task>& tasks)
|
|||
|
||||
if (task->has ("start"))
|
||||
{
|
||||
Date start = quantize (Date (task->get ("start")));
|
||||
Date start = quantize (Date (task->get_date ("start")));
|
||||
while (from < start)
|
||||
{
|
||||
epoch = from.toEpoch ();
|
||||
|
@ -361,7 +361,7 @@ void Chart::scan (std::vector <Task>& tasks)
|
|||
}
|
||||
else
|
||||
{
|
||||
Date end = quantize (Date (task->get ("end")));
|
||||
Date end = quantize (Date (task->get_date ("end")));
|
||||
while (from < end)
|
||||
{
|
||||
epoch = from.toEpoch ();
|
||||
|
|
|
@ -197,7 +197,7 @@ int CmdCalendar::execute (std::string& output)
|
|||
!task->hasTag ("nocal"))
|
||||
{
|
||||
++countDueDates;
|
||||
Date d (strtol (task->get ("due").c_str (), NULL, 10));
|
||||
Date d (task->get ("due"));
|
||||
if (d < oldest) oldest = d;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -296,7 +296,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after)
|
|||
{
|
||||
Date edited (strtol (value.c_str (), NULL, 10));
|
||||
|
||||
Date original (strtol (task.get ("entry").c_str (), NULL, 10));
|
||||
Date original (task.get_date ("entry"));
|
||||
if (!original.sameDay (edited))
|
||||
{
|
||||
context.footnote ("Creation date modified.");
|
||||
|
@ -314,7 +314,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after)
|
|||
|
||||
if (task.get ("start") != "")
|
||||
{
|
||||
Date original (strtol (task.get ("start").c_str (), NULL, 10));
|
||||
Date original (task.get_date ("start"));
|
||||
if (!original.sameDay (edited))
|
||||
{
|
||||
context.footnote ("Start date modified.");
|
||||
|
@ -344,7 +344,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after)
|
|||
|
||||
if (task.get ("end") != "")
|
||||
{
|
||||
Date original (strtol (task.get ("end").c_str (), NULL, 10));
|
||||
Date original (task.get_date ("end"));
|
||||
if (!original.sameDay (edited))
|
||||
{
|
||||
context.footnote ("Done date modified.");
|
||||
|
@ -372,7 +372,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after)
|
|||
|
||||
if (task.get ("due") != "")
|
||||
{
|
||||
Date original (strtol (task.get ("due").c_str (), NULL, 10));
|
||||
Date original (task.get_date ("due"));
|
||||
if (!original.sameDay (edited))
|
||||
{
|
||||
context.footnote ("Due date modified.");
|
||||
|
@ -410,7 +410,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after)
|
|||
|
||||
if (task.get ("until") != "")
|
||||
{
|
||||
Date original (strtol (task.get ("until").c_str (), NULL, 10));
|
||||
Date original (task.get_date ("until"));
|
||||
if (!original.sameDay (edited))
|
||||
{
|
||||
context.footnote ("Until date modified.");
|
||||
|
@ -472,7 +472,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after)
|
|||
|
||||
if (task.get ("wait") != "")
|
||||
{
|
||||
Date original (strtol (task.get ("wait").c_str (), NULL, 10));
|
||||
Date original (task.get_date ("wait"));
|
||||
if (!original.sameDay (edited))
|
||||
{
|
||||
context.footnote ("Wait date modified.");
|
||||
|
|
|
@ -72,11 +72,11 @@ int CmdHistoryMonthly::execute (std::string& output)
|
|||
std::vector <Task>::iterator task;
|
||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||
{
|
||||
Date entry (task->get ("entry"));
|
||||
Date entry (task->get_date ("entry"));
|
||||
|
||||
Date end;
|
||||
if (task->has ("end"))
|
||||
end = Date (task->get ("end"));
|
||||
end = Date (task->get_date ("end"));
|
||||
|
||||
time_t epoch = entry.startOfMonth ().toEpoch ();
|
||||
groups[epoch] = 0;
|
||||
|
@ -232,11 +232,11 @@ int CmdHistoryAnnual::execute (std::string& output)
|
|||
std::vector <Task>::iterator task;
|
||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||
{
|
||||
Date entry (task->get ("entry"));
|
||||
Date entry (task->get_date ("entry"));
|
||||
|
||||
Date end;
|
||||
if (task->has ("end"))
|
||||
end = Date (task->get ("end"));
|
||||
end = Date (task->get_date ("end"));
|
||||
|
||||
time_t epoch = entry.startOfYear ().toEpoch ();
|
||||
groups[epoch] = 0;
|
||||
|
@ -389,11 +389,11 @@ int CmdGHistoryMonthly::execute (std::string& output)
|
|||
std::vector <Task>::iterator task;
|
||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||
{
|
||||
Date entry (task->get ("entry"));
|
||||
Date entry (task->get_date ("entry"));
|
||||
|
||||
Date end;
|
||||
if (task->has ("end"))
|
||||
end = Date (task->get ("end"));
|
||||
end = Date (task->get_date ("end"));
|
||||
|
||||
time_t epoch = entry.startOfMonth ().toEpoch ();
|
||||
groups[epoch] = 0;
|
||||
|
@ -588,11 +588,11 @@ int CmdGHistoryAnnual::execute (std::string& output)
|
|||
std::vector <Task>::iterator task;
|
||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||
{
|
||||
Date entry (task->get ("entry"));
|
||||
Date entry (task->get_date ("entry"));
|
||||
|
||||
Date end;
|
||||
if (task->has ("end"))
|
||||
end = Date (task->get ("end"));
|
||||
end = Date (task->get_date ("end"));
|
||||
|
||||
time_t epoch = entry.startOfYear ().toEpoch ();
|
||||
groups[epoch] = 0;
|
||||
|
|
|
@ -179,7 +179,7 @@ int CmdInfo::execute (std::string& output)
|
|||
row = view.addRow ();
|
||||
view.set (row, 0, STRING_CMD_INFO_RECUR_UNTIL);
|
||||
|
||||
Date dt (strtol (task->get ("until").c_str (), NULL, 10));
|
||||
Date dt (task->get ("until"));
|
||||
std::string format = context.config.get ("reportdateformat");
|
||||
if (format == "")
|
||||
format = context.config.get ("dateformat");
|
||||
|
@ -227,7 +227,7 @@ int CmdInfo::execute (std::string& output)
|
|||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, STRING_COLUMN_LABEL_WAITING);
|
||||
Date dt (strtol (task->get ("wait").c_str (), NULL, 10));
|
||||
Date dt (task->get_date ("wait"));
|
||||
view.set (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ int CmdInfo::execute (std::string& output)
|
|||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, STRING_COLUMN_LABEL_START);
|
||||
Date dt (strtol (task->get ("start").c_str (), NULL, 10));
|
||||
Date dt (task->get_date ("start"));
|
||||
view.set (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ int CmdInfo::execute (std::string& output)
|
|||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, STRING_COLUMN_LABEL_END);
|
||||
Date dt (strtol (task->get ("end").c_str (), NULL, 10));
|
||||
Date dt (task->get_date ("end"));
|
||||
view.set (row, 1, dt.toString (context.config.get ("dateformat")));
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ int CmdInfo::execute (std::string& output)
|
|||
// entry
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, STRING_COLUMN_LABEL_ENTERED);
|
||||
Date dt (strtol (task->get ("entry").c_str (), NULL, 10));
|
||||
Date dt (task->get_date ("entry"));
|
||||
std::string entry = dt.toString (context.config.get ("dateformat"));
|
||||
|
||||
std::string age;
|
||||
|
|
|
@ -117,7 +117,7 @@ int CmdTimesheet::execute (std::string& output)
|
|||
// If task completed within range.
|
||||
if (task->getStatus () == Task::completed)
|
||||
{
|
||||
Date compDate (strtol (task->get ("end").c_str (), NULL, 10));
|
||||
Date compDate (task->get_date ("end"));
|
||||
if (compDate >= start && compDate < end)
|
||||
{
|
||||
Color c (task->get ("fg") + " " + task->get ("bg"));
|
||||
|
@ -155,7 +155,7 @@ int CmdTimesheet::execute (std::string& output)
|
|||
if (task->getStatus () == Task::pending &&
|
||||
task->has ("start"))
|
||||
{
|
||||
Date startDate (strtol (task->get ("start").c_str (), NULL, 10));
|
||||
Date startDate (task->get_date ("start"));
|
||||
if (startDate >= start && startDate < end)
|
||||
{
|
||||
Color c (task->get ("fg") + " " + task->get ("bg"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue