Mercurial > hg
changeset 18614:b2586e2cc67a
parsedate: understand "now" as a shortcut for the current time
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sat, 09 Feb 2013 15:39:22 -0600 |
parents | 1a2f4c633410 |
children | e7b89b5127c2 |
files | mercurial/help/dates.txt mercurial/util.py tests/test-parse-date.t |
diffstat | 3 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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:
--- 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'):
--- 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