Skip to content

Commit c8ea19f

Browse files
avoid ly_tzset_once in ly_time_time2str
It does not seem necessary to call ly_tzset_once() from ly_time_time2str(). If the user changes TZ env variable, they must explicitly call tzset() as well.
1 parent 3fea1af commit c8ea19f

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

src/tree_data_common.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,30 +1620,12 @@ ly_time_tz_offset(void)
16201620
return ly_time_tz_offset_at(time(NULL));
16211621
}
16221622

1623-
/**
1624-
* @brief Call tzset() if not already called by this process.
1625-
*/
1626-
static void
1627-
ly_tzset_once(void)
1628-
{
1629-
static int ly_tzset_called = 0;
1630-
1631-
if (ly_tzset_called) {
1632-
return;
1633-
}
1634-
tzset();
1635-
ly_tzset_called = 1;
1636-
}
1637-
16381623
LIBYANG_API_DEF int
16391624
ly_time_tz_offset_at(time_t time)
16401625
{
16411626
struct tm tm_local, tm_utc;
16421627
int result = 0;
16431628

1644-
/* init timezone */
1645-
ly_tzset_once();
1646-
16471629
/* get local and UTC time */
16481630
localtime_r(&time, &tm_local);
16491631
gmtime_r(&time, &tm_utc);
@@ -1791,9 +1773,6 @@ ly_time_time2str(time_t time, const char *fractions_s, char **str)
17911773

17921774
LY_CHECK_ARG_RET(NULL, str, LY_EINVAL);
17931775

1794-
/* init timezone */
1795-
ly_tzset_once();
1796-
17971776
/* convert */
17981777
if (!localtime_r(&time, &tm)) {
17991778
return LY_ESYS;

0 commit comments

Comments
 (0)