template::util::date::daysInMonth (public)
template::util::date::daysInMonth month [ year ]
Defined in packages/acs-templating/tcl/date-procs.tcl
- Parameters:
- month (required)
- year (optional, defaults to
"0"
)- an integer representing the number of the year in the Gregorian calendar.
- Returns:
- the number of days in a month, accounting for leap years.
- See Also:
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: # 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} variable month_data set month_desc $month_data($month) set days [lindex $month_desc 2] if { $month == 2 && ( (($year % 4) == 0 && ($year % 100) != 0) || (($year % 400) == 0) ) } { return [expr {$days + 1}] } else { return $days }XQL Not present: Generic, PostgreSQL, Oracle