timestamp_t: a new data type for timestamps
[gitweb.git] / archive-zip.c
index b429a8d974a02b06c9c6bc46850f4c9fae4a6d01..68df3d6440270c3049349548fd4ce7a2d2518039 100644 (file)
@@ -545,9 +545,17 @@ static void write_zip_trailer(const unsigned char *sha1)
                write_or_die(1, sha1_to_hex(sha1), GIT_SHA1_HEXSZ);
 }
 
-static void dos_time(time_t *time, int *dos_date, int *dos_time)
+static void dos_time(timestamp_t *timestamp, int *dos_date, int *dos_time)
 {
-       struct tm *t = localtime(time);
+       time_t time;
+       struct tm *t;
+
+       if (date_overflows(*timestamp))
+               die("timestamp too large for this system: %"PRItime,
+                   *timestamp);
+       time = (time_t)*timestamp;
+       t = localtime(&time);
+       *timestamp = time;
 
        *dos_date = t->tm_mday + (t->tm_mon + 1) * 32 +
                    (t->tm_year + 1900 - 1980) * 512;