- #1273 Query with negative relative date differs greatly from absolute date
  in past (thanks to John West).
This commit is contained in:
Paul Beckingham 2013-10-06 16:23:43 -04:00
parent 9099a353ea
commit c1492d8010
6 changed files with 16 additions and 3 deletions

View file

@ -182,3 +182,4 @@ suggestions:
Friedrich Heusler Friedrich Heusler
Ben Armstrong Ben Armstrong
XTaran XTaran
John West

View file

@ -68,6 +68,8 @@ Bugs
+ #1263 The 'waiting' report properly lists only pending tasks with a wait date + #1263 The 'waiting' report properly lists only pending tasks with a wait date
(thanks to Fidel Mato). (thanks to Fidel Mato).
+ #1270 The 'undo' command is now properly removing backlog entries. + #1270 The 'undo' command is now properly removing backlog entries.
+ #1273 Query with negative relative date differs greatly from absolute date
in past (thanks to John West).
+ #1279 Assorted corrections to the task-ref.pdf document (thanks to Benjamin + #1279 Assorted corrections to the task-ref.pdf document (thanks to Benjamin
Weber). Weber).
+ #1286 Cannot use "sow", "som", etc in "entry.after", "end.after" filters + #1286 Cannot use "sow", "som", etc in "entry.after", "end.after" filters

View file

@ -368,6 +368,8 @@ bool Duration::valid (const std::string& input)
Nibbler n (lower_input); Nibbler n (lower_input);
n.getNumber (value); n.getNumber (value);
// Negative values are valid, but do not need to complicate the validation
// check.
if (value < 0.0) if (value < 0.0)
value = -value; value = -value;

View file

@ -185,7 +185,10 @@ void E9::eval (const Task& task, std::vector <Arg>& value_stack)
{ {
Duration dur (operand._raw); Duration dur (operand._raw);
Date now; Date now;
now += (int)(time_t) dur; if (dur.negative ())
now -= (int)(time_t) dur;
else
now += (int)(time_t) dur;
operand._value = now.toEpochString (); operand._value = now.toEpochString ();
} }
else else

View file

@ -463,7 +463,7 @@ void Command::modify_task (
std::string& description) std::string& description)
{ {
// Utilize Task::modify // Utilize Task::modify
task.modify(arguments, description); task.modify (arguments, description);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View file

@ -51,7 +51,7 @@ int convertDuration (const std::string& input)
int main (int argc, char** argv) int main (int argc, char** argv)
{ {
UnitTest t (644); UnitTest t (646);
// Ensure environment has no influence. // Ensure environment has no influence.
unsetenv ("TASKDATA"); unsetenv ("TASKDATA");
@ -728,6 +728,11 @@ int main (int argc, char** argv)
t.is (convertDuration ("10d"), 10, "valid duration 10d"); t.is (convertDuration ("10d"), 10, "valid duration 10d");
t.is (convertDuration ("-"), 0, "valid duration -"); t.is (convertDuration ("-"), 0, "valid duration -");
d = Duration ("-4d");
t.is ((time_t)d, 4*86400, "-4d == 4*86400");
t.ok (d.negative (), "-4d == negative");
try try
{ {
Duration left, right; Duration left, right;