Skip to content

Commit

Permalink
fixed pocoproject#318: Logger local time doesn't automatically accoun…
Browse files Browse the repository at this point in the history
…t for DST
  • Loading branch information
obiltschnig committed May 21, 2014
1 parent 9d47f3c commit ad9ceba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Foundation/src/Timezone_UNIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "Poco/Timezone.h"
#include "Poco/Exception.h"
#include "Poco/Mutex.h"
#include <ctime>


Expand All @@ -32,23 +33,33 @@ class TZInfo

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;
gmtime_r(&now, &t);
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;
};


Expand Down

0 comments on commit ad9ceba

Please sign in to comment.