mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-31 07:58:24 +02:00
fixed #318: Logger local time doesn't automatically account for DST
This commit is contained in:
parent
9d47f3ced8
commit
ad9cebaf38
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user