A booking interface may show a simple grid of times. Behind each available slot, however, is a calculation combining the service, staff, working hours, leave, existing appointments and possible external commitments.
Short answer: Availability should not be stored as a permanent list of times. It is generated from the current rules and checked again when the booking is created. A time that was free when the page opened cannot be assumed to remain available several minutes later.
Inputs to the availability calculation
To decide whether an interval is available, the system needs at least:
- service duration,
- buffers before and after,
- the eligible staff member or resource,
- weekly working intervals,
- exceptions and leave,
- active bookings,
- the business time zone,
- booking horizon and minimum notice,
- conflicts from a connected calendar where applicable.
The value 09:00 is not enough on its own. It must mean 09:00 in a specific time zone, on a specific date, for one service and an available resource.
Duration and buffers reserve different intervals
If a service lasts 60 minutes and requires 15 minutes of preparation, the appointment may be displayed to the customer as 10:00–11:00 while reserving the resource from 09:45.
A practical calculation uses:
guardedStart = startsAt - bufferBefore
guardedEnd = startsAt + duration + bufferAfter
The guarded interval is compared with other commitments. Checking only the visible appointment could allow another booking to overlap the preparation or recovery period.
Buffers belong to the service when they vary by appointment type. One global 15-minute gap is easy to implement but often fails to represent how the business operates.
Weekly hours are only the starting point
A staff member may have more than one interval on the same day, such as 09:00–13:00 and 16:00–20:00. The complete slot must fit inside one allowed interval. Starting before closing time is not enough.
Exceptions are applied on top of the weekly pattern:
- leave or illness,
- different hours on one date,
- a public holiday,
- a closed room or unavailable equipment,
- an internal commitment not created by a customer.
Exceptions need priority over the general schedule. Otherwise, the system can recreate slots the business has already closed manually.
Use one consistent overlap rule
Two time intervals conflict when the first begins before the second ends and the second begins before the first ends:
aStart < bEnd && bStart < aEnd
This permits one appointment to begin exactly when the previous one ends, unless a buffer applies. It also avoids special branches for cases where one interval sits entirely inside another.
Before using the rule, decide which booking states block time. A cancelled booking normally does not. A pending request may block temporarily or not at all, depending on the workflow. The state model should be a business decision rather than an accidental code condition.
“Any available person” is an assignment strategy
When the customer does not select a specific professional, the system needs to choose an eligible person. It first filters staff who provide the service, then runs availability checks for each one.
The final choice may use:
- fixed priority,
- round robin,
- the lowest number of upcoming appointments,
- a specialisation or location rule.
The strategy should be visible to administrators and deterministic when the same data is supplied. Opaque random assignment is difficult to explain and test.
External-calendar availability is an additional constraint
A connected calendar can prevent a booking over a personal event. It should not become the only source of truth for business bookings.
The integration needs two directions:
- a free/busy check before creation,
- a dependable event write or update after creation, rescheduling or cancellation.
The second step may fail after the booking has been stored. The application therefore needs sync state, retries and a visible administrator error. Deleting the booking because a temporary calendar API call failed may be worse than recording the pending sync.
Recheck the slot before writing
The available-time list is a snapshot. Two people can open the same time on separate devices and select it.
The public endpoint should repeat critical availability checks before storage. When the data store supports a transaction, conditional write or unique constraint for the relevant resource and interval, checking and writing should be protected by the corresponding consistency boundary.
If the slot has just been taken, the API should return a specific conflict response. The interface explains that the time is no longer available and returns the visitor to an updated list rather than displaying a generic error.
Time zones and daylight-saving changes
Store the booking as a specific instant, normally an ISO timestamp, together with the time zone used for business presentation. Weekly hours are evaluated in the business time zone, not the server device’s zone.
This prevents errors when:
- the server runs in UTC,
- the customer is in another country,
- daylight-saving time changes,
- an online appointment needs to be displayed in two time zones.
Dates around daylight-saving changes need explicit tests. Some local times do not exist or occur twice, and simple string arithmetic cannot resolve them dependably.
What Kairos verifies
In Kairos (project overview, built under our booking systems engineering practice), the availability model connects service duration and buffers, staff weekly availability and holidays, booking states, the business time zone and conflicts from connected calendars. The public booking flow rechecks availability before writing the appointment.
Tests cover at least:
- bookings inside and outside working hours,
- overlap with an active appointment,
- buffer conflicts,
- staff leave,
- independence between different staff members,
- eligible staff selection when the customer chooses “anyone”,
- a busy period from a connected calendar,
- a slot taken before final submission.
The goal is not to produce as many slots as possible. It is for every displayed time to mean the same thing to the customer, staff and system.