From ff0a8bc94e93817b51503ebdbac6985b53c9c35b Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Fri, 4 May 2012 22:44:31 +0700 Subject: [PATCH] Fix compilation of timestamps in -D On some architectures time_t is not the same as long int. Thanks to fred for reporting this. --- include/znc/ZNCDebug.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/znc/ZNCDebug.h b/include/znc/ZNCDebug.h index 606340ff..0c92d450 100644 --- a/include/znc/ZNCDebug.h +++ b/include/znc/ZNCDebug.h @@ -10,6 +10,7 @@ #define ZNCDEBUG_H #include +#include #include #include #include @@ -42,11 +43,12 @@ public: static bool StdoutIsTTY() { return stdoutIsTTY; } static void SetDebug(bool b) { debug = b; } static bool Debug() { return debug; } - static std::string GetTimestamp() { + static CString GetTimestamp() { char buf[64]; timeval time_now; gettimeofday(&time_now, NULL); - tm* time_info = localtime(&time_now.tv_sec); + time_t currentSec = (time_t) time_now.tv_sec; // cast from long int + tm* time_info = localtime(¤tSec); strftime(buf, sizeof(buf), "[%Y-%m-%d %H:%M:%S.", time_info); std::ostringstream buffer; buffer << buf << std::setw(6) << std::setfill('0') << (time_now.tv_usec) << "] ";