@@ -1121,12 +1121,14 @@ static void pending_number(struct tm *tm, int *num)
static void date_now(struct tm *tm, struct tm *now, int *num)
{
*num = 0;
+ tm->tm_mday = -1;
update_tm(tm, now, 0);
}
static void date_yesterday(struct tm *tm, struct tm *now, int *num)
{
*num = 0;
+ tm->tm_mday = -1;
update_tm(tm, now, 24*60*60);
}
@@ -1204,6 +1206,7 @@ static const struct special {
{ "AM", date_am },
{ "never", date_never },
{ "now", date_now },
+ { "today", date_now },
{ NULL }
};
@@ -178,10 +178,10 @@ check_approxidate '6am yesterday' '2009-08-29 06:00:00'
check_approxidate '6pm yesterday' '2009-08-29 18:00:00'
check_approxidate '3:00' '2009-08-30 03:00:00'
check_approxidate '15:00' '2009-08-30 15:00:00'
-check_approxidate 'noon today' '2009-08-30 12:00:00'
-check_approxidate 'noon yesterday' '2009-08-29 12:00:00'
(
GIT_TEST_DATE_NOW=$(($GIT_TEST_DATE_NOW-12*60*60)); export GIT_TEST_DATE_NOW
+ check_approxidate 'noon today' '2009-08-30 12:00:00'
+ check_approxidate 'noon yesterday' '2009-08-29 12:00:00'
check_approxidate 'January 5th noon pm' '2009-01-05 12:00:00'
)
check_approxidate '10am noon' '2009-08-29 12:00:00'
Date specifications now (or today) and yesterday should refer to actual current or previous day. Especially "noon today" or "noon yesterday" should override the usual logic of using the first previous noon depending on the current time. Signed-off-by: Tuomas Ahola <taahol@utu.fi> --- date.c | 3 +++ t/t0006-date.sh | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)