I found a script that detects the current day. But I want to know how to detect if it is past a specific date, but I don’t know how I would do it.
Here is the script:
local months = {"January","February","March","April","May","June","July","August","September","October","November","December"}
daysinmonth = {31,28,31,30,31,30,31,31,30,31,30,31}
local function getDate()
time = os.time()
local year = math.floor(time/60/60/24/365.25+1970)
local day = math.ceil(time/60/60/24%365.25)
local month
for i=1, #daysinmonth do
if day > daysinmonth[i] then
day = day - daysinmonth[i]
else
month = i
break
end
end
return month, day, year
end
local month, day, year = getDate()
local Date = month.."/"..day.."/"..year
local function getMonthIndex(month)
for i, v in pairs(months) do
if v == month then
return i;
end
end
warn("Couldn't find month")
end
local function checkDate(expectedDate)
local m, d, y = getDate()
return y >= expectedDate["year"] and getMonthIndex(m) >= getMonthIndex(expectedDate["month"]) and d >= expectedDate["day"]
end
checkDate({month = "January", day = 12, year = 2019})
if all three requirements are met in the return statement it will return true, if not it will return false; simply just checks to see if the date values are greater than the values of the date you want to check against.
if you replace it with an or, then it wouldn’t need to meet all the requirements to be passed that date;
say the current day is 09/14/2019, and you want to check against 09/13/2020; it would pass solely because 14 is greater than 13. However as @RuizuKun_Dev stated above you could do that as well.