From: Shin-ichiro HARA Date: 1998-03-13T20:43:42+09:00 Subject: [ruby-list:7107] calender-html.rb (Re: call for scripts) 原です。 つまらないものですが、おひとつ、、。 -----^ calendar-html.rb #!/usr/local/bin/ruby def calendar_html(arg = [], data = "") if arg.length > 0 year, month, day = arg.collect{ |x| x.to_i } else t = Time.now day, month, year = t.mday, t.mon+1, t.year+1900 end holiday = {} d = m = y = nil data.each { |line| d, m0, y0 = line.split m = m0 || m y = y0 || y holiday[[y.to_i,m.to_i,d.to_i]] = TRUE } s = "" s << "

#{year} / #{month} / #{day}

\n" s << "\n\n" this_mon = Time.local(year, month-1, 1) len = (Time.local(year+month/12, month%12, 1) - this_mon) / 86400 start = this_mon.wday i = 1 - start while i <= len week = (i + start - 1) % 7 date = if i > 0 if i == day "#{i}" else i end else '' end color = if week != 0 && ! holiday[[year,month,i]] if week == 6 "#0000FF" else "#000000" end else "#FF0000" end s << "\n" if week == 0 s << "\n" s << "\n" if i == len || week == 6 i += 1 end s << "
" s << 'Sun,Mon,Tue,Wed,Thu,Fri,Sat'.gsub(',', '') s << "
#{date}
\n" end print calendar_html(ARGV, "1 1 1998 15 11 2 21 3 29 4 3 5 4 5 20 7 15 9 23 10 10 3 11 23 23 12 1 1 1999 15 11 2 22 3 29 4 3 5 4 5 20 7 15 9 23 11 10 3 11 23 23 12 ") -----$ calendar-html.rb