I'm trying to calculate the days between a date and today. Simplest way must be by calling time() and get the seconds since epoch and the calculate the difference.
It works great in theory, but I keep getting a nil error @ trying to perform arithmethic with dayNumber:
local d, m, y = strsplit("/", date, 3) -- date is passed as a function arg
local cDayNumber = time()
local dayNumber = time({year = y, month = m, day = d})
[U]local secondsBetween = cDayNumber - dayNumber;[/U] -- says error is here
local days = (secondsBetween / 3600) /24; -- recalculate from seconds to days
Funny thing is, there's no problem doing the calculations in game with /run.
I'm trying to calculate the days between a date and today. Simplest way must be by calling time() and get the seconds since epoch and the calculate the difference.
It works great in theory, but I keep getting a nil error @ trying to perform arithmethic with dayNumber:
Funny thing is, there's no problem doing the calculations in game with /run.
Turned out my "date" only delivered "12" as year instead of the required "2012" :)