tfs 0.3.5 / 0.3.6
I need a globalevent that doesn't repeat twice per week, therefore I'd need a function that returns day of the next week as monthday number
I've googled this a bit but it appears in python, msexcel, etc
the main function I haven't managed to finish, in this case the sunday of next week since current time, in yearday format
there's that thing of leap year too
--so far I got this, but it could be reduced I guess
I need a globalevent that doesn't repeat twice per week, therefore I'd need a function that returns day of the next week as monthday number
I've googled this a bit but it appears in python, msexcel, etc
Lua:
function getYearDay(dd, mm, yy)
return os.date('*t',os.time{year = yy, month = mm, day = dd})['yday']
end
the main function I haven't managed to finish, in this case the sunday of next week since current time, in yearday format
Lua:
function getNextSunday()
local value = 0
for day = os.date('%j')+1, os.date('%j')+7 do
if day <= getYearDay(31, 12, 2012) then
if os.date('%A') == 'Sunday' then --smth like if os.date(iterator's day, iterator's month) -> 'Sunday'
return --to return the next Sunday's monthday #
end
end
end
end
there's that thing of leap year too
--so far I got this, but it could be reduced I guess
Lua:
function getMonthDays(mm, yy)
return os.date('*t',os.time{year = yy, month = mm+1, day = 0})['day']
end
function getNextDay(name)
local mm, yy = os.date('%m'), os.date('%Y')
for day = os.date('%d')+1, os.date('%d')+7 do
if day > getMonthDays(mm, yy) then
mm = mm+1
day = day-getMonthDays(mm, yy)
end
if os.date('%A',os.time{year = yy, month = mm, day = day}) == name then
return day
end
end
end
print(getNextDay('Sunday'))
Last edited: