Skip to main content
Skip table of contents

TimeSlotGenerator

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

Methods

getTimeSlots
Description

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

Signature
CODE
global static B25.TimeSlotGenerator.Result getTimeSlots(B25.TimeSlotGenerator.Context)
Parameters
CODE
B25.TimeSlotGenerator.Context

Contains the settings for the series to be generated.

Return Type
CODE
B25.TimeSlotGenerator.Result

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

Inner Classes

Context
Description

Contains the settings for the series to be generated.

Properties
CODE
Datetime startOfRange;

The start time of the series to be generated.

CODE
Datetime endOfRange;

The end time of the series to be generated.

CODE
Integer duration;

The duration of each time slot, in minutes.

CODE
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.

Result
Description

Contains the resulting time slots.

Properties
CODE
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.

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);
}
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.