Skip to content

isValidTimeInterval

isValidTimeInterval(start: string, end: string): boolean

Return true if start and end form a valid time interval — both parseable as ISO PlainTime strings and start <= end.

  • Both inputs must be ISO 8601 time strings (e.g. "14:30:00").
  • Equal start === end is valid.
  • Invalid input, malformed strings, or leap-second strings return false.
  • Each endpoint must satisfy isValidTime, so annotations are read as Temporal reads them: a time zone annotation ([Europe/Paris]), [u-ca=iso8601] and an elective annotation ([foo=bar]) are ignored; an unknown critical annotation ([!foo=bar]) is rejected.
ParameterTypeDescription
startstringISO 8601 time string (interval start)
endstringISO 8601 time string (interval end)

true if start and end form a valid time interval, or false on invalid input

import { isValidTimeInterval } from "@northguild/gmt/plain/interval";
isValidTimeInterval("09:00:00", "17:00:00") // true
output 

plain/interval/validate/isValidTimeInterval.ts