summaryrefslogtreecommitdiff
path: root/t/t0006-date.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-11-02 05:23:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-02 11:49:53 (GMT)
commitc27cc94fad36ba46fea4a031d6df9d45b931f421 (patch)
tree3bebc46198a1579b1136470e081ff35f3ae95f2b /t/t0006-date.sh
parentb4cfcde4db8f5787c6c8a3912b0f2667becd1995 (diff)
downloadgit-c27cc94fad36ba46fea4a031d6df9d45b931f421.zip
git-c27cc94fad36ba46fea4a031d6df9d45b931f421.tar.gz
git-c27cc94fad36ba46fea4a031d6df9d45b931f421.tar.bz2
approxidate: handle pending number for "specials"
The approxidate parser has a table of special keywords like "yesterday", "noon", "pm", etc. Some of these, like "pm", do the right thing if we've recently seen a number: "3pm" is what you'd think. However, most of them do not look at or modify the pending-number flag at all, which means a number may "jump" across a significant keyword and be used unexpectedly. For example, when parsing: January 5th noon pm we'd connect the "5" to "pm", and ignore it as a day-of-month. This is obviously a bit silly, as "noon" already implies "pm". And other mis-parsed things are generally as silly ("January 5th noon, years ago" would connect the 5 to "years", but probably nobody would type that). However, the fix is simple: when we see a keyword like "noon", we should flush the pending number (as we would if we hit another number, or the end of the string). In a few of the specials that actually modify the day, we can simply throw away the number (saying "Jan 5 yesterday" should not respect the number at all). Note that we have to either move or forward-declare the static pending_number() to make it accessible to these functions; this patch moves it. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0006-date.sh')
-rwxr-xr-xt/t0006-date.sh1
1 files changed, 1 insertions, 0 deletions
diff --git a/t/t0006-date.sh b/t/t0006-date.sh
index 64ff86d..b7ea5fb 100755
--- a/t/t0006-date.sh
+++ b/t/t0006-date.sh
@@ -113,6 +113,7 @@ 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'
+check_approxidate 'January 5th noon pm' '2009-01-05 12:00:00'
check_approxidate 'last tuesday' '2009-08-25 19:20:00'
check_approxidate 'July 5th' '2009-07-05 19:20:00'