summaryrefslogtreecommitdiff
path: root/date.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-05-05 21:00:33 -0700
committerJunio C Hamano <gitster@pobox.com>2015-05-05 21:00:33 -0700
commit39a5d50d62780e2f838e5fa8196c06fba2baa956 (patch)
tree400746e314a752dde0cabc4021a3f27064d33acc /date.c
parentef8163ce57a59b4f494b02d01b3929b5c4488f5e (diff)
parentf6e6362107a1e7a798dc1c28ef439a3157813467 (diff)
downloadgit-39a5d50d62780e2f838e5fa8196c06fba2baa956.tar.gz
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
Diffstat (limited to 'date.c')
-rw-r--r--date.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/date.c b/date.c
index 3eba2dfe88..733d1b29b1 100644
--- a/date.c
+++ b/date.c
@@ -704,10 +704,17 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
date += match;
}
- /* mktime uses local timezone */
+ /* do not use mktime(), which uses local timezone, here */
*timestamp = tm_to_time_t(&tm);
+ if (*timestamp == -1)
+ return -1;
+
if (*offset == -1) {
- time_t temp_time = mktime(&tm);
+ time_t temp_time;
+
+ /* gmtime_r() in match_digit() may have clobbered it */
+ tm.tm_isdst = -1;
+ temp_time = mktime(&tm);
if ((time_t)*timestamp > temp_time) {
*offset = ((time_t)*timestamp - temp_time) / 60;
} else {
@@ -715,9 +722,6 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
}
}
- if (*timestamp == -1)
- return -1;
-
if (!tm_gmt)
*timestamp -= *offset * 60;
return 0; /* success */