##// END OF EJS Templates
parsedate: understand "now" as a shortcut for the current time
Augie Fackler -
r18614:b2586e2c default
parent child Browse files
Show More
@@ -20,6 +20,7 b' Many date formats are valid. Here are so'
20 - ``12/6/6`` (Dec 6 2006)
20 - ``12/6/6`` (Dec 6 2006)
21 - ``today`` (midnight)
21 - ``today`` (midnight)
22 - ``yesterday`` (midnight)
22 - ``yesterday`` (midnight)
23 - ``now`` - right now
23
24
24 Lastly, there is Mercurial's internal format:
25 Lastly, there is Mercurial's internal format:
25
26
@@ -1060,6 +1060,12 b' def parsedate(date, formats=None, bias={'
1060 datetime.timedelta(days=1)\
1060 datetime.timedelta(days=1)\
1061 ).strftime('%b %d'))
1061 ).strftime('%b %d'))
1062 True
1062 True
1063 >>> now, tz = makedate()
1064 >>> strnow, strtz = parsedate('now')
1065 >>> (strnow - now) < 1
1066 True
1067 >>> tz == strtz
1068 True
1063 """
1069 """
1064 if not date:
1070 if not date:
1065 return 0, 0
1071 return 0, 0
@@ -1069,6 +1075,8 b' def parsedate(date, formats=None, bias={'
1069 formats = defaultdateformats
1075 formats = defaultdateformats
1070 date = date.strip()
1076 date = date.strip()
1071
1077
1078 if date == _('now'):
1079 return makedate()
1072 if date == _('today'):
1080 if date == _('today'):
1073 date = datetime.date.today().strftime('%b %d')
1081 date = datetime.date.today().strftime('%b %d')
1074 elif date == _('yesterday'):
1082 elif date == _('yesterday'):
@@ -251,3 +251,8 b" Test issue 3764 (interpreting 'today' an"
251 $ hg ci -d "`sed -n '2p' dates`" -m "the time traveler's code"
251 $ hg ci -d "`sed -n '2p' dates`" -m "the time traveler's code"
252 $ hg log -d yesterday --template '{desc}\n'
252 $ hg log -d yesterday --template '{desc}\n'
253 the time traveler's code
253 the time traveler's code
254 $ echo "foo" >> a
255 $ hg commit -d now -m 'Explicitly committed now.'
256 $ hg log -d today --template '{desc}\n'
257 Explicitly committed now.
258 today is a good day to code
General Comments 0
You need to be logged in to leave comments. Login now