Hours of operation

Examples of formatting Location hours of operation

Hours formatter

Example of starting the formatter by passing primary hours of a location

{% set hours = location.hours_by_type.primary|hours_formatter %}

Formatting options

Each of the following methods have a few options for outputting the hours

  • hide_closed_days (default False) - this option will exclude days that are closed

  • group_days (default False) - this option will group similar days that have the same hours to save the number of lines needed

as_br

Output hours one per line separated by <br />

<p>{{ hours.as_br() }}</p>
<p>{{ hours.as_br(hide_closed_days=True) }}</p>
<p>{{ hours.as_br(group_days=True) }}</p>

filtered_days

For custom templating options. Below example of outputting the hours into a table.

<table>
{% for day in hours.filtered_days(hide_closed_days=True) %}
<tr>
<td>{{ day.label }}</td>
<td>{{ day.content }}</td>
</tr>
{% endfor %}
</table>

Other utilities

todays_hours

Output the content of todays hours

{{ hours.todays_hours }}

all_days_closed

Check to see if all days within the week are closed. It returns True/False. Can be used to hide a section if there are no open hours and instead show a different message

{% if hours.all_days_closed() %}
<p>This location is closed this week</p>
{% endif %}