set year [clock format [clock seconds] -format %Y]

for { set month 1 } { $month <= 12 } { incr month } {

    set startOfMonth \
	[clock scan \
	     [format %04d-%02d-01 $year $month] \
	     -format %Y-%m-%d]
    set lastDayOfMonth \
	[clock format \
	     [clock add $startOfMonth 1 month -1 day] \
	     -format %d]
    set monthName [clock format $startOfMonth -format %B]

    puts "$monthName $year has $lastDayOfMonth days by method 1"

    set endOfMonth [format %04d-%02d-00 $year [expr { $month + 1 }]]
    set lastDay [clock format [clock scan $endOfMonth] -format %d]

    puts "$monthName $year has $lastDay days by method 2"
}
