From 2a6a1d70ffd50e1322fb99868ae585a0cedb091c Mon Sep 17 00:00:00 2001 From: John Marrett Date: Thu, 29 Dec 2022 07:53:39 -0500 Subject: [PATCH 01/10] Add ParseServerTime TZ fix and tests --- src/Utils.cpp | 15 +++++++++++++++ test/UtilsTest.cpp | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/Utils.cpp b/src/Utils.cpp index 870edeca..c591ee8d 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -587,7 +587,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; diff --git a/test/UtilsTest.cpp b/test/UtilsTest.cpp index b45553b1..46edd27d 100644 --- a/test/UtilsTest.cpp +++ b/test/UtilsTest.cpp @@ -109,6 +109,27 @@ TEST(UtilsTest, ServerTime) { CString str3 = CUtils::FormatServerTime(tv3); EXPECT_EQ(str3, "1970-01-01T00:00:00.000Z"); + if (oldTZ) { + setenv("TZ", oldTZ, 1); + free(oldTZ); + } else { + unsetenv("TZ"); + } + tzset(); + +} + +TEST(UtilsTest, ParseServerTime) { + char* oldTZ = getenv("TZ"); + if (oldTZ) oldTZ = strdup(oldTZ); + setenv("TZ", "America/Montreal", 1); + tzset(); + + timeval tv4 = CUtils::ParseServerTime("2011-10-19T16:40:51.620Z"); + CString str4 = CUtils::FormatServerTime(tv4); + EXPECT_EQ(str4, "2011-10-19T16:40:51.620Z"); + + if (oldTZ) { setenv("TZ", oldTZ, 1); free(oldTZ); From 7c6dc23f14f5894e642644454fd5622e9926ed7a Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 7 Jan 2023 13:51:56 +0000 Subject: [PATCH 02/10] CI: update comment --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index dd96fe0e..3efa2c91 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,8 @@ timestamps { node('freebsd') { // freebsd 13.1 + pkg install git openjdk17 cmake icu pkgconf swig python3 boost-libs gettext-tools qt5-buildtools qt5-network qt5-qmake + // Then fill known_hosts with https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints + // (needed for crowdin cron job in jenkins) timeout(time: 30, unit: 'MINUTES') { def wsdir = pwd() stage('Checkout') { From 42fdf9b49f374849d4177f6e185e70a6541f7d31 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 7 Jan 2023 17:59:29 +0000 Subject: [PATCH 03/10] Update Csocket submodule Fix several compatility issues with SSL, and use steady clock --- .gitmodules | 2 +- third_party/Csocket | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 43fa3e96..5242e053 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "Csocket"] path = third_party/Csocket - url = https://github.com/jimloco/Csocket.git + url = https://github.com/znc/Csocket [submodule "third_party/googletest"] path = third_party/googletest url = https://github.com/google/googletest diff --git a/third_party/Csocket b/third_party/Csocket index e8d9e0bb..81d27e61 160000 --- a/third_party/Csocket +++ b/third_party/Csocket @@ -1 +1 @@ -Subproject commit e8d9e0bb248c521c2c7fa01e1c6a116d929c41b4 +Subproject commit 81d27e6137334905fe563af483da284465065028 From c5befe3dc4c9852784caed1d5f9eddc7c2f30173 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 7 Jan 2023 18:10:50 +0000 Subject: [PATCH 04/10] Use steady clock for cache map --- src/Utils.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Utils.cpp b/src/Utils.cpp index bf6b193b..94c49172 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -56,6 +56,7 @@ #include #include #include +#include using std::map; using std::vector; @@ -436,11 +437,8 @@ timeval CUtils::GetTime() { } unsigned long long CUtils::GetMillTime() { - struct timeval tv = GetTime(); - unsigned long long iTime = 0; - iTime = (unsigned long long)tv.tv_sec * 1000; - iTime += ((unsigned long long)tv.tv_usec / 1000); - return iTime; + std::chrono::time_point time = std::chrono::steady_clock::now(); + return std::chrono::duration_cast(time.time_since_epoch()).count(); } CString CUtils::CTime(time_t t, const CString& sTimezone) { From 64359328cfebc1985121669cf026f939f9ea73e0 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 7 Jan 2023 21:14:22 +0000 Subject: [PATCH 05/10] Use std::chrono and cctz instead of messing with TZ --- .gitmodules | 3 + CMakeLists.txt | 27 +++++++-- src/CMakeLists.txt | 1 + src/Utils.cpp | 134 +++++++-------------------------------------- third_party/cctz | 1 + 5 files changed, 48 insertions(+), 118 deletions(-) create mode 160000 third_party/cctz diff --git a/.gitmodules b/.gitmodules index 5242e053..e21f1e3b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "docker"] path = docker url = https://github.com/znc/znc-docker +[submodule "third_party/cctz"] + path = third_party/cctz + url = https://github.com/google/cctz diff --git a/CMakeLists.txt b/CMakeLists.txt index 69fd9004..ef2afacf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,6 +269,28 @@ else() set(CSOCK_USE_POLL true) endif() +# TODO: verify that this find_package works; on Gentoo it's not currently (Jan +# 2023) packaged, so in my tests it always falls back to submodule +find_package(cctz QUIET) +if (NOT cctz_FOUND) + set(cctz_cc + third_party/cctz/src/civil_time_detail.cc + third_party/cctz/src/time_zone_fixed.cc + third_party/cctz/src/time_zone_format.cc + third_party/cctz/src/time_zone_if.cc + third_party/cctz/src/time_zone_impl.cc + third_party/cctz/src/time_zone_info.cc + third_party/cctz/src/time_zone_libc.cc + third_party/cctz/src/time_zone_lookup.cc + third_party/cctz/src/time_zone_posix.cc + third_party/cctz/src/zone_info_source.cc + ) + add_library(cctz STATIC EXCLUDE_FROM_ALL ${cctz_cc}) + add_library(cctz::cctz ALIAS cctz) + target_include_directories(cctz PUBLIC + ${PROJECT_SOURCE_DIR}/third_party/cctz/include) +endif() + check_cxx_symbol_exists(getopt_long "getopt.h" HAVE_GETOPT_LONG) check_cxx_symbol_exists(lstat "sys/types.h;sys/stat.h;unistd.h" HAVE_LSTAT) check_cxx_symbol_exists(getpassphrase "stdlib.h" HAVE_GETPASSPHRASE) @@ -430,8 +452,3 @@ render_framed_multiline("${summary_lines}") message("") message("Now you can run 'make' to compile ZNC") message("") - -# TODO -# ==== -# -# remove old configure.ac and Makefile.in diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 830303d7..ad9177ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,6 +81,7 @@ if(Boost_FOUND) target_link_libraries(znclib ${Boost_LIBRARIES}) list(APPEND znc_include_dirs ${Boost_INCLUDE_DIRS}) endif() +target_link_libraries(znclib cctz::cctz) target_include_directories(znc PUBLIC ${znc_include_dirs}) target_include_directories(znclib PUBLIC ${znc_include_dirs}) diff --git a/src/Utils.cpp b/src/Utils.cpp index 8c1ead17..c10dfa60 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -58,6 +58,8 @@ #include #include +#include "cctz/time_zone.h" + using std::map; using std::vector; @@ -396,29 +398,6 @@ void CUtils::PrintStatus(bool bSuccess, const CString& sMessage) { fflush(stdout); } -namespace { -/* Switch GMT-X and GMT+X - * - * See https://en.wikipedia.org/wiki/Tz_database#Area - * - * "In order to conform with the POSIX style, those zone names beginning - * with "Etc/GMT" have their sign reversed from what most people expect. - * In this style, zones west of GMT have a positive sign and those east - * have a negative sign in their name (e.g "Etc/GMT-14" is 14 hours - * ahead/east of GMT.)" - */ -inline CString FixGMT(CString sTZ) { - if (sTZ.length() >= 4 && sTZ.StartsWith("GMT")) { - if (sTZ[3] == '+') { - sTZ[3] = '-'; - } else if (sTZ[3] == '-') { - sTZ[3] = '+'; - } - } - return sTZ; -} -} // namespace - timeval CUtils::GetTime() { #ifdef HAVE_CLOCK_GETTIME timespec ts; @@ -442,64 +421,22 @@ unsigned long long CUtils::GetMillTime() { } CString CUtils::CTime(time_t t, const CString& sTimezone) { - char s[30] = {}; // should have at least 26 bytes - if (sTimezone.empty()) { - ctime_r(&t, s); - // ctime() adds a trailing newline - return CString(s).Trim_n(); - } - CString sTZ = FixGMT(sTimezone); - - // backup old value - char* oldTZ = getenv("TZ"); - if (oldTZ) oldTZ = strdup(oldTZ); - setenv("TZ", sTZ.c_str(), 1); - tzset(); - - ctime_r(&t, s); - - // restore old value - if (oldTZ) { - setenv("TZ", oldTZ, 1); - free(oldTZ); - } else { - unsetenv("TZ"); - } - tzset(); - - return CString(s).Trim_n(); + return FormatTime(t, "%c", sTimezone); } CString CUtils::FormatTime(time_t t, const CString& sFormat, const CString& sTimezone) { - char s[1024] = {}; - tm m; + cctz::time_zone tz; if (sTimezone.empty()) { - localtime_r(&t, &m); - strftime(s, sizeof(s), sFormat.c_str(), &m); - return s; - } - CString sTZ = FixGMT(sTimezone); - - // backup old value - char* oldTZ = getenv("TZ"); - if (oldTZ) oldTZ = strdup(oldTZ); - setenv("TZ", sTZ.c_str(), 1); - tzset(); - - localtime_r(&t, &m); - strftime(s, sizeof(s), sFormat.c_str(), &m); - - // restore old value - if (oldTZ) { - setenv("TZ", oldTZ, 1); - free(oldTZ); + tz = cctz::local_time_zone(); + } else if (sTimezone.StartsWith("GMT")) { + int offset = CString(sTimezone.substr(3)).ToInt(); + tz = cctz::fixed_time_zone(cctz::seconds(offset * 60 * 60)); } else { - unsetenv("TZ"); + cctz::load_time_zone(sTimezone, &tz); } - tzset(); - return s; + return cctz::format(sFormat, std::chrono::system_clock::from_time_t(t), tz); } CString CUtils::FormatTime(const timeval& tv, const CString& sFormat, @@ -507,6 +444,7 @@ CString CUtils::FormatTime(const timeval& tv, const CString& sFormat, // Parse additional format specifiers before passing them to // strftime, since the way strftime treats unknown format // specifiers is undefined. + // TODO: consider using cctz's %E#f instead. CString sFormat2; // Make sure %% is parsed correctly, i.e. %%f is passed through to @@ -561,51 +499,21 @@ CString CUtils::FormatTime(const timeval& tv, const CString& sFormat, } CString CUtils::FormatServerTime(const timeval& tv) { - CString s_msec(tv.tv_usec / 1000); - while (s_msec.length() < 3) { - s_msec = "0" + s_msec; - } - // TODO support leap seconds properly - // TODO support message-tags properly - struct tm stm; - memset(&stm, 0, sizeof(stm)); - // OpenBSD has tv_sec as int, so explicitly convert it to time_t to make - // gmtime_r() happy - const time_t secs = tv.tv_sec; - gmtime_r(&secs, &stm); - char sTime[20] = {}; - strftime(sTime, sizeof(sTime), "%Y-%m-%dT%H:%M:%S", &stm); - return CString(sTime) + "." + s_msec + "Z"; + using namespace std::chrono; + system_clock::time_point time{duration_cast( + seconds(tv.tv_sec) + microseconds(tv.tv_usec))}; + return cctz::format("%Y-%m-%dT%H:%M:%E3SZ", time, cctz::utc_time_zone()); } timeval CUtils::ParseServerTime(const CString& sTime) { - struct tm stm; - memset(&stm, 0, sizeof(stm)); - const char* cp = strptime(sTime.c_str(), "%Y-%m-%dT%H:%M:%S", &stm); + using namespace std::chrono; + system_clock::time_point tp; + cctz::parse("%Y-%m-%dT%H:%M:%E*SZ", sTime, cctz::utc_time_zone(), &tp); 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; - } - } + microseconds usec = duration_cast(tp.time_since_epoch()); + tv.tv_sec = usec.count() / 1000000; + tv.tv_usec = usec.count() % 1000000; return tv; } diff --git a/third_party/cctz b/third_party/cctz new file mode 160000 index 00000000..790e1abe --- /dev/null +++ b/third_party/cctz @@ -0,0 +1 @@ +Subproject commit 790e1abe60136288464e500a2a825b9be031a622 From aaead6f11b15a5d5848b934958055bc71ba2c9ed Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 7 Jan 2023 21:26:01 +0000 Subject: [PATCH 06/10] Copy relevant parts of cctz to the tarball --- make-tarball.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/make-tarball.sh b/make-tarball.sh index 5369f551..a96a1970 100755 --- a/make-tarball.sh +++ b/make-tarball.sh @@ -43,6 +43,8 @@ echo "Exporting . to $TMPDIR/$ZNCDIR..." git checkout-index --all --prefix=$TMPDIR/$ZNCDIR/ mkdir -p --mode=0755 $TMPDIR/$ZNCDIR/third_party/Csocket cp -p third_party/Csocket/Csocket.cc third_party/Csocket/Csocket.h $TMPDIR/$ZNCDIR/third_party/Csocket/ +mkdir -p --mode=0755 $TMPDIR/$ZNCDIR/third_party/cctz +cp -Rp third_party/cctz/src third_party/cctz/include third_party/cctz/LICENSE.txt $TMPDIR/$ZNCDIR/third_party/cctz/ ( cd $TMPDIR2 cmake $TMPDIR/$ZNCDIR -DWANT_PERL=yes -DWANT_PYTHON=yes From f9693e47a6ed621aa29a69641c0fdf26b96c67e2 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 7 Jan 2023 21:45:39 +0000 Subject: [PATCH 07/10] Split dependencies of znclib target --- src/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad9177ca..241a1970 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,24 +64,24 @@ set(znc_include_dirs "$" "$" "$") -target_link_libraries(znclib ${CMAKE_DL_LIBS} Threads::Threads) +target_link_libraries(znclib PRIVATE ${CMAKE_DL_LIBS} Threads::Threads) if(OPENSSL_FOUND) - target_link_libraries(znclib ${OPENSSL_LIBRARIES}) + target_link_libraries(znclib PUBLIC ${OPENSSL_LIBRARIES}) list(APPEND znc_include_dirs "${OPENSSL_INCLUDE_DIR}") endif() if(ZLIB_FOUND) - target_link_libraries(znclib ${ZLIB_LIBRARIES}) + target_link_libraries(znclib PRIVATE ${ZLIB_LIBRARIES}) list(APPEND znc_include_dirs ${ZLIB_INCLUDE_DIRS}) endif() if(ICU_FOUND) - target_link_libraries(znclib ${ICU_LDFLAGS}) + target_link_libraries(znclib PUBLIC ${ICU_LDFLAGS}) list(APPEND znc_include_dirs ${ICU_INCLUDE_DIRS}) endif() if(Boost_FOUND) - target_link_libraries(znclib ${Boost_LIBRARIES}) + target_link_libraries(znclib PRIVATE ${Boost_LIBRARIES}) list(APPEND znc_include_dirs ${Boost_INCLUDE_DIRS}) endif() -target_link_libraries(znclib cctz::cctz) +target_link_libraries(znclib PRIVATE cctz::cctz) target_include_directories(znc PUBLIC ${znc_include_dirs}) target_include_directories(znclib PUBLIC ${znc_include_dirs}) From 9de3f908b9f10aac369bbbf7471a9b55a433dc9f Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 7 Jan 2023 22:02:19 +0000 Subject: [PATCH 08/10] Build cctz as part of znclib when not found Because on cygwin otherwise it would be a separate dll --- CMakeLists.txt | 27 ++++++++++++++------------- src/CMakeLists.txt | 3 ++- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef2afacf..5775a847 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -272,23 +272,24 @@ endif() # TODO: verify that this find_package works; on Gentoo it's not currently (Jan # 2023) packaged, so in my tests it always falls back to submodule find_package(cctz QUIET) +set(cctz_cc "") if (NOT cctz_FOUND) set(cctz_cc - third_party/cctz/src/civil_time_detail.cc - third_party/cctz/src/time_zone_fixed.cc - third_party/cctz/src/time_zone_format.cc - third_party/cctz/src/time_zone_if.cc - third_party/cctz/src/time_zone_impl.cc - third_party/cctz/src/time_zone_info.cc - third_party/cctz/src/time_zone_libc.cc - third_party/cctz/src/time_zone_lookup.cc - third_party/cctz/src/time_zone_posix.cc - third_party/cctz/src/zone_info_source.cc + ${PROJECT_SOURCE_DIR}/third_party/cctz/src/civil_time_detail.cc + ${PROJECT_SOURCE_DIR}/third_party/cctz/src/time_zone_fixed.cc + ${PROJECT_SOURCE_DIR}/third_party/cctz/src/time_zone_format.cc + ${PROJECT_SOURCE_DIR}/third_party/cctz/src/time_zone_if.cc + ${PROJECT_SOURCE_DIR}/third_party/cctz/src/time_zone_impl.cc + ${PROJECT_SOURCE_DIR}/third_party/cctz/src/time_zone_info.cc + ${PROJECT_SOURCE_DIR}/third_party/cctz/src/time_zone_libc.cc + ${PROJECT_SOURCE_DIR}/third_party/cctz/src/time_zone_lookup.cc + ${PROJECT_SOURCE_DIR}/third_party/cctz/src/time_zone_posix.cc + ${PROJECT_SOURCE_DIR}/third_party/cctz/src/zone_info_source.cc ) - add_library(cctz STATIC EXCLUDE_FROM_ALL ${cctz_cc}) + add_library(cctz INTERFACE EXCLUDE_FROM_ALL) add_library(cctz::cctz ALIAS cctz) - target_include_directories(cctz PUBLIC - ${PROJECT_SOURCE_DIR}/third_party/cctz/include) + target_include_directories(cctz INTERFACE + $) endif() check_cxx_symbol_exists(getopt_long "getopt.h" HAVE_GETOPT_LONG) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 241a1970..c10767d2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -25,7 +25,8 @@ set(znc_cpp "ZNCString.cpp" "znc.cpp" "IRCNetwork.cpp" "Translation.cpp" "HTTPSock.cpp" "Template.cpp" "ClientCommand.cpp" "Socket.cpp" "SHA256.cpp" "WebModules.cpp" "Listener.cpp" "Config.cpp" "ZNCDebug.cpp" "Threads.cpp" "Query.cpp" "SSLVerifyHost.cpp" "Message.cpp" "User.cpp") -znc_add_library(znclib ${lib_type} ${znc_cpp} "Csocket.cpp" "versionc.cpp") +znc_add_library(znclib ${lib_type} ${znc_cpp} "Csocket.cpp" "versionc.cpp" + ${cctz_cc}) znc_add_executable(znc "main.cpp") target_link_libraries(znc PRIVATE znclib) From 4fc9429d0fa9ac2620058bc4f45689f62c250a36 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 7 Jan 2023 23:30:44 +0000 Subject: [PATCH 09/10] Add test for different timezones --- test/UtilsTest.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/UtilsTest.cpp b/test/UtilsTest.cpp index 264ded48..eb7e0788 100644 --- a/test/UtilsTest.cpp +++ b/test/UtilsTest.cpp @@ -85,6 +85,29 @@ TEST(IRC32, SetMessageTags) { EXPECT_EQ(sLine, R"(@a=\:\s\\\r\n :rest)"); } +TEST(UtilsTest, Timezone) { + char* oldTZ = getenv("TZ"); + if (oldTZ) oldTZ = strdup(oldTZ); + setenv("TZ", "Europe/Berlin", 1); + tzset(); + + EXPECT_EQ(CUtils::FormatTime(1673122230, "%Y-%m-%d %H:%M:%S", "UTC"), "2023-01-07 20:10:30"); + EXPECT_EQ(CUtils::FormatTime(1673122230, "%Y-%m-%d %H:%M:%S", "GMT"), "2023-01-07 20:10:30"); + EXPECT_EQ(CUtils::FormatTime(1673122230, "%Y-%m-%d %H:%M:%S", "GMT+7"), "2023-01-08 03:10:30"); + EXPECT_EQ(CUtils::FormatTime(1673122230, "%Y-%m-%d %H:%M:%S", "GMT-7"), "2023-01-07 13:10:30"); + EXPECT_EQ(CUtils::FormatTime(1673122230, "%Y-%m-%d %H:%M:%S", "Asia/Vladivostok"), "2023-01-08 06:10:30"); + // Local TZ, set to Berlin in this test + EXPECT_EQ(CUtils::FormatTime(1673122230, "%Y-%m-%d %H:%M:%S", ""), "2023-01-07 21:10:30"); + + if (oldTZ) { + setenv("TZ", oldTZ, 1); + free(oldTZ); + } else { + unsetenv("TZ"); + } + tzset(); +} + TEST(UtilsTest, ServerTime) { char* oldTZ = getenv("TZ"); if (oldTZ) oldTZ = strdup(oldTZ); @@ -116,7 +139,6 @@ TEST(UtilsTest, ServerTime) { unsetenv("TZ"); } tzset(); - } TEST(UtilsTest, ParseServerTime) { From 6f199ac030398f688d1f75f7ad8017ef964688d9 Mon Sep 17 00:00:00 2001 From: Alexey Sokolov Date: Sat, 7 Jan 2023 23:39:54 +0000 Subject: [PATCH 10/10] Use patched cctz for now --- .gitmodules | 2 +- third_party/cctz | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index e21f1e3b..d5ceec67 100644 --- a/.gitmodules +++ b/.gitmodules @@ -9,4 +9,4 @@ url = https://github.com/znc/znc-docker [submodule "third_party/cctz"] path = third_party/cctz - url = https://github.com/google/cctz + url = https://github.com/DarthGandalf/cctz diff --git a/third_party/cctz b/third_party/cctz index 790e1abe..cf0cd21f 160000 --- a/third_party/cctz +++ b/third_party/cctz @@ -1 +1 @@ -Subproject commit 790e1abe60136288464e500a2a825b9be031a622 +Subproject commit cf0cd21f719cc86b83c7c4b1e8f85411df6b02c2