From: sinara@... Date: 1998-03-15T05:10:48+09:00 Subject: [ruby-list:7114] Re: calendar-html.rb (Re: call for scripts) 原です。 後藤さんに紹介していただいた式(の簡単な方)を取り込みました。 -----^ calendar-html.rb def calendar_html(arg = []) holiday = " 1/1 1/15 2/11 4/29 5/3 5/4 5/5 7/20 9/15 10/10 11/3 11/23 12/23 " t = Time.now e = (VERSION >= "1.1") && 0 || 1 year = if arg[0] y = arg[0].to_i else t.year+1900*e end month = if arg[1] m = arg[1].to_i if m >= 1 year += (m-1) / 12 (m-1) % 12 + 1 else year -= (12-m) / 12 12 - (12-m) % 12 end else t.mon + e end day = arg[2] && arg[2].to_i || !arg[0] && t.mday holiday << "3/" << if year < 2000 # syunbun (31*year+2213)/128-year/4+year/100 else (31*year+2089)/128-year/4+year/100 end << " " << "9/" << if year < 2000 # syubun (31*year+2525)/128-year/4+year/100 else (31*year+2395)/128-year/4+year/100 end << " " s = "

#{year}.#{month}" s << if day then ".#{day}

\n" else "\n" end 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.index(" #{month}/#{i} ") || week == 1 && holiday.index(" #{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-html.rb