Friday, February 29, 2008

Is it a leap year

Here's a bit of elisp code to find out...


(defun is-century-year(year)
(if (= (mod year 100) 0)
t
nil))

(defun is-leap-year(year)
"leap year is century years divisible by 400,
not other century years, otherwise anything evenly
divisble by 4"
(if (is-century-year year)
(if (= 0 (mod year 400))
t
nil)
(if (= 0 (mod year 4))
t
nil)))