Skip to content

Workdays ​

ts
import { addWorkdays, isWorkday, workdaysBetween } from 'temporal-workdays';

const friday = Temporal.PlainDate.from('2026-11-06');

addWorkdays(friday, 1).toString(); // → '2026-11-09'
addWorkdays(friday, -5).toString(); // → '2026-10-30'
isWorkday(Temporal.PlainDate.from('2026-11-07')); // → false
workdaysBetween(Temporal.PlainDate.from('2026-11-02'), Temporal.PlainDate.from('2026-11-09')); // → 5

Other weekends, holidays and make-up working days:

ts
import { createWorkCalendar } from 'temporal-workdays';

const calendar = createWorkCalendar({
  weekend: [5, 6], // Friday and Saturday (ISO numbering: 1 is Monday, 7 is Sunday)
  holidays: ['2026-03-20', '12-25'], // one date, and December 25 every year
  extraWorkdays: ['2026-03-28'], // a Saturday that is a working day
});

calendar.isWorkday(Temporal.PlainDate.from('2026-03-20')); // → false
calendar.isWorkday(Temporal.PlainDate.from('2026-03-28')); // → true
calendar.nextWorkday(Temporal.PlainDate.from('2026-03-19')).toString(); // → '2026-03-22'

createWorkCalendar checks and prepares the options once. Every function also accepts the options after its other arguments, as in addWorkdays(date, 3, { holidays }).

Released under the MIT License.