Skip to content

clampDate

  • The core functions, which every industry uses.
clampDate(value: string, min: string, max: string): string

Restrict value to the range [min, max].

  • Returns value if it falls within the bounds (inclusive on both ends).
  • Returns min if value is before min.
  • Returns max if value is after max.
  • Returns "" if any input is invalid or min > max.
ParameterTypeDescription
valuestringISO PlainDate string to clamp
minstringISO PlainDate string for the lower bound (inclusive)
maxstringISO PlainDate string for the upper bound (inclusive)

The clamped date string, or "" on invalid input

import { clampDate } from "@northguild/gmt/plain/calculate";
clampDate("2024-03-15", "2024-03-01", "2024-03-31") // "2024-03-15"
output 

plain/calculate/clampDate.ts

Accessibility
© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.