Skip to content

isValidDateTimeRange

  • The core functions, which every industry uses.
isValidDateTimeRange(props: { value1: string; value2: string; options?: { allowEqual?: boolean; }; }): boolean

Return true if value1 and value2 form a valid datetime range — both parseable as ISO PlainDateTime strings and value1 before value2.

  • Both inputs must be ISO 8601 datetime strings (e.g. "2024-01-01T10:00:00"), as isValidDateTime accepts, annotations included.
  • Invalid input, malformed strings, or leap-second strings return false.

props

The two values to compare and how equal values are treated

OptionTypeDefaultDescription
value1stringRequiredThe start of the range, an ISO PlainDateTime string.
value2stringRequiredThe end of the range, an ISO PlainDateTime string.
options?objectNone. Equal values are not a valid range.The settings for the comparison. It must be an object or omitted; any other value, null included, returns false.
options.allowEqual?booleanfalseWhether value1 equal to value2 is a valid range. false requires value1 to be before value2.

boolean indicating whether the datetime range is valid

import { isValidDateTimeRange } from "@northguild/gmt/plain/validate";
isValidDateTimeRange({ value1: "2024-01-01T10:00:00", value2: "2024-12-31T23:59:59" }) // true
output 

plain/validate/isValidDateTimeRange.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.