-module(year_cal). -export([main/0]). main() -> year_cal(2008). year_cal(Year) -> lists:foreach(fun manth/1, [{Year, X} || X <- lists:seq(1, 12)]). manth({Year, Manth}) -> io:format("~B月_~B~n", [Manth, Year]), io:format("日 月 火 水 木 金 土~n", []), First = calendar:day_of_the_week(Year, Manth, 1), if 7 == First -> true; true -> io:format(lists:duplicate(((First rem 7) * 3) - 1, " "), []) end, manth(Year, Manth, 1). manth(Year, Manth, Day) -> case calendar:valid_date(Year, Manth, Day) of false -> io:nl(); % 一ヶ月の終わり true -> Dotw = calendar:day_of_the_week(Year, Manth, Day), if 7 == Dotw -> io:format("~2B", [Day]); % 日曜日 6 == Dotw -> io:format("~3B~n", [Day]); % 土曜日 true -> io:format("~3B", [Day]) % その他平日 end, manth(Year, Manth, Day + 1) end.