Mercurial > hg
changeset 2609:6c5b1b5cc160
util.parsedate should understand dates from hg export
author | Chris Mason <mason@suse.com> |
---|---|
date | Thu, 13 Jul 2006 09:40:01 -0700 |
parents | ed344f948bd4 |
children | 7a87aebd848e |
files | mercurial/util.py |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Wed Jul 12 15:47:12 2006 -0700 +++ b/mercurial/util.py Thu Jul 13 09:40:01 2006 -0700 @@ -15,6 +15,10 @@ demandload(globals(), "cStringIO errno popen2 re shutil sys tempfile") demandload(globals(), "os threading time") +# used by parsedate +defaultdateformats = ('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M', + '%a %b %d %H:%M:%S %Y') + class SignalInterrupt(Exception): """Exception raised on SIGTERM and SIGHUP.""" @@ -883,10 +887,12 @@ when = int(time.mktime(time.strptime(date, format))) + offset return when, offset -def parsedate(string, formats=('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M')): +def parsedate(string, formats=None): """parse a localized time string and return a (unixtime, offset) tuple. The date may be a "unixtime offset" string or in one of the specified formats.""" + if not formats: + formats = defaultdateformats try: when, offset = map(int, string.split(' ')) except ValueError: