Coming from date-fns
The business-day functions in date-fns only know Monday to Friday. The translations below are checked against the real date-fns in test/date-fns.test.ts.
ts
import { addBusinessDays, differenceInBusinessDays, format } from 'date-fns';
import { addWorkdays, workdaysBetween } from 'temporal-workdays';
format(addBusinessDays(new Date(2026, 10, 6), 3), 'yyyy-MM-dd'); // → '2026-11-11'
addWorkdays(Temporal.PlainDate.from('2026-11-06'), 3).toString(); // → '2026-11-11'
differenceInBusinessDays(new Date(2026, 10, 16), new Date(2026, 10, 9)); // → 5
workdaysBetween(Temporal.PlainDate.from('2026-11-09'), Temporal.PlainDate.from('2026-11-16')); // → 5| date-fns | temporal-workdays |
|---|---|
addBusinessDays(date, n) | addWorkdays(d, n), which always gives the same result |
isWeekend(date) | isWeekend(d) |
differenceInBusinessDays(later, earlier) | workdaysBetween(earlier, later) when both are workdays, otherwise see below |
Going forward, differenceInBusinessDays counts from the earlier date up to, but not including, the later one. When either date can be a weekend day and you need its exact result, move both dates back one day:
ts
import { differenceInBusinessDays } from 'date-fns';
import { workdaysBetween } from 'temporal-workdays';
const saturday = Temporal.PlainDate.from('2026-11-07');
const monday = Temporal.PlainDate.from('2026-11-09');
differenceInBusinessDays(new Date(2026, 10, 9), new Date(2026, 10, 7)); // → 0
workdaysBetween(saturday.subtract({ days: 1 }), monday.subtract({ days: 1 })); // → 0Going backward, with later before earlier, workdaysBetween(earlier, later) already gives its exact result.