Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!bbn!jr@bbn.com From: jr@bbn.com (John Robinson) Newsgroups: comp.emacs Subject: Re: calendar.el Message-ID: <38202@bbn.COM> Date: 4 Apr 89 13:37:43 GMT References: <4300041@m.cs.uiuc.edu> Sender: news@bbn.COM Reply-To: jr@bbn.com (John Robinson) Organization: BBN Systems and Technologies Corporation, Cambridge MA Lines: 131 In-reply-to: reingold@m.cs.uiuc.edu Here (and perhaps 'most everyewhere) Ed's posting ended thusly: (multiply-hebrew-calendar-interval hebrew-calendar-leap-year (prior-leap-years-in-hebr uxc.cso.uiuc.edu ignored 42 excess bytes If your copy had this problem, go to the end, back up to the last (defun..., and repolace that with the following: ------------------------------------------------------------------------ (defun hebrew-calendar-new-year-mean-conjunction (year) "The time of week of the mean conjunction of Tishri of YEAR+3761." (let ((interval (add-hebrew-calendar-intervals hebrew-calendar-epoch (multiply-hebrew-calendar-interval hebrew-calendar-cycle (hebrew-calendar-cycles year)) (multiply-hebrew-calendar-interval hebrew-calendar-regular-year (prior-regular-years-in-hebrew-calendar-cycle year)) (multiply-hebrew-calendar-interval hebrew-calendar-leap-year (prior-leap-years-in-hebrew-calendar-cycle year))))) interval)) (defun hebrew-calendar-new-year-day (year) "Absolute date of 1 Tishri (Rosh Hashanah) of YEAR+3761." (let* ((m (hebrew-calendar-new-year-mean-conjunction year)) (day (extract-hebrew-calendar-days m)) (hour (extract-hebrew-calendar-hours m)) (part (extract-hebrew-calendar-parts m)) ;; Take into account any delay. (day1 (if (or (>= hour 18) (and (= (% day 7) 2) (not (hebrew-calendar-leap-year-p year)) (or (> hour 9) (and (= hour 9) (>= part 204)))) (and (= (% day 7) 1) (hebrew-calendar-leap-year-p (1- year)) (or (> hour 15) (and (= hour 15) (>= part 589))))) (1+ day) day))) (if (memq (% day1 7) (list 0 3 5)) (1+ day1) day1))) (defun hebrew-calendar-leap-year-p (year) "Returns t if YEAR+3761 is a leap year." (memq (years-into-hebrew-calendar-cycle year) (list 0 3 6 8 11 14 17))) (defun hebrew-calendar-long-heshvan-p (year) "Returns t if Heshvan is long in YEAR+3761." (if (hebrew-calendar-leap-year-p year) (= (- (hebrew-calendar-new-year-day (1+ year)) (hebrew-calendar-new-year-day year)) 385) (= (- (hebrew-calendar-new-year-day (1+ year)) (hebrew-calendar-new-year-day year)) 355))) (defun hebrew-calendar-short-kislev-p (year) "Returns t if Kislev is short in YEAR+3761." (if (hebrew-calendar-leap-year-p year) (= (- (hebrew-calendar-new-year-day (1+ year)) (hebrew-calendar-new-year-day year)) 383) (= (- (hebrew-calendar-new-year-day (1+ year)) (hebrew-calendar-new-year-day year)) 353))) (defun hebrew-calendar-last-day-of-month (month year) "The last day of MONTH in YEAR+3761." (if (or (memq month (list 2 4 6 10 13)) (and (= month 12) (not (hebrew-calendar-leap-year-p year))) (and (= month 8) (not (hebrew-calendar-long-heshvan-p year))) (and (= month 9) (hebrew-calendar-short-kislev-p year))) 29 30)) (defun hebrew-calendar-date-beyond-date (days month year) "Returns the Hebrew date that is DAYS beyond the start of MONTH, YEAR+3761. That date must be in the same year." (let ((len (hebrew-calendar-last-day-of-month month year))) (while (> days len) (setq days (- days len)) (setq month (1+ (% month (hebrew-calendar-last-month-of-year year)))) (setq len (hebrew-calendar-last-day-of-month month year)))) (list days month year)) (defun hebrew-calendar-days-from-tishri (days month year) "Number of days, inclusive, from 1 Tishri to DAYS, MONTH, YEAR+3761." (while (/= month 7) (setq month (if (= month 1) (hebrew-calendar-last-month-of-year year) (1- month))) (setq days (+ days (hebrew-calendar-last-day-of-month month year)))) days) (defun hebrew-calendar-year-length (year) "The number of days in Hebrew calendar YEAR+3761." (- (hebrew-calendar-new-year-day year) (hebrew-calendar-new-year-day (1- year)))) (defun hebrew-calendar-last-month-of-year (year) "The last month of the Hebrew calendar YEAR+3761." (if (hebrew-calendar-leap-year-p year) 13 12)) (defun calendar-absolute-from-hebrew (date) "Absolute date of Hebrew DATE. The absolute date is the number of days elapsed since the (imaginary) Gregorian date Sunday, December 31, 1 BC." (let ((month (extract-calendar-month date)) (day (extract-calendar-day date)) (year (- (extract-calendar-year date) 3761))) (+ -1 (hebrew-calendar-new-year-day year) (hebrew-calendar-days-from-tishri day month year)))) ------------------------------------------------------------------------ /jr jr@bbn.com or bbn!jr C'mon big money!