Can generate a series of time slots based on certain settings such as slot duration and interval.

Methods

Description

Generates a series of time slots based on the request context.

Signature

global static B25.TimeSlotGenerator.Result getTimeSlots(B25.TimeSlotGenerator.Context)

Parameters

B25.TimeSlotGenerator.Context

Contains the settings for the series to be generated.

Return Type

B25.TimeSlotGenerator.Result

Contains a List<B25.TimeSlot> timeSlots property with the generated time slots.

Inner Classes

Description

Contains the settings for the series to be generated.

Properties

Datetime startOfRange;

The start time of the series to be generated.

Datetime endOfRange;

The end time of the series to be generated.

Integer duration;

The duration of each time slot, in minutes.

Integer interval;

Amount of minutes between the start times of each slot. Allows you to have overlap if the interval is lower than the duration. For example, a duration of 60 with an interval of 15 would result in time slots from 9:00-10:00, 9:15-10:15, 9:30-10:30, etc.

Description

Contains the resulting time slots.

Properties

List<B25.TimeSlot> timeSlots

The resulting time slots. Each time slot has a startDateTime and endDateTime.

Example

This example shows how you can use the class in your own code.

B25.TimeSlotGenerator.Context context = new B25.TimeSlotGenerator.Context();
context.startOfRange = System.now();
context.endOfRange = System.now().addDays(7);
context.duration = 60;
context.interval = 15;

// call the method and do something with the result
B25.TimeSlotGenerator.Result result = B25.TimeSlotGenerator.getTimeSlots(context);
for (B25.TimeSlot timeSlot : result.timeSlots) {
    System.debug('time slot from ' + timeSlot.startDatetime
        + ' until ' + timeSlot.endDatetime);
}