Skip to content

Schedules and PartialSchedules

Sometimes, a SessionSeries can include information about when it generally occurs (e.g. “it generally occurs on Mondays at 12:30pm and lasts 90 minutes”). These are Schedules or PartialSchedules and can be found in the eventSchedule array of a SessionSeries. Here’s what that would look like for the above example rule:

"eventSchedule": [
{
"type": "PartialSchedule",
"byDay": [
"schema:Monday"
],
"duration": "PT1H30M",
"startTime": "12:30",
"endTime": "14:00",
"startDate": "2020-06-22",
"endDate": "2021-06-01",
"repeatFrequency": "P7D",
"scheduleTimezone": "Europe/London"
}
],

This information can then be displayed on a website or mobile app to give the user a general idea of the session’s schedule. This might look like this:

An EventSeries can contain the following data:

  • Only a ScheduledSession;
  • Both a ScheduledSession and PartialSchedule / Schedule; or
  • Only a PartialSchedule (lease common).

PartialSchedule vs Schedule

The items in a SessionSeries’ eventSchedule array can be either PartialSchedules or Schedules. For front-ends, the difference isn’t important but it may interest you regardless.

  • Schedule: has a lot of date/time information - OpenActive dictates that Schedules must have certain fields (see required properties). Internally, imin generates ScheduledSessions from Schedules where they exist as well as exceptions and amendments, which come from other sources.
  • PartialSchedule: has less date/time information - OpenActive only mandates for the inclusion of @type (see the required property). For example, they may be missing an endDate. Internally, imin does not generate ScheduledSessions from PartialSchedules and instead gathers them from other sources.

Timezones

Because a Schedule / PartialSchedule can occur over timezone boundaries (e.g. it may occur on the week before clocks go forward and the week after), it cannot have a single timezone designator (e.g. 12:00Z would refer to 12:00 before clocks go forward and 13:00 after).

This is why the scheduleTimezone field is included, which specifies the IANA time zone. When not included, please assume that this field is set to Europe/London.

To render the correct time in JavaScript, you can use Moment Timezone. For example:

> const moment = require('moment-timezone');
> const schedule = { /** with the PartialSchedule defined above */ }
> const datetime = moment.tz(
`${schedule.startDate} ${schedule.startTime}`,
'YYYY-MM-DD HH:mm',
schedule.scheduleTimezone || 'Europe/London');
// Render the time using the appropriate timezone designator
> datetime.format();
'2019-07-01T12:00:00+01:00'
// You can also convert it to UTC if you wish
> moment(datetime).utc().format();
'2019-07-01T11:00:00Z'