ColTypeDate: Add relative formatter

This commit is contained in:
Tomas Babej 2015-11-17 22:59:06 +01:00 committed by Paul Beckingham
parent 7d6a7266d3
commit cd95282c10
2 changed files with 19 additions and 0 deletions

View file

@ -40,6 +40,7 @@
- Removed unused 'dom' and 'shell.prompt' configuration settings.
- Numerous performance improvements. Taskwarrior 2.5.1 is between X% and
Y% faster than 2.5.0 when running various commands.
- New formatting specifier 'relative' for columns of Date type was introduced.
------ current release ---------------------------

View file

@ -45,6 +45,7 @@ ColumnTypeDate::ColumnTypeDate ()
"epoch",
"iso",
"age",
"relative",
"remaining",
"countdown"};
@ -55,6 +56,7 @@ ColumnTypeDate::ColumnTypeDate ()
now.toEpochString (),
now.toISO (),
ISO8601p (ISO8601d () - now).formatVague (),
"-" + ISO8601p (ISO8601d () - now).formatVague (),
"",
ISO8601p (ISO8601d () - now).format ()};
}
@ -115,6 +117,14 @@ void ColumnTypeDate::measure (Task& task, unsigned int& minimum, unsigned int& m
else
minimum = maximum = ISO8601p (date - now).formatVague ().length () + 1;
}
else if (_style == "relative")
{
ISO8601d now;
if (now < date)
minimum = maximum = ISO8601p (date - now).formatVague ().length ();
else
minimum = maximum = ISO8601p (now - date).formatVague ().length () + 1;
}
else if (_style == "remaining")
{
ISO8601d now;
@ -177,6 +187,14 @@ void ColumnTypeDate::render (
else
renderStringLeft (lines, width, color, "-" + ISO8601p (date - now).formatVague ());
}
else if (_style == "relative")
{
ISO8601d now;
if (now < date)
renderStringLeft (lines, width, color, ISO8601p (date - now).formatVague ());
else
renderStringLeft (lines, width, color, "-" + ISO8601p (now - date).formatVague ());
}
else if (_style == "remaining")
{