diff --git a/ChangeLog b/ChangeLog index c6ba9c8ba..35e92af60 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,6 +37,7 @@ Features + Now requires libuuid (thanks to Martin Natano). + New '_get' is a DOM accessor helper command. + New virtual tags (WEEK, MONTH, YEAR, PARENT). + + Added the 'remaining' format for all date columns. Bugs + #1196 Now builds on Hurd (thanks to Jakub Wilk). diff --git a/NEWS b/NEWS index 7b11d1189..16d45dd2c 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ New Features in taskwarrior 2.3.0 - Now requires libuuid. - New '_get' DOM accessor helper command. - New virtual tags: WEEK, MONTH, YEAR, PARENT. + - New 'remaining' format for date columns. New commands in taskwarrior 2.3.0 diff --git a/doc/man/taskrc.5.in b/doc/man/taskrc.5.in index 88bff2a05..ca92fcd52 100644 --- a/doc/man/taskrc.5.in +++ b/doc/man/taskrc.5.in @@ -1204,11 +1204,8 @@ The description for report X when running the "task help" command. .TP .B report.X.columns -The columns that will be used when generating the report X. Valid columns are: -id, uuid, status, project, priority, priority_long, entry, start, end, due, -countdown, countdown_compact, age, age_compact, active, tags, depends, -description_only, description, recur, recurrence_indicator, tag_indicator and -wait. The IDs are separated by commas. +This is a comma-separated list of columns and formatting specifiers. See the +command 'task columns' for a full list of options and examples. .TP .B report.X.labels @@ -1222,7 +1219,7 @@ specified by using the column ids post-fixed by a "+" for ascending sort order or a "-" for descending sort order. The sort IDs are separated by commas. For example: - report.list.sort=due+,priority-,active-,project+ + report.list.sort=due+,priority-,start.active-,project+ .TP .B report.X.filter diff --git a/src/columns/ColDate.cpp b/src/columns/ColDate.cpp index 86fb6abfc..ef3fb55c2 100644 --- a/src/columns/ColDate.cpp +++ b/src/columns/ColDate.cpp @@ -26,7 +26,6 @@ //////////////////////////////////////////////////////////////////////////////// #include -#include #include #include #include @@ -50,6 +49,8 @@ ColumnDate::ColumnDate () _styles.push_back ("epoch"); _styles.push_back ("iso"); _styles.push_back ("age"); + _styles.push_back ("remaining"); + _styles.push_back ("countdown"); Date now; now -= 125; // So that "age" is non-zero. @@ -58,6 +59,8 @@ ColumnDate::ColumnDate () _examples.push_back (now.toEpochString ()); _examples.push_back (now.toISO ()); _examples.push_back (Duration (Date () - now).formatCompact ()); + _examples.push_back (""); + _examples.push_back (Duration (Date () - now).format ()); } //////////////////////////////////////////////////////////////////////////////// @@ -79,7 +82,7 @@ void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maxim if (task.has (_name)) { - Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10)); + Date date (task.get_date (_name)); if (_style == "default" || _style == "formatted") @@ -98,7 +101,6 @@ void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maxim } else if (_style == "countdown") { - Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10)); Date now; minimum = maximum = Duration (now - date).format ().length (); } @@ -119,6 +121,12 @@ void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maxim Date now; minimum = maximum = Duration (now - date).formatCompact ().length (); } + else if (_style == "remaining") + { + Date now; + if (date > now) + minimum = maximum = Duration (date - now).format ().length (); + } else throw format (STRING_COLUMN_BAD_FORMAT, _name, _style); } @@ -133,6 +141,8 @@ void ColumnDate::render ( { if (task.has (_name)) { + Date date (task.get_date (_name)); + if (_style == "default" || _style == "formatted") { @@ -149,12 +159,10 @@ void ColumnDate::render ( lines.push_back ( color.colorize ( leftJustify ( - Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10)) - .toString (format), width))); + date.toString (format), width))); } else if (_style == "countdown") { - Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10)); Date now; lines.push_back ( @@ -167,28 +175,24 @@ void ColumnDate::render ( lines.push_back ( color.colorize ( rightJustify ( - format (Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10)) - .toJulian (), 13, 12), width))); + format (date.toJulian (), 13, 12), width))); } else if (_style == "epoch") { lines.push_back ( color.colorize ( rightJustify ( - Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10)) - .toEpochString (), width))); + date.toEpochString (), width))); } else if (_style == "iso") { lines.push_back ( color.colorize ( leftJustify ( - Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10)) - .toISO (), width))); + date.toISO (), width))); } else if (_style == "age") { - Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10)); Date now; lines.push_back ( @@ -196,6 +200,17 @@ void ColumnDate::render ( leftJustify ( Duration (now - date).formatCompact (), width))); } + else if (_style == "remaining") + { + Date now; + if (date > now) + lines.push_back ( + color.colorize ( + rightJustify ( + Duration (date - now).format (), width))); + else + lines.push_back (""); + } } } diff --git a/src/columns/ColDue.cpp b/src/columns/ColDue.cpp index 08cffaf84..3f102fe70 100644 --- a/src/columns/ColDue.cpp +++ b/src/columns/ColDue.cpp @@ -42,8 +42,6 @@ ColumnDue::ColumnDue () _name = "due"; _label = STRING_COLUMN_LABEL_DUE; - _styles.push_back ("countdown"); - Date now; now += 125; _examples.push_back (Duration (now - Date ()).formatCompact ()); diff --git a/src/columns/ColScheduled.cpp b/src/columns/ColScheduled.cpp index 132dd064a..d00180377 100644 --- a/src/columns/ColScheduled.cpp +++ b/src/columns/ColScheduled.cpp @@ -41,12 +41,6 @@ ColumnScheduled::ColumnScheduled () { _name = "scheduled"; _label = STRING_COLUMN_LABEL_SCHED; - - _styles.push_back ("countdown"); - - Date now; - now += 125; - _examples.push_back (Duration (now - Date ()).formatCompact ()); } ////////////////////////////////////////////////////////////////////////////////