feat: add day menu

This commit is contained in:
2025-11-28 14:07:03 +01:00
parent 02c5542f2f
commit 75a2b404b1
4 changed files with 263 additions and 51 deletions

46
src/lib/dates.lua Normal file
View File

@@ -0,0 +1,46 @@
local dates = {}
---Checks whether date2 is after date1
---@param date1 any
---@param date2 any
---@return boolean
function dates.isAfter(date1, date2)
if date2.year < date1.year then
return false
elseif date2.year > date1.year then
return true
end
if date2.month < date1.month then
return false
elseif date2.month > date1.month then
return true
end
return date2.day > date1.day
end
---Checks whether date2 is before date1
---@param date1 any
---@param date2 any
---@return boolean
function dates.isBefore(date1, date2)
if date2.year > date1.year then
return false
elseif date2.year < date1.year then
return true
end
if date2.month > date1.month then
return false
elseif date2.month < date1.month then
return true
end
return date2.day < date1.day
end
function dates.isInDateRange(startDate, targetDate, endDate)
return not (
dates.isBefore(startDate, targetDate) or
dates.isAfter(endDate, targetDate)
)
end
return dates