mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-25 18:30:23 -06:00
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.
This commit is contained in:
parent
fde47d1c7f
commit
e20f60361f
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user