mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
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:
parent
ac9d1f3bfa
commit
ee2960b9b0
1 changed files with 19 additions and 0 deletions
|
@ -420,6 +420,9 @@ void Command::modify_task (
|
|||
{
|
||||
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.
|
||||
A3 fragment;
|
||||
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.
|
||||
else
|
||||
task.set (name, result);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue