Overview
The TimeSlots plugin adds functionality to find available time slots within a given date range while considering busy periods. This is perfect for scheduling applications, calendar management, appointment booking, and resource allocation.Installation
Using extend()
Using lazyLoad()
Types
TimeSlot
Represents a time period with start and end times.AvailabilityOptions
Configuration options for finding available slots.Factory Methods
findAvailableSlots()
Finds all available time slots of a specified duration within a date range, avoiding busy periods.options- Configuration object (seeAvailabilityOptionsabove)
TemporalWrapper[] - Array of start times for available slots
Example:
Algorithm Features
Overlapping Busy Slots
The plugin automatically merges overlapping or touching busy slots for optimal performance:Custom Intervals
Control how frequently the algorithm checks for available slots:Boundary Handling
Slots are checked with exclusive end boundaries - a slot ending at 10:00 doesn’t conflict with a busy period starting at 10:00:Complete Examples
Meeting Room Scheduler
Doctor’s Appointment Booking
Multi-Day Resource Allocation
Calendar Integration
Performance Considerations
- Busy slots are automatically sorted and merged for efficient checking
- The algorithm stops as soon as slots exceed the search range
- Invalid date inputs are filtered out early
- For large datasets, consider chunking the search range
Notes
- All times use the Temporal API’s precise time handling
- Date inputs can be strings (ISO 8601), Date objects, or TemporalWrapper instances
- Invalid dates in the range or busy slots are automatically filtered out
- The algorithm uses exclusive end boundaries (a slot ending at 10:00 doesn’t conflict with a busy period starting at 10:00)
- If no
intervalis specified, it defaults to thedurationvalue - Empty arrays are returned if no slots are available
- The search stops when potential slots would exceed the window end