Index: openacs-4/packages/acs-templating/tcl/date-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/tcl/date-procs.tcl,v diff -u -r1.63.2.9 -r1.63.2.10 --- openacs-4/packages/acs-templating/tcl/date-procs.tcl 18 Aug 2021 13:42:05 -0000 1.63.2.9 +++ openacs-4/packages/acs-templating/tcl/date-procs.tcl 18 Aug 2021 14:08:56 -0000 1.63.2.10 @@ -107,9 +107,18 @@ month {year 0} } { - @return the number of days in a month, accounting for leap years - LOOKATME: IS THE LEAP YEAR CODE CORRECT ? + @param year an integer representing the number of the year in the + Gregorian calendar. + + @return the number of days in a month, accounting for leap years. + + @see https://en.wikipedia.org/wiki/Leap_year#Algorithm } { + # Something like this oneliner might work and delegate the leap + # year calculation to the clock command. However, it would be + # significantly slower... + # clock format [clock add [clock scan [format "%04d" $year]-[format "%02d" $month]-01 -format %Y-%m-%d] 1 month -1 day] -format %d + set month [string trimleft $month 0] set year [string trimleft $year 0] if {$year eq ""} {set year 0}