summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 34dc6e7)
raw | patch | inline | side by side (parent: 34dc6e7)
author | Jeff King <peff@peff.net> | |
Mon, 31 Aug 2009 02:31:42 +0000 (22:31 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 31 Aug 2009 05:04:56 +0000 (22:04 -0700) |
These were broken by b5373e9. The problem is that the code
marks the month and year with "-1" for "we don't know it
yet", but the month and year code paths were not adjusted to
fill in the current time before doing their calculations
(whereas other units follow a different code path and are
fine).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
marks the month and year with "-1" for "we don't know it
yet", but the month and year code paths were not adjusted to
fill in the current time before doing their calculations
(whereas other units follow a different code path and are
fine).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
date.c | patch | blob | history | |
t/t0006-date.sh | patch | blob | history |
index 8e57e5eb82450a448ea8096cf4a87810b58226c3..e9ee4aa7484c531fab8e6d24fbdabdc640378e28 100644 (file)
--- a/date.c
+++ b/date.c
}
if (match_string(date, "months") >= 5) {
- int n = tm->tm_mon - *num;
+ int n;
+ update_tm(tm, now, 0); /* fill in date fields if needed */
+ n = tm->tm_mon - *num;
*num = 0;
while (n < 0) {
n += 12;
}
if (match_string(date, "years") >= 4) {
+ update_tm(tm, now, 0); /* fill in date fields if needed */
tm->tm_year -= *num;
*num = 0;
return end;
diff --git a/t/t0006-date.sh b/t/t0006-date.sh
index 02cd5659f72f161a5a75b25eb3282922bac74421..a4d8fa8fa1c8b3c16aeeed49a3f4c52971f92518 100755 (executable)
--- a/t/t0006-date.sh
+++ b/t/t0006-date.sh
check_approxidate yesterday '2009-08-29 19:20:00'
check_approxidate 3.days.ago '2009-08-27 19:20:00'
check_approxidate 3.weeks.ago '2009-08-09 19:20:00'
-check_approxidate 3.months.ago '2009-05-30 19:20:00' failure
-check_approxidate 2.years.3.months.ago '2007-05-30 19:20:00' failure
+check_approxidate 3.months.ago '2009-05-30 19:20:00'
+check_approxidate 2.years.3.months.ago '2007-05-30 19:20:00'
check_approxidate '6am yesterday' '2009-08-29 06:00:00'
check_approxidate '6pm yesterday' '2009-08-29 18:00:00'