ColTypeDate: Add relative formatter
This commit is contained in:
committed by
Paul Beckingham
parent
7d6a7266d3
commit
cd95282c10
@@ -40,6 +40,7 @@
|
|||||||
- Removed unused 'dom' and 'shell.prompt' configuration settings.
|
- Removed unused 'dom' and 'shell.prompt' configuration settings.
|
||||||
- Numerous performance improvements. Taskwarrior 2.5.1 is between X% and
|
- Numerous performance improvements. Taskwarrior 2.5.1 is between X% and
|
||||||
Y% faster than 2.5.0 when running various commands.
|
Y% faster than 2.5.0 when running various commands.
|
||||||
|
- New formatting specifier 'relative' for columns of Date type was introduced.
|
||||||
|
|
||||||
------ current release ---------------------------
|
------ current release ---------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ ColumnTypeDate::ColumnTypeDate ()
|
|||||||
"epoch",
|
"epoch",
|
||||||
"iso",
|
"iso",
|
||||||
"age",
|
"age",
|
||||||
|
"relative",
|
||||||
"remaining",
|
"remaining",
|
||||||
"countdown"};
|
"countdown"};
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ ColumnTypeDate::ColumnTypeDate ()
|
|||||||
now.toEpochString (),
|
now.toEpochString (),
|
||||||
now.toISO (),
|
now.toISO (),
|
||||||
ISO8601p (ISO8601d () - now).formatVague (),
|
ISO8601p (ISO8601d () - now).formatVague (),
|
||||||
|
"-" + ISO8601p (ISO8601d () - now).formatVague (),
|
||||||
"",
|
"",
|
||||||
ISO8601p (ISO8601d () - now).format ()};
|
ISO8601p (ISO8601d () - now).format ()};
|
||||||
}
|
}
|
||||||
@@ -115,6 +117,14 @@ void ColumnTypeDate::measure (Task& task, unsigned int& minimum, unsigned int& m
|
|||||||
else
|
else
|
||||||
minimum = maximum = ISO8601p (date - now).formatVague ().length () + 1;
|
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")
|
else if (_style == "remaining")
|
||||||
{
|
{
|
||||||
ISO8601d now;
|
ISO8601d now;
|
||||||
@@ -177,6 +187,14 @@ void ColumnTypeDate::render (
|
|||||||
else
|
else
|
||||||
renderStringLeft (lines, width, color, "-" + ISO8601p (date - now).formatVague ());
|
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")
|
else if (_style == "remaining")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user