C
Chinna Karuppan
why is it not working properly( weekly calendar)...
require "Date"
def mon_days(month,year=Date.today.year)
mday = [nil,31,28,31,30,31,30,31,31,30,31,30,31]
mday[2] = 29 if Date.leap? year
mday[month]
end
def cal_week(month,year=Date.today.year)
days = 1..mon_days(month,year)
weeks = []
week = []
wday = 1
for i in days
wday = Date.new(year,month,i).wday
week[wday] = i
if wday == 6
weeks << week
p week,weeks
week.clear
end
end
weeks << week if week.length != 0
weeks
end
p cal_week(4)
I think it is the problem of week still remembering the values....
THnks
CHinna
require "Date"
def mon_days(month,year=Date.today.year)
mday = [nil,31,28,31,30,31,30,31,31,30,31,30,31]
mday[2] = 29 if Date.leap? year
mday[month]
end
def cal_week(month,year=Date.today.year)
days = 1..mon_days(month,year)
weeks = []
week = []
wday = 1
for i in days
wday = Date.new(year,month,i).wday
week[wday] = i
if wday == 6
weeks << week
p week,weeks
week.clear
end
end
weeks << week if week.length != 0
weeks
end
p cal_week(4)
I think it is the problem of week still remembering the values....
THnks
CHinna