# HG changeset patch # User Augie Fackler # Date 1360445962 21600 # Node ID b2586e2cc67ad7d446cdf8a78baccd34d5fa195f # Parent 1a2f4c633410f6bc49b94c65d74939165bbc2dd7 parsedate: understand "now" as a shortcut for the current time diff -r 1a2f4c633410 -r b2586e2cc67a mercurial/help/dates.txt --- a/mercurial/help/dates.txt Sat Feb 09 15:38:57 2013 -0600 +++ b/mercurial/help/dates.txt Sat Feb 09 15:39:22 2013 -0600 @@ -20,6 +20,7 @@ - ``12/6/6`` (Dec 6 2006) - ``today`` (midnight) - ``yesterday`` (midnight) +- ``now`` - right now Lastly, there is Mercurial's internal format: diff -r 1a2f4c633410 -r b2586e2cc67a mercurial/util.py --- a/mercurial/util.py Sat Feb 09 15:38:57 2013 -0600 +++ b/mercurial/util.py Sat Feb 09 15:39:22 2013 -0600 @@ -1060,6 +1060,12 @@ datetime.timedelta(days=1)\ ).strftime('%b %d')) True + >>> now, tz = makedate() + >>> strnow, strtz = parsedate('now') + >>> (strnow - now) < 1 + True + >>> tz == strtz + True """ if not date: return 0, 0 @@ -1069,6 +1075,8 @@ formats = defaultdateformats date = date.strip() + if date == _('now'): + return makedate() if date == _('today'): date = datetime.date.today().strftime('%b %d') elif date == _('yesterday'): diff -r 1a2f4c633410 -r b2586e2cc67a tests/test-parse-date.t --- a/tests/test-parse-date.t Sat Feb 09 15:38:57 2013 -0600 +++ b/tests/test-parse-date.t Sat Feb 09 15:39:22 2013 -0600 @@ -251,3 +251,8 @@ $ hg ci -d "`sed -n '2p' dates`" -m "the time traveler's code" $ hg log -d yesterday --template '{desc}\n' the time traveler's code + $ echo "foo" >> a + $ hg commit -d now -m 'Explicitly committed now.' + $ hg log -d today --template '{desc}\n' + Explicitly committed now. + today is a good day to code