gnucash stable: Bug 799004 - Update of Prices attaches incorrect Date
John Ralls
jralls at code.gnucash.org
Sat Jul 8 19:12:23 EDT 2023
Updated via https://github.com/Gnucash/gnucash/commit/e20f6036 (commit)
from https://github.com/Gnucash/gnucash/commit/fde47d1c (commit)
commit e20f60361f34b566b596e5ef6511e46b863d0ae1
Author: John Ralls <jralls at ceridwen.us>
Date: Sat Jul 8 16:07:09 2023 -0700
Bug 799004 - Update of Prices attaches incorrect Date
Using a "close" time of 16:00 is a nice idea except that we don't know
what timezone it is, so it's not terribly useful. Use neutral time
instead so that the date will be right in all timezones.
diff --git a/libgnucash/app-utils/gnc-quotes.cpp b/libgnucash/app-utils/gnc-quotes.cpp
index 9d97c2a9ad..8ef7c4597c 100644
--- a/libgnucash/app-utils/gnc-quotes.cpp
+++ b/libgnucash/app-utils/gnc-quotes.cpp
@@ -586,25 +586,18 @@ calc_price_time(const PriceParams& p)
*/
if (p.date)
{
- /* Returned date is always in MM/DD/YYYY format according to
- * F::Q man page, transform it to simplify conversion to
- * GncDateTime.
- */
- auto date_tmp = *p.date;
- auto iso_date_str = date_tmp.substr (6, 4) + "-" + date_tmp.substr (0, 2) +
- "-" + date_tmp.substr (3, 2);
try
{
- auto close_time{GncDateTime(iso_date_str + " 16:00:00")};
+ auto quote_time{GncDateTime(GncDate(*p.date, "m-d-y"))};
PINFO("Quote date included, using %s for %s:%s",
- close_time.format("%Y-%m-%d %H:%M:%S").c_str(), p.ns, p.mnemonic);
- return static_cast<time64>(close_time);
- }
- catch (...)
+ quote_time.format("%Y-%m-%d %H:%M:%S").c_str(), p.ns, p.mnemonic);
+ return static_cast<time64>(quote_time);
+ }
+ catch (const std::exception &err)
{
auto now{GncDateTime()};
- PWARN("Warning: failed to parse quote date '%s' for %s:%s - will use %s",
- iso_date_str.c_str(), p.ns, p.mnemonic, now.format("%Y-%m-%d %H:%M%S").c_str());
+ PWARN("Warning: failed to parse quote date '%s' for %s:%s because %s - will use %s",
+ p.date->c_str(), p.ns, p.mnemonic, err.what(), now.format("%Y-%m-%d %H:%M%S").c_str());
return static_cast<time64>(now);
}
}
Summary of changes:
libgnucash/app-utils/gnc-quotes.cpp | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
More information about the gnucash-changes
mailing list