# HG changeset patch # User Chris Mason # Date 1152808801 25200 # Node ID 6c5b1b5cc1605d70b5e7f27ac9b5c45fa5121837 # Parent ed344f948bd4e49de2582db7c646a0215acb8d4d util.parsedate should understand dates from hg export diff -r ed344f948bd4 -r 6c5b1b5cc160 mercurial/util.py --- 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: