templatetags: deduce period and all_day_hours directely from data (#48919)
This commit is contained in:
parent
d75a455f4d
commit
ff52f172e8
|
@ -138,7 +138,7 @@ def openinghours_to_datetime(codename, hour, minute):
|
|||
return None
|
||||
|
||||
|
||||
def get_period_from_data(weekday, time_table):
|
||||
def get_period_from_data(time_table):
|
||||
"""Return am or pm and all_day_hours from opening_time and closing_time
|
||||
"""
|
||||
start_hour = int(time_table['start_hour'])
|
||||
|
@ -146,8 +146,8 @@ def get_period_from_data(weekday, time_table):
|
|||
end_hour = int(time_table['end_hour'])
|
||||
end_minute = int(time_table['end_minute'])
|
||||
|
||||
closing_time = openinghours_to_datetime(weekday, end_hour, end_minute)
|
||||
opening_time = openinghours_to_datetime(weekday, start_hour, start_minute)
|
||||
closing_time = datetime.time(hour=end_hour, minute=end_minute)
|
||||
opening_time = datetime.time(hour=start_hour, minute=start_minute)
|
||||
|
||||
all_day_hours = False
|
||||
if (opening_time < closing_time # closing_time may last on the night
|
||||
|
@ -330,7 +330,7 @@ def get_mairie_opening_hours(mairie_data):
|
|||
} for i in range(7)]))
|
||||
|
||||
def update_opening_hours(weekday, time_table):
|
||||
period, all_day_hours = get_period_from_data(weekday, time_table)
|
||||
period, all_day_hours = get_period_from_data(time_table)
|
||||
if all_day_hours and period == 'am':
|
||||
opening_hours_dict[weekday]['pm'] = '' # empty string to avoid displaying fermé
|
||||
opening_hours_dict[weekday][period] = "%sh%s-%sh%s" % (
|
||||
|
|
Loading…
Reference in New Issue