From: Christian Hofstaedtler Date: Sun, 3 Jan 2016 15:36:40 +0000 (+0100) Subject: Add timezone to generated bind slave zone files X-Git-Tag: dnsdist-1.0.0-alpha2~129^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F3156%2Fhead;p=thirdparty%2Fpdns.git Add timezone to generated bind slave zone files --- diff --git a/pdns/misc.cc b/pdns/misc.cc index 4417658dd6..5ef1138b44 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -174,10 +174,13 @@ int writen2WithTimeout(int fd, const void * buffer, size_t len, int timeout) string nowTime() { - time_t now=time(0); - string t=ctime(&now); - boost::trim_right(t); - return t; + time_t now = time(nullptr); + struct tm* tm = localtime(&now); + char buffer[30]; + // YYYY-mm-dd HH:MM:SS TZOFF + strftime(buffer, sizeof(buffer), "%F %T %z", tm); + buffer[sizeof(buffer)-1] = '\0'; + return buffer; } uint16_t getShort(const unsigned char *p)