isBetweenDate
Signature
Section titled “Signature”isBetweenDate(date: string, start: string, end: string, options?: { inclusiveStart?: boolean; inclusiveEnd?: boolean; }): booleanimport { isBetweenDate } from "@northguild/gmt/plain/compare";Return true when date is between start and end (inclusive by default).
- Uses Temporal.PlainDate.compare to compare dates.
- Returns false if start > end (invalid range).
- Returns false if any input is invalid.
- Use options.inclusiveStart and options.inclusiveEnd to control boundary inclusivity.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
date |
string |
ISO PlainDate string to check |
start |
string |
ISO PlainDate string for the start of the range |
end |
string |
ISO PlainDate 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 date is between start and end
Examples
Section titled “Examples”isBetweenDate("2024-02-29", "2024-02-01", "2024-02-28") // falseisBetweenDate("2024-02-29", "2024-02-01", "2024-02-29") // trueisBetweenDate("2024-02-29", "2024-02-29", "2024-02-28") // falseisBetweenDate("2024-02-29", "2024-02-28", "2024-03-01") // trueisBetweenDate("invalid", "2024-02-01", "2024-02-28") // falseisBetweenDate("2024-02-29", "invalid", "2024-02-28") // falseisBetweenDate("2024-02-29", "2024-02-01", "invalid") // false