Hi,
On 2018-07-12 09:58:19 +0200, Giovanni Mascellani wrote:
> I do not know much of how gnucash works internally. Would you care to
> produce a minimal example that demonstrates the bug?
Unfortunately I don't know much about C++ and boost. But the bug
occurs on 2012-03-25 03:47:47 +0200, i.e. 1332640067 as the number
of seconds since the epoch, with the timezone "Europe/Paris". When
converting this date to a string with the operator<< and the
format "%Y-%m-%d %H:%M:%s %q", I get 2012-03-25 02:47:47 +0100
instead of 2012-03-25 03:47:47 +0200 (i.e. it generates the date/time
with DST off instead of DST on).
I'm not sure, but I think this GnuCash function from
libgnucash/engine/gnc-datetime.cpp is involved:
std::string
GncDateTimeImpl::format(const char* format) const
{
using Facet = boost::local_time::local_time_facet;
std::stringstream ss;
//The stream destructor frees the facet, so it must be heap-allocated.
auto output_facet(new Facet(normalize_format(format).c_str()));
ss.imbue(std::locale(std::locale(), output_facet));
ss << m_time;
return ss.str();
}
In the same file, one has:
using LDT = boost::local_time::local_date_time;
and
class GncDateTimeImpl
{
public:
GncDateTimeImpl() :
m_time(boost::local_time::local_sec_clock::local_time(tzp.get(boost::gregorian::day_clock::local_day().year())))
{}
GncDateTimeImpl(const time64 time) : m_time(LDT_from_unix_local(time)) {}
GncDateTimeImpl(const struct tm tm) : m_time(LDT_from_struct_tm(tm)) {}
GncDateTimeImpl(const GncDateImpl& date, DayPart part = DayPart::neutral);
GncDateTimeImpl(std::string str);
GncDateTimeImpl(PTime&& pt) : m_time(pt, tzp.get(pt.date().year())) {}
GncDateTimeImpl(LDT&& ldt) : m_time(ldt) {}
operator time64() const;
operator struct tm() const;
void now() { m_time =
boost::local_time::local_sec_clock::local_time(tzp.get(boost::gregorian::day_clock::local_day().year()));
}
long offset() const;
struct tm utc_tm() const { return to_tm(m_time.utc_time()); }
std::unique_ptr<GncDateImpl> date() const;
std::string format(const char* format) const;
std::string format_zulu(const char* format) const;
private:
LDT m_time;
static const TD time_of_day[3];
};
--
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)