Date/Duration Distinction
- When a date attribute is updated, the expression may have evaluated to a duration, which at this point is simply a number. If it is below a certain threshold (5y) then it is considered a duration and added to 'now', otherwise it is considered a date.
This commit is contained in:
@@ -420,6 +420,9 @@ void Command::modify_task (
|
|||||||
{
|
{
|
||||||
std::cout << "# Command::modify_task name='" << name << "' value='" << value << "'\n";
|
std::cout << "# Command::modify_task name='" << name << "' value='" << value << "'\n";
|
||||||
|
|
||||||
|
// Get the column info.
|
||||||
|
Column* column = context.columns[name];
|
||||||
|
|
||||||
// All values must be eval'd first.
|
// All values must be eval'd first.
|
||||||
A3 fragment;
|
A3 fragment;
|
||||||
fragment.capture (value);
|
fragment.capture (value);
|
||||||
@@ -447,6 +450,22 @@ void Command::modify_task (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dates are special, maybe.
|
||||||
|
else if (column->type () == "date")
|
||||||
|
{
|
||||||
|
// If the date value is less than 5 years, it is a duration, not a
|
||||||
|
// date, therefore add 'now'.
|
||||||
|
long l = strtol (result.c_str (), NULL, 10);
|
||||||
|
if (labs (l) < 5 * 365 * 86400)
|
||||||
|
{
|
||||||
|
Date now;
|
||||||
|
now += l;
|
||||||
|
task.set (name, now.toEpochString ());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
task.set (name, result);
|
||||||
|
}
|
||||||
|
|
||||||
// By default, just add it.
|
// By default, just add it.
|
||||||
else
|
else
|
||||||
task.set (name, result);
|
task.set (name, result);
|
||||||
|
|||||||
Reference in New Issue
Block a user