misc: display known format but no opening hours as all closed (#40054)
This commit is contained in:
parent
c6448b72ab
commit
6659113395
|
@ -279,6 +279,7 @@ def get_mairie_opening_hours(mairie_data):
|
||||||
previous_week = base_datetime - datetime.timedelta(7)
|
previous_week = base_datetime - datetime.timedelta(7)
|
||||||
next_week = base_datetime + datetime.timedelta(7)
|
next_week = base_datetime + datetime.timedelta(7)
|
||||||
for specification in mairie_data.get('openinghoursspecification', []):
|
for specification in mairie_data.get('openinghoursspecification', []):
|
||||||
|
known_format = True
|
||||||
valid_from, valid_through = previous_week, next_week
|
valid_from, valid_through = previous_week, next_week
|
||||||
if specification.get('validFrom'):
|
if specification.get('validFrom'):
|
||||||
valid_from = parse_valid_from(specification)
|
valid_from = parse_valid_from(specification)
|
||||||
|
@ -304,8 +305,12 @@ def get_mairie_opening_hours(mairie_data):
|
||||||
|
|
||||||
if not (any([x['am'] for x in opening_hours_dict.values()]) or
|
if not (any([x['am'] for x in opening_hours_dict.values()]) or
|
||||||
any([x['pm'] for x in opening_hours_dict.values()])):
|
any([x['pm'] for x in opening_hours_dict.values()])):
|
||||||
# always closed, return None to mark unavailability
|
# always closed, returns None if the format is unknown so it can be
|
||||||
return None
|
# displayed as "unavailable".
|
||||||
|
if not known_format:
|
||||||
|
return None
|
||||||
|
# otherwise returns an array of closed days
|
||||||
|
return [(weekday, {'am': None, 'pm': ''}) for weekday in FR_WEEKDAYS]
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(FR_ABBREV_WEEKDAYS_LIST[weekday], hours) for weekday, hours in opening_hours_dict.items()
|
(FR_ABBREV_WEEKDAYS_LIST[weekday], hours) for weekday, hours in opening_hours_dict.items()
|
||||||
|
|
Loading…
Reference in New Issue