fixed #318: Logger local time doesn't automatically account for DST

This commit is contained in:
Guenter Obiltschnig 2014-05-21 09:00:53 +02:00
parent 9d47f3ced8
commit ad9cebaf38

View File

@ -16,6 +16,7 @@
#include "Poco/Timezone.h"
#include "Poco/Exception.h"
#include "Poco/Mutex.h"
#include <ctime>
@ -32,6 +33,8 @@ public:
int timeZone()
{
Poco::FastMutex::ScopedLock lock(_mutex);
#if defined(__APPLE__) || defined(__FreeBSD__) || defined (__OpenBSD__) || defined(POCO_ANDROID) // no timezone global var
std::time_t now = std::time(NULL);
struct std::tm t;
@ -39,16 +42,24 @@ public:
std::time_t utc = std::mktime(&t);
return now - utc;
#elif defined(__CYGWIN__)
tzset();
return -_timezone;
#else
tzset();
return -timezone;
#endif
}
const char* name(bool dst)
{
Poco::FastMutex::ScopedLock lock(_mutex);
tzset();
return tzname[dst ? 1 : 0];
}
private:
Poco::FastMutex _mutex;
};