• ruby のプログラム

2007/1/1から2009/7/31までの日付を出力する。

f="";
for k in 2007..2009
for j in 1..12
if (k==2009 && j>7) then break;
end
if (k==2008 && j==2) then n=29;
elsif (k!=2008 && j==2) then n=28;
elsif (j==4 || j==6 || j==9 || j==11) then n=30;
else n=31;
end
for i in 1..n
f << k.to_s;
f << "-"
f << j.to_s;
f << "-";
f << i.to_s;
print f + "\n";
f="";
end
end
end