Bug #417 - Sorting by countdown_compact not working

- Added support for more varied durations when specifying recurring tasks,
  such as '3 mths' or '24 hrs'.
- Fixed bug #417, which caused sorting on countdown fields to be wrong
  (thanks to Michell Crane).
- Durations are now based on seconds, rather than days, and can accept/parse
  negative durations.
This commit is contained in:
Paul Beckingham 2010-06-27 13:44:04 -04:00
parent ff18241f6f
commit 007c194c8c
6 changed files with 169 additions and 47 deletions

View file

@ -435,14 +435,7 @@ int runCustomReport (
if (due.length ())
{
Date dt (::atoi (due.c_str ()));
time_t cntdwn = (time_t) (now - dt);
Duration du (cntdwn < 0 ? -cntdwn : cntdwn);
if (cntdwn < 0)
countdown = std::string ("-") + du.format ();
else
countdown = du.format ();
countdown = Duration (now - dt).format ();
context.hooks.trigger ("format-countdown", "countdown", countdown);
table.addCell (row, columnCount, countdown);
}
@ -464,14 +457,7 @@ int runCustomReport (
if (due.length ())
{
Date dt (::atoi (due.c_str ()));
time_t cntdwn = (time_t) (now - dt);
Duration du (cntdwn < 0 ? -cntdwn : cntdwn);
if (cntdwn < 0)
countdown = std::string ("-") + du.formatCompact ();
else
countdown = du.formatCompact ();
countdown = Duration (now - dt).formatCompact ();
context.hooks.trigger ("format-countdown_compact", "countdown_compact", countdown);
table.addCell (row, columnCount, countdown);
}
@ -699,6 +685,12 @@ int runCustomReport (
Table::ascendingPeriod :
Table::descendingPeriod));
else if (column == "countdown" || column == "countdown_compact")
table.sortOn (columnIndex[column],
(direction == '+' ?
Table::descendingPeriod : // Yes, these are flipped.
Table::ascendingPeriod)); // Yes, these are flipped.
else
table.sortOn (columnIndex[column],
(direction == '+' ?