# HG changeset patch # User Chris Mason # Date 1152808801 25200 # Node ID 6c5b1b5cc1605d70b5e7f27ac9b5c45fa5121837 # Parent ed344f948bd4e49de2582db7c646a0215acb8d4d util.parsedate should understand dates from hg export diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -15,6 +15,10 @@ from demandload import * 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 @@ def strdate(string, format='%a %b %d %H: 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: