Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tryton/tryton/common/datetime_.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# this repository contains the full copyright notices and license terms.
import datetime
import gettext
import re

from dateutil.parser import parse
from dateutil.relativedelta import relativedelta
Expand Down Expand Up @@ -58,7 +59,10 @@ def date_parse(text, format_='%x'):
monthfirst = False
yearfirst = not dayfirst and not monthfirst
if len(text) == 8 and dayfirst:
return datetime.datetime.strptime(text, '%d%m%Y')
if re.match(r"\d{8}", text):
return datetime.datetime.strptime(text, '%d%m%Y')
elif re.match(r"\d{6}", text):
return datetime.datetime.strptime(text, '%d%m%y')
return parse(text, dayfirst=dayfirst, yearfirst=yearfirst, ignoretz=True)


Expand Down