temporal-fns
    Preparing search index...

    temporal-fns

    temporal-fns

    A utility library for working with Temporal dates and times, providing helper functions for common date and time manipulations.

    Documentation · npm · GitHub

    npm install temporal-fns
    

    temporal-fns v2+ uses the native Temporal global and ships ESM only.

    • Node.js 26 or later (Temporal is enabled by default).
    • Browsers / runtimes that expose the Temporal global natively.

    If you need to run on an older runtime, install and load a polyfill (for example temporal-polyfill) before importing this package. Pre-v2 releases bundled a polyfill — v2 leaves that choice to you.

    import { startOfMonth, addBusinessDays, eachDayOfInterval } from "temporal-fns";

    const today = Temporal.Now.plainDateISO();

    startOfMonth(today);
    addBusinessDays(today, 5);
    eachDayOfInterval({ start: today, end: today.add({ days: 6 }) });

    See the full API documentation for detailed signatures and examples.

    Category Functions
    Period boundaries startOfDay, endOfDay, startOfHour, endOfHour, startOfMinute, endOfMinute, startOfSecond, endOfSecond, startOfWeek, endOfWeek, startOfMonth, endOfMonth, startOfQuarter, endOfQuarter, startOfYear, endOfYear
    Day-of-week navigation nextDayOfWeek, previousDayOfWeek, firstDayOfWeekOfMonth, lastDayOfWeekOfMonth
    Predicates isWeekend, isBusinessDay, isFirstDayOfMonth, isLastDayOfMonth, isToday, isYesterday, isTomorrow, isPast, isFuture
    Same-period predicates isSameDay, isSameWeek, isSameMonth, isSameQuarter, isSameYear, isSameHour, isSameMinute, isSameSecond
    Comparison & selection compare, min, max, clamp, closestTo, closestIndexTo
    Intervals eachDayOfInterval, eachWeekOfInterval, eachMonthOfInterval, eachQuarterOfInterval, eachYearOfInterval, eachHourOfInterval, eachMinuteOfInterval, isWithinInterval, areIntervalsOverlapping, intervalToDuration
    Business days isBusinessDay, addBusinessDays, subBusinessDays, differenceInBusinessDays
    Conversion fromDate, toDate, getQuarter
    Type helpers Interval, ComparableTemporal, TemporalWithDate, TemporalWithTime, TemporalWithDateTime, TemporalWithYearMonth

    MIT