Merge commit 'refs/pull/1853/head' of github.com:znc/znc

This commit is contained in:
Alexey Sokolov
2023-01-07 20:41:48 +00:00
2 changed files with 36 additions and 0 deletions

View File

@@ -585,7 +585,22 @@ timeval CUtils::ParseServerTime(const CString& sTime) {
struct timeval tv;
memset(&tv, 0, sizeof(tv));
if (cp) {
char* oldTZ = getenv("TZ");
if (oldTZ) oldTZ = strdup(oldTZ);
setenv("TZ", "UTC", 1);
tzset();
tv.tv_sec = mktime(&stm);
// restore old value
if (oldTZ) {
setenv("TZ", oldTZ, 1);
free(oldTZ);
} else {
unsetenv("TZ");
}
tzset();
CString s_usec(cp);
if (s_usec.TrimPrefix(".") && s_usec.TrimSuffix("Z")) {
tv.tv_usec = s_usec.ToULong() * 1000;