mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Variant: Ensure implmentation of addition/subtraction of dates/durations does not involve casting
Implicit casting of a duration anchors it around the 'now' point in time, which would throw off the conversion.
This commit is contained in:
parent
7242accb58
commit
5e0fc1caab
1 changed files with 11 additions and 11 deletions
|
@ -1295,12 +1295,12 @@ Variant& Variant::operator-= (const Variant& other)
|
|||
case type_date:
|
||||
switch (right._type)
|
||||
{
|
||||
case type_boolean: right.cast (type_integer); _date -= right._integer; break;
|
||||
case type_integer: _date -= right._integer; break;
|
||||
case type_real: _date -= (int) right._real; break;
|
||||
case type_boolean: right.cast (type_integer); _date -= right._integer; break;
|
||||
case type_integer: _date -= right._integer; break;
|
||||
case type_real: _date -= (int) right._real; break;
|
||||
case type_string: throw std::string (STRING_VARIANT_SUB_STRING);
|
||||
case type_date: cast (type_duration); _duration -= right._date; break;
|
||||
case type_duration: _date -= right._duration; break;
|
||||
case type_date: _type = Variant::type_duration; _duration = _date - right._date; break;
|
||||
case type_duration: _date -= right._duration; break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1408,12 +1408,12 @@ Variant& Variant::operator+= (const Variant& other)
|
|||
case type_duration:
|
||||
switch (right._type)
|
||||
{
|
||||
case type_boolean: right.cast (type_duration); _duration += right._duration; break;
|
||||
case type_integer: _duration += right._integer; break;
|
||||
case type_real: _duration += (int) right._real; break;
|
||||
case type_string: cast (type_string); _string += right._string; break;
|
||||
case type_date: cast (type_date); _date += right._date; break;
|
||||
case type_duration: _duration += right._duration; break;
|
||||
case type_boolean: right.cast (type_duration); _duration += right._duration; break;
|
||||
case type_integer: _duration += right._integer; break;
|
||||
case type_real: _duration += (int) right._real; break;
|
||||
case type_string: cast (type_string); _string += right._string; break;
|
||||
case type_date: _type = Variant::type_date; _date += right._date + _duration; break;
|
||||
case type_duration: _duration += right._duration; break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue