Skip to content

Commit 667f2dc

Browse files
committedDec 3, 2020
use tzset on Windows
1 parent 3543dae commit 667f2dc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
 

‎src/utils/configuration.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,8 +1228,13 @@ parse_time(const char *value, time_t *result, bool utc_default)
12281228
* treat it as UTC if requested, otherwise as local timezone
12291229
*/
12301230
if (tz_set || utc_default)
1231+
{
12311232
/* set timezone to UTC */
12321233
pgut_setenv("TZ", "UTC");
1234+
#ifdef WIN32
1235+
tzset();
1236+
#endif
1237+
}
12331238

12341239
/* convert time to utc unix time */
12351240
*result = mktime(&tm);
@@ -1240,6 +1245,10 @@ parse_time(const char *value, time_t *result, bool utc_default)
12401245
else
12411246
pgut_unsetenv("TZ");
12421247

1248+
#ifdef WIN32
1249+
tzset();
1250+
#endif
1251+
12431252
/* adjust time zone */
12441253
if (tz_set || utc_default)
12451254
{
@@ -1480,7 +1489,12 @@ time2iso(char *buf, size_t len, time_t time, bool utc)
14801489

14811490
/* set timezone to UTC if requested */
14821491
if (utc)
1492+
{
14831493
pgut_setenv("TZ", "UTC");
1494+
#ifdef WIN32
1495+
tzset();
1496+
#endif
1497+
}
14841498

14851499
ptm = gmtime(&time);
14861500
gmt = mktime(ptm);
@@ -1493,6 +1507,9 @@ time2iso(char *buf, size_t len, time_t time, bool utc)
14931507
pgut_setenv("TZ", local_tz);
14941508
else
14951509
pgut_unsetenv("TZ");
1510+
#ifdef WIN32
1511+
tzset();
1512+
#endif
14961513
}
14971514

14981515
/* adjust timezone offset */

0 commit comments

Comments
 (0)
Please sign in to comment.