I am trying to make a list of dates, starting from today.
The start is easy, I use the commands
local date = os.date( “*t” )
print( date.year, date.month, date.day )
print(date.wday)
Now I would like to make a loop that increments the day with one and adds the new day to a table
My table WeekDays has the local strings of the weekdays and MonthNames the local strings for months
for i = 0,90 do date.day = date.day +1 local weekday = tonumber(os.date("%w", os.time(date))) if weekday then print("weekday: "..weekday) print("weekday: ".. WeekDays[weekday+1]) end days[i] = WeekDays[weekday+1].." "..date.day.." "..MonthNames[date.month]..date.year end
The name of the Weekdays is incremented and shows “Monday”, “Tuesday” etc in the local language.
And the days keeps increasing: 1,2,3,4… and then it goes on to 31,32,33…
I would have liked the date to be added so that the month and year changes automatically, like the dateadd() function in other languages so that the date increases from 31. Januar 2018 to 1. February 2018 when I add date.day = date.day +1
The best solution I have found was on this page, but then I need to also consider leap-years.
https://www.promixis.com/forums/archive/index.php/t-8653.html
It could be done, but is there really no easy way to increment the date value, so that I can add it to a picker wheel ?