summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-19 03:37:16 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-19 03:37:16 -0500
commitcc9110a43a1e2d006de8d24a84bbfb2c6918cf33 (patch)
tree4230ae03ebea8e2cbc0b6e1de821730e4819af47 /src/value.cc
parent6b557f810e1c6eb2dcd8a24eeeacfcf9cc8210e3 (diff)
parent63fee4c83775f79364199ea547dbc7e068b0abc8 (diff)
downloadledger-cc9110a43a1e2d006de8d24a84bbfb2c6918cf33.tar.gz
ledger-cc9110a43a1e2d006de8d24a84bbfb2c6918cf33.tar.bz2
ledger-cc9110a43a1e2d006de8d24a84bbfb2c6918cf33.zip
Merge branch 'next'
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/value.cc b/src/value.cc
index 3f70ab3d..f4df3329 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -338,10 +338,13 @@ value_t& value_t::operator+=(const value_t& val)
case DATETIME:
switch (val.type()) {
case INTEGER:
- as_datetime_lval() += date_duration(val.as_long());
+ as_datetime_lval() +=
+ time_duration_t(0, 0, static_cast<time_duration_t::sec_type>(val.as_long()));
return *this;
case AMOUNT:
- as_datetime_lval() += date_duration(val.as_amount().to_long());
+ as_datetime_lval() +=
+ time_duration_t(0, 0, static_cast<time_duration_t::sec_type>
+ (val.as_amount().to_long()));
return *this;
default:
break;
@@ -351,10 +354,10 @@ value_t& value_t::operator+=(const value_t& val)
case DATE:
switch (val.type()) {
case INTEGER:
- as_date_lval() += date_duration_t(val.as_long());
+ as_date_lval() += gregorian::date_duration(val.as_long());
return *this;
case AMOUNT:
- as_date_lval() += date_duration_t(val.as_amount().to_long());
+ as_date_lval() += gregorian::date_duration(val.as_amount().to_long());
return *this;
default:
break;
@@ -466,10 +469,13 @@ value_t& value_t::operator-=(const value_t& val)
case DATETIME:
switch (val.type()) {
case INTEGER:
- as_datetime_lval() -= date_duration(val.as_long());
+ as_datetime_lval() -=
+ time_duration_t(0, 0, static_cast<time_duration_t::sec_type>(val.as_long()));
return *this;
case AMOUNT:
- as_datetime_lval() -= date_duration(val.as_amount().to_long());
+ as_datetime_lval() -=
+ time_duration_t(0, 0, static_cast<time_duration_t::sec_type>
+ (val.as_amount().to_long()));
return *this;
default:
break;
@@ -479,10 +485,10 @@ value_t& value_t::operator-=(const value_t& val)
case DATE:
switch (val.type()) {
case INTEGER:
- as_date_lval() -= date_duration_t(val.as_long());
+ as_date_lval() -= gregorian::date_duration(val.as_long());
return *this;
case AMOUNT:
- as_date_lval() -= date_duration_t(val.as_amount().to_long());
+ as_date_lval() -= gregorian::date_duration(val.as_amount().to_long());
return *this;
default:
break;
@@ -1187,6 +1193,13 @@ void value_t::in_place_negate()
case BALANCE:
as_balance_lval().in_place_negate();
return;
+ case SEQUENCE: {
+ value_t temp;
+ foreach (const value_t& value, as_sequence())
+ temp.push_back(- value);
+ *this = temp;
+ return;
+ }
default:
break;
}
@@ -1216,6 +1229,13 @@ void value_t::in_place_not()
case STRING:
set_boolean(as_string().empty());
return;
+ case SEQUENCE: {
+ value_t temp;
+ foreach (const value_t& value, as_sequence())
+ temp.push_back(! value);
+ *this = temp;
+ return;
+ }
default:
break;
}