diff --git a/src/tree_data_common.c b/src/tree_data_common.c index d97f643ea..6363e98cc 100644 --- a/src/tree_data_common.c +++ b/src/tree_data_common.c @@ -1620,30 +1620,12 @@ ly_time_tz_offset(void) return ly_time_tz_offset_at(time(NULL)); } -/** - * @brief Call tzset() if not already called by this process. - */ -static void -ly_tzset_once(void) -{ - static int ly_tzset_called = 0; - - if (ly_tzset_called) { - return; - } - tzset(); - ly_tzset_called = 1; -} - LIBYANG_API_DEF int ly_time_tz_offset_at(time_t time) { struct tm tm_local, tm_utc; int result = 0; - /* init timezone */ - ly_tzset_once(); - /* get local and UTC time */ localtime_r(&time, &tm_local); gmtime_r(&time, &tm_utc); @@ -1791,9 +1773,6 @@ ly_time_time2str(time_t time, const char *fractions_s, char **str) LY_CHECK_ARG_RET(NULL, str, LY_EINVAL); - /* init timezone */ - ly_tzset_once(); - /* convert */ if (!localtime_r(&time, &tm)) { return LY_ESYS; diff --git a/tests/utests/utests.h b/tests/utests/utests.h index b1f72cc42..a81a34d8b 100644 --- a/tests/utests/utests.h +++ b/tests/utests/utests.h @@ -1326,6 +1326,8 @@ utest_setup(void **state) /* set CET */ setenv("TZ", "CET+02:00", 1); + /* call tzset explicitly, to update the tzname, timezone and daylight global variables */ + tzset(); return 0; }