API Reference
This page provides a quick reference for Calendary's public API.
Calendary
Calendary::load()
Creates a calendar from weekly and date-specific availability.
timezone()
Sets the timezone used during calendar resolution.
duration()
Sets generated slot duration.
interval()
Sets the interval between candidate slot starts.
breakTime()
Sets the additional unavailable time after a busy entry whose end is inferred from the configured duration.
The default value is 0.
busy()
Adds busy dates or time periods.
daysOff()
Marks dates as days off.
holidays()
Marks dates as holidays.
query()
Starts a calendar query.
CalendarQuery
select()
Controls which Day fields are serialized.
Accepted fields:
date weekday available status slots
status()
Filters resolved days by status.
Accepted statuses:
open closed full day_off holiday
available()
Returns only days containing at least one available slot.
availableSlots()
Removes busy slots from returned Day objects.
on()
Resolves one date.
weekOf()
Resolves the ISO week containing a date.
between()
Resolves an inclusive date range.
Day
$day->date(): DateTimeImmutable;
$day->weekday(): int;
$day->status(): string;
$day->slots(): array;
$day->availableSlots(): array;
$day->available(): bool;
$day->isAvailable(string $time): bool;
$day->toArray(): array;
$day->toJson(int $flags = 0): string;
Slot
$slot->start(): DateTimeImmutable;
$slot->end(): DateTimeImmutable;
$slot->status(): string;
$slot->available(): bool;
$slot->toArray(): array;
$slot->toJson(int $flags = 0): string;
Range
$range->from(): DateTimeImmutable;
$range->to(): DateTimeImmutable;
$range->days(): array;
$range->toArray(): array;
$range->toJson(int $flags = 0): string;
Result
Day, Slot and Range implement:
The contract provides:
and extends PHP's JsonSerializable.