Mercurial > farol > farol
comparison farol/controller.py @ 130:5b47af23547f
Add possibility for parseDate to return None, shouldn't happen since we also do client-side validation.
author | Benoît Allard <benoit.allard@greenbone.net> |
---|---|
date | Fri, 24 Oct 2014 10:52:47 +0200 |
parents | d2588d88d47a |
children |
comparison
equal
deleted
inserted
replaced
129:d2588d88d47a | 130:5b47af23547f |
---|---|
87 date without time. """ | 87 date without time. """ |
88 try: return parseXMLDate(string) | 88 try: return parseXMLDate(string) |
89 except AttributeError: pass | 89 except AttributeError: pass |
90 # Absorb AttributeError, and try to parse it a second time ... | 90 # Absorb AttributeError, and try to parse it a second time ... |
91 m = re.match('(\d{4})-(\d{2})-(\d{2})', string) | 91 m = re.match('(\d{4})-(\d{2})-(\d{2})', string) |
92 if m is None: | |
93 flash('Cannot parse date: "%s"' % string, 'warning') | |
94 return None | |
92 return datetime(int(m.group(1)), int(m.group(2)), int(m.group(3)), | 95 return datetime(int(m.group(1)), int(m.group(2)), int(m.group(3)), |
93 tzinfo=timezone(timedelta(hours=0, minutes=0))) | 96 tzinfo=timezone(timedelta(hours=0, minutes=0))) |
94 | 97 |
95 def parseVersion(string): | 98 def parseVersion(string): |
96 """ An extended version, one that doesn't throw exceptions """ | 99 """ An extended version, one that doesn't throw exceptions """ |