diff options
author | Craig Earls <enderw88@gmail.com> | 2013-01-29 11:39:01 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2013-01-29 11:39:01 -0700 |
commit | a4c81a4cd72024bb8e39550447cc28c6335af028 (patch) | |
tree | a3ab9b26047500e8a4582e3715ecfead19389b3c /src/amount.cc | |
parent | f8ff46241bfd2b1beed418b201a121c2738db089 (diff) | |
parent | 1e709d1040eb2c10f7ab0ea80e903c12fcb0f35c (diff) | |
download | fork-ledger-a4c81a4cd72024bb8e39550447cc28c6335af028.tar.gz fork-ledger-a4c81a4cd72024bb8e39550447cc28c6335af028.tar.bz2 fork-ledger-a4c81a4cd72024bb8e39550447cc28c6335af028.zip |
Merge branch 'next' into kitchen-sink
Diffstat (limited to 'src/amount.cc')
-rw-r--r-- | src/amount.cc | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/amount.cc b/src/amount.cc index cba9a282..ee03827e 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -195,7 +195,10 @@ namespace { for (const char * p = buf; *p; p++) { if (*p == '.') { - if (commodity_t::decimal_comma_by_default || + if (commodity_t::time_colon_by_default || + (comm && comm->has_flags(COMMODITY_STYLE_TIME_COLON))) + out << ':'; + else if (commodity_t::decimal_comma_by_default || (comm && comm->has_flags(COMMODITY_STYLE_DECIMAL_COMMA))) out << ','; else @@ -209,7 +212,10 @@ namespace { out << *p; if (integer_digits > 3 && --integer_digits % 3 == 0) { - if (commodity_t::decimal_comma_by_default || + if (commodity_t::time_colon_by_default || + (comm && comm->has_flags(COMMODITY_STYLE_TIME_COLON))) + out << ':'; + else if (commodity_t::decimal_comma_by_default || (comm && comm->has_flags(COMMODITY_STYLE_DECIMAL_COMMA))) out << '.'; else @@ -737,6 +743,16 @@ void amount_t::in_place_unreduce() } if (shifted) { + if ("h" == comm->symbol() && commodity_t::time_colon_by_default) { + amount_t floored = tmp.floored(); + amount_t precision = tmp - floored; + if (precision < 0.0) { + precision += 1.0; + floored -= 1.0; + } + tmp = floored + (precision * (comm->smaller()->number() / 100.0)); + } + *this = tmp; commodity_ = comm; } @@ -1090,6 +1106,9 @@ bool amount_t::parse(std::istream& in, const parse_flags_t& flags) bool decimal_comma_style = (commodity_t::decimal_comma_by_default || commodity().has_flags(COMMODITY_STYLE_DECIMAL_COMMA)); + bool time_colon_style + = (commodity_t::time_colon_by_default || + commodity().has_flags(COMMODITY_STYLE_TIME_COLON)); new_quantity->prec = 0; |