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

  1. proc days_in_month {year month} {
  2. switch $month {
  3. 1 -
  4. 3 -
  5. 5 -
  6. 7 -
  7. 8 -
  8. 10 -
  9. 12 {return 31}
  10. 2 {
  11. set leap false
  12. if {$year%4==0} {set leap true}
  13. if {$year%100==0} {set leap false}
  14. if {$year%400==0} {set leap true}
  15. if {$leap} {return 29} {return 28}
  16. }
  17. default {return 30}
  18. }
  19.  
  20. }

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} } }