months = -- 1 2 3 4 5 6 7 8 9 10 11 12function daysBeforeMonth(mon) local days = 0 if mon>1 then for i = 1, mon-1 do days = days + months[i] end return days elseif mon == 1 then return 0 endendfunction isYear(yy) if yy % 100 == 0 then if yy % 400 == 0 then return true end return false else if yy % 4 == 0 then return true end return false endendfunction dayInYear(yy,mm,dd) local days = daysBeforeMonth(mm) + dd if isYear(yy) then days = days + 1 end print(days)enddayInYear(2001,3,1)