create tz-aware datetimes when all we have is dates

This commit is contained in:
Frédéric Péters 2020-02-26 19:47:21 +01:00
parent 07e6d28cfc
commit 545ad896e2
1 changed files with 2 additions and 2 deletions

View File

@ -238,14 +238,14 @@ def get_slots_from_mairie_format(data, base_datetime):
def parse_valid_from(spec):
valid_from = parse_datetime(spec.get('validFrom')) or parse_date(spec.get('validFrom'))
if not isinstance(valid_from, datetime.datetime):
valid_from = datetime.datetime(valid_from.year, valid_from.month, valid_from.day)
valid_from = make_aware(datetime.datetime(valid_from.year, valid_from.month, valid_from.day))
return valid_from
def parse_valid_through(spec):
valid_through = parse_datetime(spec.get('validThrough')) or parse_date(spec.get('validThrough'))
if not isinstance(valid_through, datetime.datetime):
valid_through = datetime.datetime(valid_through.year, valid_through.month, valid_through.day, 23, 59)
valid_through = make_aware(datetime.datetime(valid_through.year, valid_through.month, valid_through.day, 23, 59))
return valid_through