DevHub Docs
  • Welcome
  • Analytics
    • What events are tracked automatically?
    • Custom events
    • Google Analytics
  • API documentation
  • Domains
    • Registering a new domain
    • Renewing a domain
    • Pointing an existing domain
    • Pointing a subdomain of an existing domain
    • Transfer a domain
      • Transfer a domain to another registrar
    • Validating your domain
      • Validate with Google Webmaster Tools
    • Domain expiration process
  • Email accounts
    • Hosted email (rackspace)
      • Configure email clients to use POP or IMAP
  • Forms
    • Form and field options
    • Using fieldsets
    • Spam filtering
    • Configure SMTP For outbound emails
    • Using Marketo forms
  • Google Sheets
  • Hosting options
    • Embed pages
    • Wordpress plugin for path override
    • Server path override
      • Apache configuration
      • IIS configuration
      • NGINX configuration
    • CDN (content delivery network) support
  • Maps
    • Location finder
    • Map options explained
    • Google Maps API keys
  • Privacy
    • OneTrust integration
    • Cookies
  • Reverse proxy
    • Privacy and security
    • Proxy Configuration
    • Proxy Gating
    • Form lead tracking
    • Blocking and Whitelisting
      • Whitelisting Options
      • Google Ads rejections or disapprovals
      • 3rd Party Services/Widgets
      • Common Security System Restrictions or Domain Errors
  • SEO
    • Schema.org support
    • Sitemap XML
    • Enable No Index
  • Site builder
    • Getting Started
    • Images and video
    • Pages and content
      • Using page drafts
      • Adding Text
      • Adding and Managing Pages
      • Adding Images
      • Page templates and Templated pages
      • Maps
    • Redirects
    • Site Settings
    • Style Options
    • Adding a Business and location
    • Adding a site
    • Adding a user
    • Adding Custom Forms
    • Adding HTML to Sites or Pages
    • Blogs
  • SSL and security
    • SSL Troubleshooting
    • SSL certificate install options
      • Use your own purchased SSL certificate
    • Enable HTTPS for Sites and Proxies
  • Support
    • Creating a Zendesk account
    • Ticketing submission workflow
    • Builder URL and Site ID
  • Themes and custom templates
    • Getting started
    • Using macros
    • Using custom fields
    • Using URL parameters
    • Hours of operation
    • Using date and time in templates
    • Template variables
    • Site Builder Markup
      • Avoiding Site Builder CSS and HTML duplication
    • Example themes
      • Location focused page with bootstrap
      • Store locator theme example
    • Advanced Examples
      • Theme module templates
      • Static Google maps
      • Content translations
      • Page navigation
      • Override page title and meta tags
      • Adding line breaks to content
      • Get objects
      • Handling boolean values
      • Right to left languages
      • Access current URL
      • Social sharing links
      • Standard filters
      • Serializing data to JSON
      • Form events
      • Schema.org FAQ utility
  • Trace technology
    • What is Trace?
    • Configuration options
  • Data Sources
    • External Contexts
Powered by GitBook
On this page
  • Hours formatter
  • Hours formatter options
  • Formatting options
  • as_br
  • filtered_days
  • Other utilities
  • special_hours_days
  • todays_hours
  • Finder Support for todays_hours
  • all_days_closed
  • is_open_now
  • closes_next

Was this helpful?

  1. Themes and custom templates

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

|hours_formatter(disable_special_hours=True)

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

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>

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>
<td>
    {% if day.ranges.items %}
        {% for range in day.ranges.items %}
            <span>{{ range.content }}</span>
        {% endfor %}
    {% else %}
        <span>{{ day.content }}</span>
    {% endif %}
</td>

Other utilities

special_hours_days

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

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

Example output

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

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.

Example

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

todays_hours

Output the content of todays hours

{{ hours.todays_hours }}

Finder Support for todays_hours

<p>{{location.todays_hours_of_operation}}</p>

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

is_open_now

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

closes_next

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>

PreviousUsing URL parametersNextUsing date and time in templates

Last updated 9 months ago

Was this helpful?