Import: Parse iso dates

This commit is contained in:
Raphael Michel
2024-09-12 09:28:19 +02:00
parent eebdce80cd
commit 24e2b1b9ab
2 changed files with 8 additions and 2 deletions

View File

@@ -213,7 +213,13 @@ class DatetimeColumnMixin:
except (ValueError, TypeError):
pass
else:
raise ValidationError(_("Could not parse {value} as a date and time.").format(value=value))
try:
d = datetime.datetime.fromisoformat(value)
if not d.tzinfo:
d = d.replace(tzinfo=self.timezone)
return d
except (ValueError, TypeError):
raise ValidationError(_("Could not parse {value} as a date and time.").format(value=value))
class DecimalColumnMixin:

View File

@@ -66,7 +66,7 @@ def inputfile_factory(multiplier=1):
'A': 'GHIJK432',
'B': 'Ticket',
'C': 'False',
'D': '2021-05-28 11:00:00',
'D': '2021-05-28T11:00:00+00:00',
'E': '2',
'F': '1',
},