Merge branch 'jc/daemon-no-ipv6-for-2.4.1' into maint
[gitweb.git] / date.c
diff --git a/date.c b/date.c
index 3eba2dfe8841cee28850e2f1f4177e1e32f1c8a8..733d1b29b19fc7dda04d599eb6a311e809212775 100644 (file)
--- 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 */