diff options
author | John Wiegley <johnw@newartisans.com> | 2007-04-18 23:50:25 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:35:37 -0400 |
commit | ba2a54f3d22dacd69d8202fc9a7d32a2b40b1d1e (patch) | |
tree | 02bfb4221cf9b73bd57cf6df2abae58f3b365c0b /quotes.cc | |
parent | 4c460a1c40cfb1547ce9a4c91b4e8a87d768463d (diff) | |
download | fork-ledger-ba2a54f3d22dacd69d8202fc9a7d32a2b40b1d1e.tar.gz fork-ledger-ba2a54f3d22dacd69d8202fc9a7d32a2b40b1d1e.tar.bz2 fork-ledger-ba2a54f3d22dacd69d8202fc9a7d32a2b40b1d1e.zip |
Initial round of changes to use boost_date_time
Diffstat (limited to 'quotes.cc')
-rw-r--r-- | quotes.cc | 25 |
1 files changed, 14 insertions, 11 deletions
@@ -1,5 +1,4 @@ #include "quotes.h" -#include "datetime.h" #include "error.h" #include "debug.h" @@ -10,15 +9,15 @@ namespace ledger { void quotes_by_script::operator()(commodity_base_t& commodity, - const datetime_t& moment, - const datetime_t& date, - const datetime_t& last, + const ptime& moment, + const ptime& date, + const ptime& last, amount_t& price) { DEBUG_CLASS("ledger.quotes.download"); DEBUG_PRINT_("commodity: " << commodity.symbol); - DEBUG_PRINT_TIME_(datetime_t::now); + DEBUG_PRINT_TIME_(now); DEBUG_PRINT_TIME_(moment); DEBUG_PRINT_TIME_(date); DEBUG_PRINT_TIME_(last); @@ -27,9 +26,9 @@ void quotes_by_script::operator()(commodity_base_t& commodity, DEBUG_PRINT_("pricing_leeway is " << pricing_leeway); if ((commodity.history && - (datetime_t::now - commodity.history->last_lookup) < (long)pricing_leeway) || - (datetime_t::now - last) < (long)pricing_leeway || - (price && moment > date && (moment - date) <= (long)pricing_leeway)) + (now - commodity.history->last_lookup) < pricing_leeway) || + (now - last) < pricing_leeway || + (price && moment > date && (moment - date) <= pricing_leeway)) return; using namespace std; @@ -58,9 +57,9 @@ void quotes_by_script::operator()(commodity_base_t& commodity, DEBUG_PRINT_("downloaded quote: " << buf); price.parse(buf); - commodity.add_price(datetime_t::now, price); + commodity.add_price(now, price); - commodity.history->last_lookup = datetime_t::now; + commodity.history->last_lookup = now; cache_dirty = true; if (price && ! price_db.empty()) { @@ -69,8 +68,12 @@ void quotes_by_script::operator()(commodity_base_t& commodity, #else ofstream database(price_db.c_str(), ios_base::out | ios_base::app); #endif - database << "P " << datetime_t::now.to_string("%Y/%m/%d %H:%M:%S") +#if 0 + // jww (2007-04-18): Need to convert to local time and print + // here, print with UTC timezone specifier + database << "P " << now.to_string("%Y/%m/%d %H:%M:%S") << " " << commodity.symbol << " " << price << endl; +#endif } } else { throw new error(std::string("Failed to download price for '") + |