From: Shin-ichiro HARA Date: 1998-03-14T19:56:23+09:00 Subject: [ruby-list:7110] Re: calendar-html.rb (Re: call for scripts) 原です。 たびたびすいません。また少し変えました。 ところで正しい春分秋分の求め方ってどういう式でしょうか? -----^ calendar.rb #!/usr/local/bin/ruby DATA = "1,1 15 11,2 21,3 29,4 3,5 4 5 20,7 15,9 23 10,10 3,11 23 23,12" def calendar_html(arg = [], data = DATA) t = Time.now e = (VERSION >= "1.1") && 0 || 1 year = if arg[0] arg[0].to_i else t.year+1900*e end month = if arg[1] arg[1].to_i else t.mon + e end day = arg[2] && arg[2].to_i || t.mday holiday = {} m = y = nil data.split(/\s+/).each { |line| d, m0 = line.split(/,/) m = m0 || m holiday[[m.to_i,d.to_i]] = TRUE } s = "" s << "

#{year}.#{month}.#{day}

\n" s << "\n\n" this_mon = Time.local(year, month-e, 1) len = (Time.local(year+month/12, month%12+1-e, 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[[month,i]] || week == 1 && holiday[[month,i-1]] "#FF0000" else if week == 6 "#0000FF" else "#000000" end 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 -----$ calendar.rb