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 %}

Hours formatter options

Additional options can be passed to the formatter to change its behavior. Example of passing in options


Available options

  • disable_special_hours (default False) - This option disables using special hours when listing the days' hours. By default, when outputting hours they will be contextual to any special hours coming up for a day. For example, if is Monday and there is special hours for this Thursday, it will adjust the hours listed to show the special hours on Thursday.

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


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>


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

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

Multiple time ranges in a day

Days can also have multiple ranges of time that they are open. For example if the location is closed for lunch but then opens again for dinner.

By default, the value of day.content will have both ranges separated by commas.

9:00 AM - 12:00 PM, 5:00 PM - 9:00 PM

If you want more formatting options, you can also loop over each range within your template using day.ranges.items. If there is no ranges, then the day is closed and day.content is used to display "Closed"

<td>{{ day.label }}</td>
    {% if day.ranges.items %}
        {% for range in day.ranges.items %}
            <span>{{ range.content }}</span>
        {% endfor %}
    {% else %}
        <span>{{ day.content }}</span>
    {% endif %}

Other utilities


This can be used to list upcoming special hours dates and times for a location.

{% for day in hours.special_hours_days() %}
    <td>{{ day.label }}</td>
    <td>{{ day.content }}</td>
{% endfor %}

Example output

    <td>Dec 25</td>
    <td>Jan 1</td>
    <td>8:00 am - 12:00 pm</td>

Additional options

Additional options can be passed into the special_hours_days

  • day_format - Specify the format to be used for each day's label. Default is '%b %-d'. Example of another would be %b %-d, %Y which would output the days as Jan 1, 2022

  • days_in_future - Number of days into the future to get special hours. Default is 30 to show upcoming special hours in the next 30 days.


{{ hours.special_hours_days(day_format='%b %-d, %Y', days_in_future=90) }}


Output the content of todays hours

{{ hours.todays_hours }}


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 %}


Check to see if this location is currently open. This uses the location timezone.

{% if hours.is_open_now(location=location) %}
  <p>Open Now</p>
{% endif %}


Get the next "closing time". Only use this if you know that the location is currently open (using is_open_now).

<p>Closes at: {{ hours.closes_next(location=location) }}</p>

Last updated