-
-
Save kureikei/65f78fdf175631af3410 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System; | |
[<EntryPoint>] | |
let main argv = | |
// 現在の日付を取得し、当月1日の曜日と末日を求めます。 | |
let now = DateTime.Today | |
let prePad = int( DateTime( now.Year, now.Month, 1 ).DayOfWeek ) | |
let lastDay = DateTime.DaysInMonth( now.Year, now.Month ) | |
// カレンダーを出力します。 | |
for curDay in [( -prePad + 1 )..lastDay] do | |
// 範囲を[( - 1日の曜日 + 1 )..末日]にし、要素が負の時に空白を出力します。 | |
// こうすることで1日の曜日に合わせてオフセットすることができます。 | |
if curDay > 0 then printf "%3d" curDay else printf " " | |
if ( curDay + prePad ) % 7 = 0 || curDay = lastDay then printfn "" | |
done | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment