Skip to content

Commit 39a5d50

Browse files
committed
Merge branch 'jc/epochtime-wo-tz'
"git commit --date=now" or anything that relies on approxidate lost the daylight-saving-time offset. * jc/epochtime-wo-tz: parse_date_basic(): let the system handle DST conversion parse_date_basic(): return early when given a bogus timestamp
2 parents ef8163c + f6e6362 commit 39a5d50

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

date.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,20 +704,24 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
704704
date += match;
705705
}
706706

707-
/* mktime uses local timezone */
707+
/* do not use mktime(), which uses local timezone, here */
708708
*timestamp = tm_to_time_t(&tm);
709+
if (*timestamp == -1)
710+
return -1;
711+
709712
if (*offset == -1) {
710-
time_t temp_time = mktime(&tm);
713+
time_t temp_time;
714+
715+
/* gmtime_r() in match_digit() may have clobbered it */
716+
tm.tm_isdst = -1;
717+
temp_time = mktime(&tm);
711718
if ((time_t)*timestamp > temp_time) {
712719
*offset = ((time_t)*timestamp - temp_time) / 60;
713720
} else {
714721
*offset = -(int)((temp_time - (time_t)*timestamp) / 60);
715722
}
716723
}
717724

718-
if (*timestamp == -1)
719-
return -1;
720-
721725
if (!tm_gmt)
722726
*timestamp -= *offset * 60;
723727
return 0; /* success */

0 commit comments

Comments
 (0)