Skip to Content
Getting started

timeslottr

timeslottr turns working hours into bookable time slots. Use it to skip breaks, remove existing bookings, and find times when everyone on a team is free.

It is a TypeScript library with no runtime dependencies. It handles timezones and daylight-saving changes using the platform’s Intl API. You provide the calendar data, storage, and booking UI.

High unit test coverage. The current suite has 273 passing tests, with 97.92% line coverage and 96.18% branch coverage across the library source. Tests cover daylight-saving transitions, interval boundaries, exclusions, booking windows, and multi-party availability. CI runs the suite on Node.js 18, 20, and 22 . Run npm run coverage from the repository root to check the latest results.

Choose the function for your task

I want to…Use
Generate slots for one day or time windowgenerateTimeslots
Apply working hours across several daysgenerateDailyTimeslots
Offer slots around existing bookings or several people’s calendarsgenerateAvailableTimeslots
Subtract busy time or find shared free time without generating slotssubtract and intersect

Installation

npm install timeslottr

Requires Node.js ≥ 18.

Generate your first slots

Generate 30-minute slots for a single day, skipping a lunch break:

import { generateTimeslots } from 'timeslottr' const slots = generateTimeslots({ day: '2024-01-01', timezone: 'America/New_York', range: { start: '09:00', end: '17:00' }, slotDurationMinutes: 30, excludedWindows: [{ start: '12:00', end: '13:00' }], }) console.log(slots.length) // 14 slots: 9 to 12 and 1 to 5, every 30 minutes console.log(slots[0].start.toISOString()) // '2024-01-01T14:00:00.000Z' console.log(slots[0].end.toISOString()) // '2024-01-01T14:30:00.000Z'

Each slot is a Timeslot: a meeting option with start and end dates plus metadata describing its length and position. A meeting can end exactly when the next one starts; Core concepts walks through that rule. Start and end are real Date objects. In this example, 09:00 in New York is 14:00 UTC. The Z in the output means UTC; it does not mean the configured timezone was ignored.

These fixed-date examples work whenever you run them. Past dates are included unless you enable a booking window.

Find a time that works for a team

Suppose the host takes lunch at noon, Alice is busy until 10:00, and Bob is busy from 16:00. Give the generator those bookings to find times they can all attend.

import { generateAvailableTimeslots } from 'timeslottr' const slots = generateAvailableTimeslots({ day: '2024-01-01', timezone: 'America/New_York', range: { start: '09:00', end: '17:00' }, slotDurationMinutes: 30, busy: [{ start: '12:00', end: '13:00' }], // already-booked participantsBusy: [ [{ start: '09:00', end: '10:00' }], // Alice [{ start: '16:00', end: '17:00' }], // Bob ], }) // 10 slots: 10:00–12:00 and 13:00–16:00 in America/New_York

Your application supplies the bookings and saves any reservations. timeslottr returns the possible meetings; it does not connect to calendars or reserve a slot.

Where to next

New to scheduling dates? Start with Core concepts. Ready to build? Follow Scheduling for working hours, or Multi-party availability for calendar bookings. The reference pages list signatures, types, and defaults.

Last updated on