summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2013-03-25 14:00:56 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-03-25 14:00:56 -0700
commitf10a012088a7b6e418ec3f726142a8ddfa3d0264 (patch)
tree0c422f8fa659196e9e0cc22ce7756bafa9ad0c13
parentMerge branch 'jk/suppress-clang-warning' (diff)
parentFix time offset calculation in case of unsigned time_t (diff)
downloadtgif-f10a012088a7b6e418ec3f726142a8ddfa3d0264.tar.xz
Merge branch 'mg/unsigned-time-t'
A few workarounds for systems with unsigned time_t. * mg/unsigned-time-t: Fix time offset calculation in case of unsigned time_t date.c: fix unsigned time_t comparison
-rw-r--r--date.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/date.c b/date.c
index 57331ed406..df20d0ba1d 100644
--- a/date.c
+++ b/date.c
@@ -383,7 +383,7 @@ static int is_date(int year, int month, int day, struct tm *now_tm, time_t now,
* sense to specify timestamp way into the future. Make
* sure it is not later than ten days from now...
*/
- if (now + 10*24*3600 < specified)
+ if ((specified != -1) && (now + 10*24*3600 < specified))
return 0;
tm->tm_mon = r->tm_mon;
tm->tm_mday = r->tm_mday;
@@ -694,8 +694,14 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
/* mktime uses local timezone */
*timestamp = tm_to_time_t(&tm);
- if (*offset == -1)
- *offset = ((time_t)*timestamp - mktime(&tm)) / 60;
+ if (*offset == -1) {
+ time_t temp_time = mktime(&tm);
+ if ((time_t)*timestamp > temp_time) {
+ *offset = ((time_t)*timestamp - temp_time) / 60;
+ } else {
+ *offset = -(int)((temp_time - (time_t)*timestamp) / 60);
+ }
+ }
if (*timestamp == -1)
return -1;