isBetweenDateTime
Signature
Section titled “Signature”isBetweenDateTime(dateTime: string, start: string, end: string, options?: { inclusiveStart?: boolean; inclusiveEnd?: boolean; }): booleanReturn true when dateTime is between start and end (inclusive by default).
- Uses Temporal.PlainDateTime.compare to compare date-times.
- Returns false if start > end (invalid range).
- Returns false if any input is invalid.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
dateTime | string | ISO PlainDateTime string to check |
start | string | ISO PlainDateTime string for the start of the range |
end | string | ISO PlainDateTime string for the end of the range |
Options
Section titled “Options”options
Whether each end of the range counts as inside it
| Option | Type | Default | Description |
|---|---|---|---|
inclusiveStart? | boolean | true | Whether dateTime equal to start counts as inside the range. false requires it to be after start. |
inclusiveEnd? | boolean | true | Whether dateTime equal to end counts as inside the range. false requires it to be before end. |
Returns
Section titled “Returns”boolean indicating whether dateTime is between start and end
Examples
Section titled “Examples”import { isBetweenDateTime } from "@northguild/gmt/plain/compare";
isBetweenDateTime("2024-02-29T12:00:00", "2024-02-01T00:00:00", "2024-02-28T23:59:59") // false