Welcome to the CHICKEN Scheme pasting service

moon-phase added by C-Keen on Thu Apr 5 12:55:16 2012

;; Ben Daglish's simple method, see http://www.ben-daglish.net/moon.shtml
;; Returns the phase day (0 to 29, where 0=new moon, 15=full etc.) for
;; the selected date.
(use srfi-19)
(define (moon-phase year month day)
  (let ((lunar-phase 2551443)
        (new-moon 588900000)
        (date (time->milliseconds
               (date->time (date-subtract-duration
                            (make-date 0 0 0 0 day month year)
                            (make-duration #:months 1))))))
    (inexact->exact (add1 (floor (/ (modulo (/ (- date new-moon) 1000) lunar-phase)
                                    (* 24 3600)))))))


Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which module provides `get-environment-variable'?
Visually impaired? Let me spell it for you (wav file) download WAV