Posted to tcl by mjanssen at Sun Dec 10 21:30:17 GMT 2006view pretty

proc days_in_month {year month} {
	switch $month {
		1 -
		3 - 
		5 -
		7 -
		8 - 
		10 -
		12 {return 31}
		2 {
			set leap false
			if {$year%4==0} {set leap true}
			if {$year%100==0} {set leap false}
			if {$year%400==0} {set leap true}
			if {$leap} {return 29} {return 28}
		}
		default {return 30} 
	}
	
}

Comments

Posted by mjanssen at Sun Dec 10 21:41:41 GMT 2006 [text] [code]

proc days_in_month {year month} { switch $month { 4 - 6 - 5 - 9 - 11 {return 30} 2 { set leap false if {$year%4==0} {set leap true} if {$year%100==0} {set leap false} if {$year%400==0} {set leap true} if {$leap} {return 29} {return 28} } default {return 31} } }