Mercurial > emacs
comparison lisp/calendar/cal-islam.el @ 93462:263786b8fe73
(Commentary): Replace with reference to calendar.el.
(holiday-islamic): Comments. Remove un-needed let. Use and.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Mon, 31 Mar 2008 15:37:52 +0000 |
parents | 6facf919dde4 |
children | 31158dd82f24 |
comparison
equal
deleted
inserted
replaced
93461:3afeea9a48a3 | 93462:263786b8fe73 |
---|---|
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | 26 ;; Boston, MA 02110-1301, USA. |
27 | 27 |
28 ;;; Commentary: | 28 ;;; Commentary: |
29 | 29 |
30 ;; This collection of functions implements the features of calendar.el and | 30 ;; See calendar.el. |
31 ;; diary.el that deal with the Islamic calendar. | |
32 | |
33 ;; Technical details of all the calendrical calculations can be found in | |
34 ;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold | |
35 ;; and Nachum Dershowitz, Cambridge University Press (2001). | |
36 | 31 |
37 ;;; Code: | 32 ;;; Code: |
38 | 33 |
39 (require 'calendar) | 34 (require 'calendar) |
40 | 35 |
185 (defun holiday-islamic (month day string) | 180 (defun holiday-islamic (month day string) |
186 "Holiday on MONTH, DAY (Islamic) called STRING. | 181 "Holiday on MONTH, DAY (Islamic) called STRING. |
187 If MONTH, DAY (Islamic) is visible, the value returned is corresponding | 182 If MONTH, DAY (Islamic) is visible, the value returned is corresponding |
188 Gregorian date in the form of the list (((month day year) STRING)). Returns | 183 Gregorian date in the form of the list (((month day year) STRING)). Returns |
189 nil if it is not visible in the current calendar window." | 184 nil if it is not visible in the current calendar window." |
185 ;; Islamic date corresponding to the center of the calendar window. | |
186 ;; Since the calendar displays 3 months at a time, there are approx | |
187 ;; 45 visible days either side of this date. Given the length of | |
188 ;; the Islamic months, this means up to two different months are | |
189 ;; visible either side of the central date. | |
190 (let* ((islamic-date (calendar-islamic-from-absolute | 190 (let* ((islamic-date (calendar-islamic-from-absolute |
191 (calendar-absolute-from-gregorian | 191 (calendar-absolute-from-gregorian |
192 (list displayed-month 15 displayed-year)))) | 192 (list displayed-month 15 displayed-year)))) |
193 (m (extract-calendar-month islamic-date)) | 193 (m (extract-calendar-month islamic-date)) |
194 (y (extract-calendar-year islamic-date)) | 194 (y (extract-calendar-year islamic-date)) |
195 date) | 195 date) |
196 (unless (< m 1) ; Islamic calendar doesn't apply | 196 (unless (< m 1) ; Islamic calendar doesn't apply |
197 ;; Since converting to absolute dates can be a complex | |
198 ;; operation, we try to speed things up by excluding those date | |
199 ;; ranges that can't possibly be visible. | |
200 ;; We can view the situation (see above) as if we had a calendar | |
201 ;; window displaying 5 months at a time. When month m is | |
202 ;; central, months m-2:m+2 (modulo 12) might be visible. | |
203 ;; Recall from holiday-fixed that with a 3 month calendar | |
204 ;; window, November is special, because we can do a one-sided | |
205 ;; inclusion test. When November is central is when the end of | |
206 ;; year first appears on the calendar. Similarly, with a 5 | |
207 ;; month window, October is special. When October is central is | |
208 ;; when the end of year first appears, and when January is | |
209 ;; central, October is no longer visible. October is visible | |
210 ;; when the central month is >= 8. | |
211 ;; Hence to test if any given month might be visible, we can | |
212 ;; shift things and ask about October. | |
213 ;; At the same time, we work out the appropriate year y to use. | |
197 (increment-calendar-month m y (- 10 month)) | 214 (increment-calendar-month m y (- 10 month)) |
198 (if (> m 7) ; Islamic date might be visible | 215 (and (> m 7) ; Islamic date might be visible |
199 (let ((date (calendar-gregorian-from-absolute | 216 (calendar-date-is-visible-p |
200 (calendar-absolute-from-islamic (list month day y))))) | 217 (setq date (calendar-gregorian-from-absolute |
201 (if (calendar-date-is-visible-p date) | 218 (calendar-absolute-from-islamic (list month day y))))) |
202 (list (list date string)))))))) | 219 (list (list date string)))))) |
203 | 220 |
204 (autoload 'diary-list-entries-1 "diary-lib") | 221 (autoload 'diary-list-entries-1 "diary-lib") |
205 | 222 |
206 ;;;###diary-autoload | 223 ;;;###diary-autoload |
207 (defun list-islamic-diary-entries () | 224 (defun list-islamic-diary-entries () |