Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

clamp

import { clamp } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// What is Mar, 21, 2021 bounded to an interval starting at Mar, 22, 2021 and ending at Apr, 01, 2021
const result = clamp(new Date(2021, 2, 21), {
  start: new Date(2021, 2, 22),
  end: new Date(2021, 3, 1),
})
//=> Mon Mar 22 2021 00:00:00
function clamp<DateType extends Date>(date: DateType | number | string, interval: Interval): DateType | Date;
§
clamp<DateType extends Date>(date: DateType | number | string, interval: Interval): DateType | Date
[src]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
date: DateType | number | string
[src]
  • The date to be bounded
§
interval: Interval
[src]
  • The interval to bound to

§Return Type

§
DateType | Date
[src]

The date bounded by the start and the end of the interval