Replace day and month by 1 in date_trunk for SQLite

The value 0 is not valid for day and month.

issue7263
review45311002
This commit is contained in:
Cédric Krier
2018-03-27 22:14:01 +02:00
parent bfb76a70ad
commit df4e5f0cb0
+8 -3
View File
@@ -91,11 +91,16 @@ def date_trunc(_type, date):
break
else:
return None
for attribute in [
'microsecond', 'second', 'minute', 'hour', 'day', 'month', 'year']:
for attribute, replace in [
('microsecond', 0),
('second', 0),
('minute', 0),
('hour', 0),
('day', 1),
('month', 1)]:
if _type.startswith(attribute):
break
value = value.replace(**{attribute: 0})
value = value.replace(**{attribute: replace})
return str(value)