def print_calendar(year, month)
first = Date.new(year, month, 1)
end_of_month = ((first >> 1) - 1).day
start = 6 - first.wday
work_date = AlmanacDateTime.new(year,month,1,12,0,0,Rational(3,8))
twentyeight_mansions = AlmanacTwentyEightMansions.new
Curses::init_screen
title_string = " " + year.to_s + "年 " + month.to_s + "月" + "\n"
Curses::addstr(title_string)
Curses::addstr(" 日 月 火 水 木 金 土 " + "\n")
WEEK_TABLE.each{|week|
week_buf = ""
twentyeight_mansions_buf = ""
week[start, 7].each{|day|
if day > end_of_month
week_buf << " "
twentyeight_mansions_buf << " "
else
work_week = sprintf("%3d", day) + " "
week_buf << work_week
work_twentyeight_mansions_string \
= AlmanacTwentyEightMansions::TWENTY_EIGHT_MANSIONS_NAME_J[
twentyeight_mansions.get_twenty_eight_mansions_number(work_date)] + "宿 "
twentyeight_mansions_buf << work_twentyeight_mansions_string
work_date = work_date + 1
end
}
week_buf = week_buf +"\n"
Curses::addstr(week_buf)
twentyeight_mansions_buf = twentyeight_mansions_buf + "\n"
Curses::addstr(twentyeight_mansions_buf)
}
Curses::refresh
Curses::getch
Curses::close_screen
end