mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Date Formats
- Fixed broken documentation for custom report definitions regarding column formats. - Modified date access to use the more efficient Date::get_date method, which also shrinks the code. - Added the 'remaining' format for all date columns.
This commit is contained in:
parent
8252095174
commit
4cc9e90362
6 changed files with 33 additions and 27 deletions
|
@ -37,6 +37,7 @@ Features
|
||||||
+ Now requires libuuid (thanks to Martin Natano).
|
+ Now requires libuuid (thanks to Martin Natano).
|
||||||
+ New '_get' is a DOM accessor helper command.
|
+ New '_get' is a DOM accessor helper command.
|
||||||
+ New virtual tags (WEEK, MONTH, YEAR, PARENT).
|
+ New virtual tags (WEEK, MONTH, YEAR, PARENT).
|
||||||
|
+ Added the 'remaining' format for all date columns.
|
||||||
|
|
||||||
Bugs
|
Bugs
|
||||||
+ #1196 Now builds on Hurd (thanks to Jakub Wilk).
|
+ #1196 Now builds on Hurd (thanks to Jakub Wilk).
|
||||||
|
|
1
NEWS
1
NEWS
|
@ -9,6 +9,7 @@ New Features in taskwarrior 2.3.0
|
||||||
- Now requires libuuid.
|
- Now requires libuuid.
|
||||||
- New '_get' DOM accessor helper command.
|
- New '_get' DOM accessor helper command.
|
||||||
- New virtual tags: WEEK, MONTH, YEAR, PARENT.
|
- New virtual tags: WEEK, MONTH, YEAR, PARENT.
|
||||||
|
- New 'remaining' format for date columns.
|
||||||
|
|
||||||
New commands in taskwarrior 2.3.0
|
New commands in taskwarrior 2.3.0
|
||||||
|
|
||||||
|
|
|
@ -1204,11 +1204,8 @@ The description for report X when running the "task help" command.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B report.X.columns
|
.B report.X.columns
|
||||||
The columns that will be used when generating the report X. Valid columns are:
|
This is a comma-separated list of columns and formatting specifiers. See the
|
||||||
id, uuid, status, project, priority, priority_long, entry, start, end, due,
|
command 'task columns' for a full list of options and examples.
|
||||||
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.
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B report.X.labels
|
.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.
|
or a "-" for descending sort order. The sort IDs are separated by commas.
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
report.list.sort=due+,priority-,active-,project+
|
report.list.sort=due+,priority-,start.active-,project+
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B report.X.filter
|
.B report.X.filter
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <ColDate.h>
|
#include <ColDate.h>
|
||||||
|
@ -50,6 +49,8 @@ ColumnDate::ColumnDate ()
|
||||||
_styles.push_back ("epoch");
|
_styles.push_back ("epoch");
|
||||||
_styles.push_back ("iso");
|
_styles.push_back ("iso");
|
||||||
_styles.push_back ("age");
|
_styles.push_back ("age");
|
||||||
|
_styles.push_back ("remaining");
|
||||||
|
_styles.push_back ("countdown");
|
||||||
|
|
||||||
Date now;
|
Date now;
|
||||||
now -= 125; // So that "age" is non-zero.
|
now -= 125; // So that "age" is non-zero.
|
||||||
|
@ -58,6 +59,8 @@ ColumnDate::ColumnDate ()
|
||||||
_examples.push_back (now.toEpochString ());
|
_examples.push_back (now.toEpochString ());
|
||||||
_examples.push_back (now.toISO ());
|
_examples.push_back (now.toISO ());
|
||||||
_examples.push_back (Duration (Date () - now).formatCompact ());
|
_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))
|
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" ||
|
if (_style == "default" ||
|
||||||
_style == "formatted")
|
_style == "formatted")
|
||||||
|
@ -98,7 +101,6 @@ void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maxim
|
||||||
}
|
}
|
||||||
else if (_style == "countdown")
|
else if (_style == "countdown")
|
||||||
{
|
{
|
||||||
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
|
|
||||||
Date now;
|
Date now;
|
||||||
minimum = maximum = Duration (now - date).format ().length ();
|
minimum = maximum = Duration (now - date).format ().length ();
|
||||||
}
|
}
|
||||||
|
@ -119,6 +121,12 @@ void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maxim
|
||||||
Date now;
|
Date now;
|
||||||
minimum = maximum = Duration (now - date).formatCompact ().length ();
|
minimum = maximum = Duration (now - date).formatCompact ().length ();
|
||||||
}
|
}
|
||||||
|
else if (_style == "remaining")
|
||||||
|
{
|
||||||
|
Date now;
|
||||||
|
if (date > now)
|
||||||
|
minimum = maximum = Duration (date - now).format ().length ();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
|
||||||
}
|
}
|
||||||
|
@ -133,6 +141,8 @@ void ColumnDate::render (
|
||||||
{
|
{
|
||||||
if (task.has (_name))
|
if (task.has (_name))
|
||||||
{
|
{
|
||||||
|
Date date (task.get_date (_name));
|
||||||
|
|
||||||
if (_style == "default" ||
|
if (_style == "default" ||
|
||||||
_style == "formatted")
|
_style == "formatted")
|
||||||
{
|
{
|
||||||
|
@ -149,12 +159,10 @@ void ColumnDate::render (
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
color.colorize (
|
color.colorize (
|
||||||
leftJustify (
|
leftJustify (
|
||||||
Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
date.toString (format), width)));
|
||||||
.toString (format), width)));
|
|
||||||
}
|
}
|
||||||
else if (_style == "countdown")
|
else if (_style == "countdown")
|
||||||
{
|
{
|
||||||
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
|
|
||||||
Date now;
|
Date now;
|
||||||
|
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
|
@ -167,28 +175,24 @@ void ColumnDate::render (
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
color.colorize (
|
color.colorize (
|
||||||
rightJustify (
|
rightJustify (
|
||||||
format (Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
format (date.toJulian (), 13, 12), width)));
|
||||||
.toJulian (), 13, 12), width)));
|
|
||||||
}
|
}
|
||||||
else if (_style == "epoch")
|
else if (_style == "epoch")
|
||||||
{
|
{
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
color.colorize (
|
color.colorize (
|
||||||
rightJustify (
|
rightJustify (
|
||||||
Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
date.toEpochString (), width)));
|
||||||
.toEpochString (), width)));
|
|
||||||
}
|
}
|
||||||
else if (_style == "iso")
|
else if (_style == "iso")
|
||||||
{
|
{
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
color.colorize (
|
color.colorize (
|
||||||
leftJustify (
|
leftJustify (
|
||||||
Date ((time_t) strtol (task.get (_name).c_str (), NULL, 10))
|
date.toISO (), width)));
|
||||||
.toISO (), width)));
|
|
||||||
}
|
}
|
||||||
else if (_style == "age")
|
else if (_style == "age")
|
||||||
{
|
{
|
||||||
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
|
|
||||||
Date now;
|
Date now;
|
||||||
|
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
|
@ -196,6 +200,17 @@ void ColumnDate::render (
|
||||||
leftJustify (
|
leftJustify (
|
||||||
Duration (now - date).formatCompact (), width)));
|
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 ("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,6 @@ ColumnDue::ColumnDue ()
|
||||||
_name = "due";
|
_name = "due";
|
||||||
_label = STRING_COLUMN_LABEL_DUE;
|
_label = STRING_COLUMN_LABEL_DUE;
|
||||||
|
|
||||||
_styles.push_back ("countdown");
|
|
||||||
|
|
||||||
Date now;
|
Date now;
|
||||||
now += 125;
|
now += 125;
|
||||||
_examples.push_back (Duration (now - Date ()).formatCompact ());
|
_examples.push_back (Duration (now - Date ()).formatCompact ());
|
||||||
|
|
|
@ -41,12 +41,6 @@ ColumnScheduled::ColumnScheduled ()
|
||||||
{
|
{
|
||||||
_name = "scheduled";
|
_name = "scheduled";
|
||||||
_label = STRING_COLUMN_LABEL_SCHED;
|
_label = STRING_COLUMN_LABEL_SCHED;
|
||||||
|
|
||||||
_styles.push_back ("countdown");
|
|
||||||
|
|
||||||
Date now;
|
|
||||||
now += 125;
|
|
||||||
_examples.push_back (Duration (now - Date ()).formatCompact ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue