temporal-fns
API reference

previousDay

API index · Input types and conventions · Installation

previousDay(value, weekday) → same kind

Move strictly backward to the previous occurrence of the requested weekday. Matching the input's own weekday moves back a week. Clock preservation, skipped occurrences, weekday validation, and range rules match nextDay.

import { previousDay } from '@frantss/temporal-fns';

const thursday = Temporal.PlainDate.from('2026-10-22');
previousDay(thursday, 3).toString(); // => '2026-10-21'
previousDay(thursday, 4).toString(); // => '2026-10-15'
previousDay(thursday, 0).toString(); // => '2026-10-18'
previousDay(Temporal.PlainDateTime.from('2026-10-22T12:30'), 3).toString(); // => '2026-10-21T12:30:00'

Related: nextDay, subBusinessDays, endOfWeek.

Behaviors: CAL-001: Weekday navigation is strictly next or previous; CAL-003: A missing weekday occurrence is skipped rather than returning another weekday; CAL-004: Weekday numbers cannot wrap or be fractional.