diff --git a/src/sort.cpp b/src/sort.cpp index 1e9b534cf..cc45f1587 100644 --- a/src/sort.cpp +++ b/src/sort.cpp @@ -137,9 +137,32 @@ static bool sort_compare (int left, int right) (left_string == "H" && (right_string == "M" || right_string == "L")); } + // Due Date. + else if (field == "due") + { + left_string = (*global_data)[left].get (field); + right_string = (*global_data)[right].get (field); + + if (left_string != "" && right_string == "") + return true; + + if (left_string == "" && right_string != "") + return false; + + if (left_string == right_string) + continue; + + left_date = atoi (left_string.c_str ()); + right_date = atoi (right_string.c_str ()); + + if (ascending) + return left_date < right_date; + + return left_date > right_date; + } + // Date. - else if (field == "due" || - field == "end" || + else if (field == "end" || field == "entry" || field == "start" || field == "until" || diff --git a/test/custom.t b/test/custom.t index 8d32c55b5..6dbc6fb90 100755 --- a/test/custom.t +++ b/test/custom.t @@ -42,8 +42,8 @@ if (open my $fh, '>', 'custom.rc') ok (-r 'custom.rc', 'Created custom.rc'); } -# Generate the usage screen, and locate the custom report on it. -my $output = qx{../src/task rc:custom.rc usage}; +# Generate the help screen, and locate the custom report on it. +my $output = qx{../src/task rc:custom.rc help}; like ($output, qr/task foo \[tags\] \[attrs\] desc\.\.\.\s+DESC\n/m, 'report.foo'); qx{../src/task rc:custom.rc add project:A one};