mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Bug Fix - due date, colorization
- Fixed bug that caused colorization to be way, way off. Silly mistake. - Fixed bug whereby due dates and durations were stored as-is, but should have been converted. - On a related note, added Date::toEpochString, Duration::operator (std::string).
This commit is contained in:
parent
f701f10234
commit
7e2da42f40
9 changed files with 57 additions and 45 deletions
|
@ -343,13 +343,13 @@ bool Att::validNameValue (
|
|||
name == "until")
|
||||
{
|
||||
if (value != "")
|
||||
Date (value);
|
||||
value = Date (value).toEpochString ();
|
||||
}
|
||||
|
||||
else if (name == "recur")
|
||||
{
|
||||
if (value != "")
|
||||
Duration (value);
|
||||
value = (std::string) Duration (value);
|
||||
}
|
||||
|
||||
else if (name == "limit")
|
||||
|
|
|
@ -523,21 +523,17 @@ void Context::autoFilter ()
|
|||
header ("auto filter: " + att->first + ".startswith:" + att->second.value ());
|
||||
}
|
||||
|
||||
// TODO Don't create a uuid for every task?
|
||||
// Every task has a unique uuid by default, and it shouldn't be included.
|
||||
// The mechanism for filtering on tags is +/-<tag>, not tags:foo which
|
||||
// means that there can only be one tag, "foo".
|
||||
else if (att->first != "uuid" &&
|
||||
att->first != "tags" &&
|
||||
att->first != "project")
|
||||
att->first != "tags")
|
||||
{
|
||||
filter.push_back (att->second);
|
||||
header ("auto filter: " + att->first + ":" + att->second.value ());
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Include Annotations as part of the description?
|
||||
|
||||
// Include tagAdditions.
|
||||
foreach (tag, tagAdditions)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -209,6 +210,14 @@ time_t Date::toEpoch ()
|
|||
return mT;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Date::toEpochString ()
|
||||
{
|
||||
std::stringstream epoch;
|
||||
epoch << mT;
|
||||
return epoch.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Date::toEpoch (time_t& epoch)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ public:
|
|||
|
||||
void toEpoch (time_t&);
|
||||
time_t toEpoch ();
|
||||
std::string toEpochString ();
|
||||
void toMDY (int&, int&, int&);
|
||||
const std::string toString (const std::string& format = "m/d/Y") const;
|
||||
static bool valid (const std::string&, const std::string& format = "m/d/Y");
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdlib.h>
|
||||
#include "text.h"
|
||||
|
@ -55,6 +57,14 @@ Duration::operator time_t ()
|
|||
return mDays;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Duration::operator std::string ()
|
||||
{
|
||||
std::stringstream s;
|
||||
s << mDays;
|
||||
return s.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Duration::operator< (const Duration& other)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
|
||||
operator int ();
|
||||
operator time_t ();
|
||||
operator std::string ();
|
||||
|
||||
bool valid (const std::string&) const;
|
||||
void parse (const std::string&);
|
||||
|
|
|
@ -42,8 +42,6 @@ bool Filter::pass (const Record& record) const
|
|||
// but it doesn't match, fail.
|
||||
foreach (att, (*this))
|
||||
{
|
||||
// TODO std::cout << "Filter::pass " << att->name () << "=" << att->value () << std::endl;
|
||||
|
||||
// If the record doesn't have the attribute, match against a default one.
|
||||
// This is because "att" may contain a modifier like "name.not:X".
|
||||
if ((r = record.find (att->name ())) == record.end ())
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
#include "TDB.h"
|
||||
#include "main.h"
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// The ctor/dtor do nothing.
|
||||
// The lock/unlock methods hold the file open.
|
||||
|
@ -175,7 +177,7 @@ int TDB::load (std::vector <Task>& tasks, Filter& filter)
|
|||
numberStatusClauses != numberSimpleStatusClauses)
|
||||
loadCompleted (tasks, filter);
|
||||
else
|
||||
std::cout << "[1;31m# TDB::load optimization short circuit[0m" << std::endl;
|
||||
context.header ("load optimization short circuit");
|
||||
#else
|
||||
loadCompleted (tasks, filter);
|
||||
#endif
|
||||
|
|
|
@ -158,16 +158,15 @@ std::string handleCustomReport (const std::string& report)
|
|||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
int row = 0;
|
||||
std::string entered;
|
||||
foreach (task, tasks)
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
entered = task->get ("entry");
|
||||
entered = tasks[row].get ("entry");
|
||||
if (entered.length ())
|
||||
{
|
||||
Date dt (::atoi (entered.c_str ()));
|
||||
entered = dt.toString (context.config.get ("dateformat", "m/d/Y"));
|
||||
table.addCell (row++, columnCount, entered);
|
||||
table.addCell (row, columnCount, entered);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,16 +177,15 @@ std::string handleCustomReport (const std::string& report)
|
|||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
int row = 0;
|
||||
std::string started;
|
||||
foreach (task, tasks)
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
started = task->get ("start");
|
||||
started = tasks[row].get ("start");
|
||||
if (started.length ())
|
||||
{
|
||||
Date dt (::atoi (started.c_str ()));
|
||||
started = dt.toString (context.config.get ("dateformat", "m/d/Y"));
|
||||
table.addCell (row++, columnCount, started);
|
||||
table.addCell (row, columnCount, started);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -198,16 +196,15 @@ std::string handleCustomReport (const std::string& report)
|
|||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
int row = 0;
|
||||
std::string started;
|
||||
foreach (task, tasks)
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
started = task->get ("end");
|
||||
started = tasks[row].get ("end");
|
||||
if (started.length ())
|
||||
{
|
||||
Date dt (::atoi (started.c_str ()));
|
||||
started = dt.toString (context.config.get ("dateformat", "m/d/Y"));
|
||||
table.addCell (row++, columnCount, started);
|
||||
table.addCell (row, columnCount, started);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -232,18 +229,17 @@ std::string handleCustomReport (const std::string& report)
|
|||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
int row = 0;
|
||||
std::string created;
|
||||
std::string age;
|
||||
Date now;
|
||||
foreach (task, tasks)
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
created = task->get ("entry");
|
||||
created = tasks[row].get ("entry");
|
||||
if (created.length ())
|
||||
{
|
||||
Date dt (::atoi (created.c_str ()));
|
||||
age = formatSeconds ((time_t) (now - dt));
|
||||
table.addCell (row++, columnCount, age);
|
||||
table.addCell (row, columnCount, age);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -254,18 +250,17 @@ std::string handleCustomReport (const std::string& report)
|
|||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
int row = 0;
|
||||
std::string created;
|
||||
std::string age;
|
||||
Date now;
|
||||
foreach (task, tasks)
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
created = task->get ("entry");
|
||||
created = tasks[row].get ("entry");
|
||||
if (created.length ())
|
||||
{
|
||||
Date dt (::atoi (created.c_str ()));
|
||||
age = formatSecondsCompact ((time_t) (now - dt));
|
||||
table.addCell (row++, columnCount, age);
|
||||
table.addCell (row, columnCount, age);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -276,10 +271,9 @@ std::string handleCustomReport (const std::string& report)
|
|||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::left);
|
||||
|
||||
int row = 0;
|
||||
foreach (task, tasks)
|
||||
if (task->get ("start") != "")
|
||||
table.addCell (row++, columnCount, "*");
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
if (tasks[row].has ("start"))
|
||||
table.addCell (row, columnCount, "*");
|
||||
}
|
||||
|
||||
else if (*col == "tags")
|
||||
|
@ -327,9 +321,12 @@ std::string handleCustomReport (const std::string& report)
|
|||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
int row = 0;
|
||||
foreach (task, tasks)
|
||||
table.addCell (row++, columnCount, task->get ("recur"));
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
{
|
||||
std::string recur = tasks[row].get ("recur");
|
||||
if (recur != "")
|
||||
table.addCell (row, columnCount, recur);
|
||||
}
|
||||
}
|
||||
|
||||
else if (*col == "recurrence_indicator")
|
||||
|
@ -338,10 +335,9 @@ std::string handleCustomReport (const std::string& report)
|
|||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
int row = 0;
|
||||
foreach (task, tasks)
|
||||
table.addCell (row++, columnCount,
|
||||
task->get ("recur") != "" ? "R" : "");
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
if (tasks[row].has ("recur"))
|
||||
table.addCell (row, columnCount, "R");
|
||||
}
|
||||
|
||||
else if (*col == "tag_indicator")
|
||||
|
@ -350,10 +346,9 @@ std::string handleCustomReport (const std::string& report)
|
|||
table.setColumnWidth (columnCount, Table::minimum);
|
||||
table.setColumnJustification (columnCount, Table::right);
|
||||
|
||||
int row = 0;
|
||||
foreach (task, tasks)
|
||||
table.addCell (row++, columnCount,
|
||||
task->getTagCount () ? "+" : "");
|
||||
for (unsigned int row = 0; row < tasks.size(); ++row)
|
||||
if (tasks[row].getTagCount ())
|
||||
table.addCell (row, columnCount, "+");
|
||||
}
|
||||
|
||||
// Common to all columns.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue