Skip to content

clampZoned

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

Restrict value to the range [min, max] in zoned datetime space.

  • 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 ZonedDateTime string to clamp
minstringISO ZonedDateTime string for the lower bound (inclusive)
maxstringISO ZonedDateTime string for the upper bound (inclusive)

The clamped zoned datetime string, or "" on invalid input

import { clampZoned } from "@northguild/gmt/zoned/calculate";
clampZoned("2024-03-15T12:00:00+00:00[UTC]", "2024-03-01T00:00:00+00:00[UTC]", "2024-03-31T23:59:59+00:00[UTC]") // "2024-03-15T12:00:00+00:00[UTC]"
output 

zoned/calculate/clampZoned.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.