let date field instance accept data without seconds or totally without time part
git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@3599 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
9caf7ab727
commit
12c6855630
1 changed files with 7 additions and 1 deletions
|
@ -236,7 +236,13 @@ class DateFieldInstance(NumberFieldInstance):
|
||||||
value[1] = 'T00:00:00'
|
value[1] = 'T00:00:00'
|
||||||
value = ''.join(value)
|
value = ''.join(value)
|
||||||
if value:
|
if value:
|
||||||
return datetime(*(strptime(value, '%Y-%m-%dT%H:%M:%S')[:6]))
|
try:
|
||||||
|
return datetime(*(strptime(value, '%Y-%m-%dT%H:%M:%S')[:6]))
|
||||||
|
except ValueError:
|
||||||
|
try:
|
||||||
|
return datetime(*(strptime(value, '%Y-%m-%dT%H:%M')[:6]))
|
||||||
|
except ValueError:
|
||||||
|
return datetime(*(strptime(value, '%Y-%m-%d')[:6]))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def validate(self, value, data=None):
|
def validate(self, value, data=None):
|
||||||
|
|
Loading…
Add table
Reference in a new issue