This document is for an older version of

Calendar

.

View latest version →

Templating

Hour object

An Hour object holds in itself a list of all Events that fall into this hour.

Properties

  • date #
    • A Date object of the starting date of the event duration
    • For an Hour object of April 15, 2016 at 5pm, this would return the Date object of 2016-04-15 17:00:00
  • startDate #
    • Basically the same as the date property
  • endDate #
    • The ending date of the Hour object's hour, e.g - 2016-04-15 17:59:59 in this case
  • previousDate #
    • Returns a Date object of the previous hour relative to the date property, e.g. 2016-04-15 16:00:00 in this case
  • nextDate #
    • Returns a Date object of the next hour relative to the date property, e.g. 2016-05-15 18:00:00 in this case
  • events #
    • Contains a list of Events that fall into this Hour object's range
  • eventCount #
    • The number of events in the events property

Methods

  • dateRange(int before, int after) #
    • Returns a list of Date objects ranging before number of hours before date and after number of hours after date
    • E.g. hour.dateRange(6, 6) would return a list starting from 2016-04-15 11:00:00 and ending in 2016-04-15 23:00:00 assuming the Day object's date is 2016-04-15 17:00:00
  • containsDate(dateObject) #
    • Returns true if the dateObject provided is within the Hour object's date range
    • E.g. hour.containsDate(event.startDate) would return true if the Hour object would be April 15, 2016 at 5pm, and the event.startDate would be 2016-04-15 17:30:00, but false if the event.startDate would be 2016-04-16 18:00:00

Usage in Templates

Iterate through all events within the current hour

{% set hour = craft.calendar.day({
  date: "now",
  calendar: ["holidays", "sports"]
}) %}

{% for event in hour.events %}
  <div style="{{ event.calendar.color }};">
    {{ event.title }}
  </div>
{% endfor %}
1
2
3
4
5
6
7
8
9
10