DateTime():isBetween()
Checks if the current DateTime object is between two other DateTime objects (inclusive).
Signature
isBetween(start: DateTime, end: DateTime): boolean
Parameters
Parameter | Type | Description |
---|---|---|
start | DateTime | The start DateTime object. |
end | DateTime | The end DateTime object. |
Returns
- Type:
boolean
true
if the currentDateTime
is betweenstart
andend
(inclusive),false
otherwise.
Examples
local date = DateTime(2024, 1, 15)
local start = DateTime(2024, 1, 10)
local end_date = DateTime(2024, 1, 20)
local result1 = date:isBetween(start, end_date) -- result will be true
toast(tostring(result1))
local dateOutside = DateTime(2024, 1, 25)
local result2 = dateOutside:isBetween(start, end_date) -- result will be false
toast(tostring(result2))