diff options
author | John Wiegley <johnw@newartisans.com> | 2009-10-28 01:17:54 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-10-28 01:17:54 -0400 |
commit | cc532c31aa8aa745d6d02c5c0cb22b3d75866590 (patch) | |
tree | 47eaa051abf286a08fe4406f41dacab4407ac352 | |
parent | 559566751ddd29caf2cd74c3d44982c907bd1020 (diff) | |
download | fork-ledger-cc532c31aa8aa745d6d02c5c0cb22b3d75866590.tar.gz fork-ledger-cc532c31aa8aa745d6d02c5c0cb22b3d75866590.tar.bz2 fork-ledger-cc532c31aa8aa745d6d02c5c0cb22b3d75866590.zip |
Added TRUE_CURRENT_TIME() macro
Because CURRENT_TIME() can now be a past date if --now is used.
-rw-r--r-- | src/commodity.cc | 2 | ||||
-rw-r--r-- | src/times.h | 8 | ||||
-rw-r--r-- | src/utils.cc | 13 |
3 files changed, 12 insertions, 11 deletions
diff --git a/src/commodity.cc b/src/commodity.cc index 4041946b..54cb02d6 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -393,7 +393,7 @@ commodity_t::check_for_updated_price(const optional<price_point_t>& point, DEBUG("commodity.download", "moment = " << *moment); DEBUG("commodity.download", "slip.moment = " << seconds_diff); } else { - seconds_diff = (CURRENT_TIME() - point->when).total_seconds(); + seconds_diff = (TRUE_CURRENT_TIME() - point->when).total_seconds(); DEBUG("commodity.download", "slip.now = " << seconds_diff); } diff --git a/src/times.h b/src/times.h index 035d86cd..69e3af51 100644 --- a/src/times.h +++ b/src/times.h @@ -69,11 +69,11 @@ inline bool is_valid(const date_t& moment) { extern optional<datetime_t> epoch; #ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK -#define CURRENT_TIME() \ - (epoch ? *epoch : boost::posix_time::microsec_clock::universal_time()) +#define TRUE_CURRENT_TIME() (boost::posix_time::microsec_clock::universal_time()) +#define CURRENT_TIME() (epoch ? *epoch : TRUE_CURRENT_TIME()) #else -#define CURRENT_TIME() \ - (epoch ? *epoch : boost::posix_time::second_clock::universal_time()) +#define TRUE_CURRENT_TIME() (boost::posix_time::second_clock::universal_time()) +#define CURRENT_TIME() (epoch ? *epoch : TRUE_CURRENT_TIME()) #endif #define CURRENT_DATE() \ (epoch ? epoch->date() : boost::gregorian::day_clock::universal_day()) diff --git a/src/utils.cc b/src/utils.cc index 85a7aa46..a5334155 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -531,14 +531,15 @@ bool logger_func(log_level_t level) { if (! logger_has_run) { logger_has_run = true; - logger_start = CURRENT_TIME(); + logger_start = TRUE_CURRENT_TIME(); IF_VERIFY() *_log_stream << " TIME OBJSZ MEMSZ" << std::endl; } *_log_stream << std::right << std::setw(5) - << (CURRENT_TIME() - logger_start).total_milliseconds() << "ms"; + << (TRUE_CURRENT_TIME() - + logger_start).total_milliseconds() << "ms"; #if defined(VERIFY_ON) IF_VERIFY() { @@ -616,7 +617,7 @@ struct timer_t bool active; timer_t(log_level_t _level, std::string _description) - : level(_level), begin(CURRENT_TIME()), + : level(_level), begin(TRUE_CURRENT_TIME()), spent(time_duration(0, 0, 0, 0)), description(_description), active(true) {} }; @@ -637,7 +638,7 @@ void start_timer(const char * name, log_level_t lvl) timers.insert(timer_map::value_type(name, timer_t(lvl, _log_buffer.str()))); } else { assert((*i).second.description == _log_buffer.str()); - (*i).second.begin = CURRENT_TIME(); + (*i).second.begin = TRUE_CURRENT_TIME(); (*i).second.active = true; } _log_buffer.str(""); @@ -657,7 +658,7 @@ void stop_timer(const char * name) timer_map::iterator i = timers.find(name); assert(i != timers.end()); - (*i).second.spent += CURRENT_TIME() - (*i).second.begin; + (*i).second.spent += TRUE_CURRENT_TIME() - (*i).second.begin; (*i).second.active = false; #if defined(VERIFY_ON) @@ -682,7 +683,7 @@ void finish_timer(const char * name) time_duration spent = (*i).second.spent; if ((*i).second.active) { - spent = CURRENT_TIME() - (*i).second.begin; + spent = TRUE_CURRENT_TIME() - (*i).second.begin; (*i).second.active = false; } |