Skip to content

Commit 604e867

Browse files
committed
Fix parse_time(): it is possible TZ may be zero
1 parent a98bc4e commit 604e867

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/utils/pgut.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,7 @@ parse_time(const char *value, time_t *result)
752752
int fields_num,
753753
tz = 0,
754754
i;
755+
bool tz_set = false;
755756
char *tmp;
756757
struct tm tm;
757758
char junk[2];
@@ -824,6 +825,8 @@ parse_time(const char *value, time_t *result)
824825
if (*value == '-')
825826
tz = -tz;
826827

828+
tz_set = true;
829+
827830
fields_num++;
828831
value = cp;
829832
}
@@ -865,7 +868,7 @@ parse_time(const char *value, time_t *result)
865868
*result = mktime(&tm);
866869

867870
/* adjust time zone */
868-
if (tz != 0)
871+
if (tz_set)
869872
{
870873
time_t ltime = time(NULL);
871874
struct tm *ptm = gmtime(&ltime);

0 commit comments

Comments
 (0)