I think the Timezone::isDst() functions on Windows and Unix both have a possible bug: you should check if the localtime() function returns a NULL pointer or not.
I also find it a bit strange that the Poco::LocalDateTime() class doesn't have a constructor which calculates on the fly the tzd() of the supplied time.
At the moment I calculate it myself like this:
- Code: Select all
Poco::LocalDateTime TimeLib::unixTimeToLocalDateTime(Poco::Int64 utc_unixtime)
{
Poco::Timestamp ts(Poco::Timestamp::TimeVal(utc_unixtime)*Poco::Timestamp::resolution());
// tzd() = utcOffset() + dst();
int tzd = Poco::Timezone::utcOffset();
if (Poco::Timezone::isDst(ts))
{
tzd += 3600; // Always 1 hour ?
}
return Poco::LocalDateTime(tzd, Poco::DateTime(ts));
}
Ronny





