#!/usr/bin/env ruby

class Time
	@@my_holidays = {}
	@@my_holidays['2009'] = {									# 2009年度
		'1223' => '天皇誕生日',
		'0101' => '元日',										# 2010年
		'0111' => '成人の日',
		'0211' => '建国記念の日',
		'0321' => '春分の日',
	}
	@@my_holidays['2010'] = {									# 2010年度
		'0429' => '昭和の日',
		'0503' => '憲法記念日',
		'0504' => 'みどりの日',
		'0505' => 'こどもの日',
		'0719' => '海の日',
		'0920' => '敬老の日',
		'0923' => '秋分の日',
		'1011' => '体育の日',
		'1103' => '文化の日',
		'1123' => '勤労感謝の日',
		'1223' => '天皇誕生日',
#		'1225' => '!休日出勤',
		'0101' => '元日',										# 2011年
		'0110' => '成人の日',
		'0211' => '建国記念の日',
		'0321' => '春分の日',
	}
	def my_holiday?
		it = @@my_holidays[(year - (month < 4 ? 1 : 0)).to_s] || {}
		it = it['%02d%02d' % [month, day]] and return(it =~ /^!/ ? false : it)
		wday == 0 and return('日曜日')
		wday == 6 and return('土曜日')
		false
	end
end

begin
	$LOAD_PATH.unshift('/usr/local/lib/ruby')
	require 'my_holidays'
rescue LoadError
end

now = Time.now
target = (it = ARGV[0]) ? it.to_i : now.year * 100 + now.mon
target += now.year * 100 if(target < 13)
target += 200000 if(target < 10000)

wdays = %w(日 月 火 水 木 金 土)
tt = Time.local(target / 100, target % 100)
(1..45).each {
	printf("-------- %4d年 %2d月 --------\n", tt.year, tt.month) if(tt.day == 1)
	printf("%2d(%s): %s\n", tt.day, wdays[tt.wday], (it = tt.my_holiday?) ? "--#{it}--" : '')
	tt += 24 * 60 * 60
}

__END__

