Based on the algorithm described by CallToPower on his webblog here’s a lisp version of it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | (defun easter-date-for-year (year &optional &key (use-date-name t)) (let ((golden-year (+ 1 (mod year 19))) (century (+ (/ year 100) 1))) (let ((skipped-leap-years (- (/ (* 3 century) 4) 12)) (correction-factor (- (/ (+ (* 8 century) 5) 25) 5))) (let ((d (- (/ (* 5 year) 4) skipped-leap-years 10)) (epac (mod (- (+ (* 11 golden-year) 20 correction-factor) skipped-leap-years) 30))) (if (or (and (= epac 25) (> golden-year 11)) (= epac 24)) (incf epac)) (let ((n (- 44 epac)) (month nil) (day-of-month nil)) (if (< n 21) (setf n (+ 30 n))) (setf n (- (+ n 7) (mod (+ d n) 7))) (cond ((> n 31) (setf month (if use-date-name 'APRIL 4)) (setf day-of-month (- n 31))) (t (setf month (if use-date-name 'MARCH 3)) (setf day-of-month n))) (let ((formatted-date (if use-date-name "~a. ~a ~a" "~a.~a.~a"))) (format nil (concatenate 'string "Easter date: " formatted-date) (round day-of-month) month year))))))) |


One Response
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
Continuing the Discussion