isBetweenTime
Signature
Section titled “Signature”isBetweenTime(time: string, start: string, end: string, options?: { inclusiveStart?: boolean; inclusiveEnd?: boolean; }): booleanimport { isBetweenTime } from "@northguild/gmt/plain/compare";Return true when time is between start and end (inclusive by default).
- Uses Temporal.PlainTime.compare to compare times.
- Returns false if start > end (invalid range).
- Returns false if any input is invalid.
- Use options.inclusiveStart and options.inclusiveEnd to control boundary inclusivity.
- Note: PlainTime comparison does not account for day overflow.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
time |
string |
ISO PlainTime string to check |
start |
string |
ISO PlainTime string for the start of the range |
end |
string |
ISO PlainTime string for the end of the range |
Options
Section titled “Options”options
| Option | Type | Default |
|---|---|---|
inclusiveStart? |
boolean |
— |
inclusiveEnd? |
boolean |
— |
Returns
Section titled “Returns”boolean indicating whether time is between start and end
Examples
Section titled “Examples”isBetweenTime("12:34:56", "12:00:00", "13:00:00") // trueisBetweenTime("12:34:56", "12:34:56", "13:00:00") // trueisBetweenTime("12:34:56", "12:34:57", "13:00:00") // falseisBetweenTime("12:34:56", "12:00:00", "12:34:56") // trueisBetweenTime("12:34:56", "12:00:00", "12:34:55") // falseisBetweenTime("invalid", "12:00:00", "13:00:00") // falseisBetweenTime("12:34:56", "invalid", "13:00:00") // falseisBetweenTime("12:34:56", "12:00:00", "invalid") // false