aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-03-31 16:12:53 +0000
committerGlenn Morris2008-03-31 16:12:53 +0000
commitcca1ce4cd728546a26a5803313842bc4d6b63a19 (patch)
treee3e2b72a1132e0556569cde0fcb15cf16c810720
parentc1471ef8c48ceff449548a9f59ccdbb3bf542a62 (diff)
downloademacs-cca1ce4cd728546a26a5803313842bc4d6b63a19.tar.gz
emacs-cca1ce4cd728546a26a5803313842bc4d6b63a19.zip
(holiday-bahai): Use an algorithm actually relevant to this calendar
system.
-rw-r--r--lisp/ChangeLog2
-rw-r--r--lisp/calendar/cal-bahai.el26
2 files changed, 19 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 7481dafc1ed..299111b7ec3 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -40,6 +40,8 @@
40 40
41 * calendar/cal-bahai.el (calendar-bahai-date-string): Avoid an error for 41 * calendar/cal-bahai.el (calendar-bahai-date-string): Avoid an error for
42 pre-Bahai dates. 42 pre-Bahai dates.
43 (holiday-bahai): Use an algorithm actually relevant to this calendar
44 system.
43 45
44 * calendar/cal-china.el (holiday-chinese-new-year): Doc fix. 46 * calendar/cal-china.el (holiday-chinese-new-year): Doc fix.
45 47
diff --git a/lisp/calendar/cal-bahai.el b/lisp/calendar/cal-bahai.el
index f7e552b6b6c..0d302a6c25b 100644
--- a/lisp/calendar/cal-bahai.el
+++ b/lisp/calendar/cal-bahai.el
@@ -195,13 +195,15 @@ Reads a year, month and day."
195(defvar displayed-month) 195(defvar displayed-month)
196(defvar displayed-year) 196(defvar displayed-year)
197 197
198;; FIXME same as islamic.
199;;;###holiday-autoload 198;;;###holiday-autoload
200(defun holiday-bahai (month day string) 199(defun holiday-bahai (month day string)
201 "Holiday on MONTH, DAY (Bahá'í) called STRING. 200 "Holiday on MONTH, DAY (Bahá'í) called STRING.
202If MONTH, DAY (Bahá'í) is visible, the value returned is corresponding 201If MONTH, DAY (Bahá'í) is visible, the value returned is corresponding
203Gregorian date in the form of the list (((month day year) STRING)). Returns 202Gregorian date in the form of the list (((month day year) STRING)). Returns
204nil if it is not visible in the current calendar window." 203nil if it is not visible in the current calendar window."
204 ;; Since the calendar window shows 3 months at a time, there are
205 ;; approx +/- 45 days either side of the central month.
206 ;; Since the Bahai months have 19 days, this means up to +/- 3 months.
205 (let* ((bahai-date (calendar-bahai-from-absolute 207 (let* ((bahai-date (calendar-bahai-from-absolute
206 (calendar-absolute-from-gregorian 208 (calendar-absolute-from-gregorian
207 (list displayed-month 15 displayed-year)))) 209 (list displayed-month 15 displayed-year))))
@@ -209,14 +211,20 @@ nil if it is not visible in the current calendar window."
209 (y (extract-calendar-year bahai-date)) 211 (y (extract-calendar-year bahai-date))
210 date) 212 date)
211 (unless (< m 1) ; Bahá'í calendar doesn't apply 213 (unless (< m 1) ; Bahá'í calendar doesn't apply
212 ;; FIXME makes no sense (?), since there are not 12 months in a year. 214 ;; Cf holiday-fixed, holiday-islamic.
213 ;; Suspect this was copied from cal-islam. 215 ;; With a +- 3 month calendar window, and 19 months per year,
214 (increment-calendar-month m y (- 10 month)) 216 ;; month 16 is special. When m16 is central is when the
215 (if (> m 7) ; Bahá'í date might be visible 217 ;; end-of-year first appears. When m1 is central, m16 is no
216 (let ((date (calendar-gregorian-from-absolute 218 ;; longer visible. Hence we can do a one-sided test to see if
217 (calendar-absolute-from-bahai (list month day y))))) 219 ;; m16 is visible. m16 is visible when the central month >= 13.
218 (if (calendar-date-is-visible-p date) 220 ;; To see if other months are visible we can shift the range
219 (list (list date string)))))))) 221 ;; accordingly.
222 (increment-calendar-month m y (- 16 month) 19)
223 (and (> m 12) ; Bahá'í date might be visible
224 (calendar-date-is-visible-p
225 (setq date (calendar-gregorian-from-absolute
226 (calendar-absolute-from-bahai (list month day y)))))
227 (list (list date string))))))
220 228
221(autoload 'diary-list-entries-1 "diary-lib") 229(autoload 'diary-list-entries-1 "diary-lib")
222 230