Mercurial > emacs
annotate lisp/calendar/cal-islam.el @ 93480:2aa65ff3876d
(Commentary): Point to calendar.el.
(calendar-goto-french-date): Reduce nesting of some lets.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Tue, 01 Apr 2008 02:40:36 +0000 |
parents | 31158dd82f24 |
children | bac2b63b476f |
rev | line source |
---|---|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38402
diff
changeset
|
1 ;;; cal-islam.el --- calendar functions for the Islamic calendar |
13053 | 2 |
92610
6f4bd17c2adc
(mark-islamic-calendar-date-pattern): Use zerop.
Glenn Morris <rgm@gnu.org>
parents:
92585
diff
changeset
|
3 ;; Copyright (C) 1995, 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
6f4bd17c2adc
(mark-islamic-calendar-date-pattern): Use zerop.
Glenn Morris <rgm@gnu.org>
parents:
92585
diff
changeset
|
4 ;; 2008 Free Software Foundation, Inc. |
13053 | 5 |
6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> | |
67465
a55ee709ec8d
Update copyright pending Emacs 22.
Glenn Morris <rgm@gnu.org>
parents:
65144
diff
changeset
|
7 ;; Maintainer: Glenn Morris <rgm@gnu.org> |
13053 | 8 ;; Keywords: calendar |
9 ;; Human-Keywords: Islamic calendar, calendar, diary | |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
78216
93e11478c954
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
77279
diff
changeset
|
15 ;; the Free Software Foundation; either version 3, or (at your option) |
13053 | 16 ;; any later version. |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
14169 | 24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
13053 | 27 |
28 ;;; Commentary: | |
29 | |
93462
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
30 ;; See calendar.el. |
20462
d179de7ad92e
Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents:
20268
diff
changeset
|
31 |
13053 | 32 ;;; Code: |
33 | |
93223
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
34 (require 'calendar) |
13053 | 35 |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
36 (defconst calendar-islamic-month-name-array |
13053 | 37 ["Muharram" "Safar" "Rabi I" "Rabi II" "Jumada I" "Jumada II" |
52119
226327fe046f
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
38 "Rajab" "Sha'ban" "Ramadan" "Shawwal" "Dhu al-Qada" "Dhu al-Hijjah"] |
226327fe046f
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
39 "Array of strings giving the names of the Islamic months.") |
13053 | 40 |
93223
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
41 (eval-and-compile |
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
42 (autoload 'calendar-absolute-from-julian "cal-julian")) |
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
43 |
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
44 (defconst calendar-islamic-epoch |
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
45 (eval-when-compile (calendar-absolute-from-julian '(7 16 622))) |
9aca848375df
Require calendar rather than cal-julian.
Glenn Morris <rgm@gnu.org>
parents:
93184
diff
changeset
|
46 "Absolute date of start of Islamic calendar = July 16, 622 AD (Julian).") |
13053 | 47 |
48 (defun islamic-calendar-leap-year-p (year) | |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
49 "Return t if YEAR is a leap year on the Islamic calendar." |
13053 | 50 (memq (% year 30) |
51 (list 2 5 7 10 13 16 18 21 24 26 29))) | |
52 | |
53 (defun islamic-calendar-last-day-of-month (month year) | |
54 "The last day in MONTH during YEAR on the Islamic calendar." | |
55 (cond | |
56 ((memq month (list 1 3 5 7 9 11)) 30) | |
57 ((memq month (list 2 4 6 8 10)) 29) | |
58 (t (if (islamic-calendar-leap-year-p year) 30 29)))) | |
59 | |
60 (defun islamic-calendar-day-number (date) | |
61 "Return the day number within the year of the Islamic date DATE." | |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
62 (let ((month (extract-calendar-month date))) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
63 (+ (* 30 (/ month 2)) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
64 (* 29 (/ (1- month) 2)) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
65 (extract-calendar-day date)))) |
13053 | 66 |
67 (defun calendar-absolute-from-islamic (date) | |
68 "Absolute date of Islamic DATE. | |
69 The absolute date is the number of days elapsed since the (imaginary) | |
70 Gregorian date Sunday, December 31, 1 BC." | |
71 (let* ((month (extract-calendar-month date)) | |
72 (day (extract-calendar-day date)) | |
73 (year (extract-calendar-year date)) | |
74 (y (% year 30)) | |
92991
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
75 (leap-years-in-cycle (cond ((< y 3) 0) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
76 ((< y 6) 1) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
77 ((< y 8) 2) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
78 ((< y 11) 3) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
79 ((< y 14) 4) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
80 ((< y 17) 5) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
81 ((< y 19) 6) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
82 ((< y 22) 7) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
83 ((< y 25) 8) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
84 ((< y 27) 9) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
85 (t 10)))) |
92644 | 86 (+ (islamic-calendar-day-number date) ; days so far this year |
87 (* (1- year) 354) ; days in all non-leap years | |
88 (* 11 (/ year 30)) ; leap days in complete cycles | |
89 leap-years-in-cycle ; leap days this cycle | |
90 (1- calendar-islamic-epoch)))) ; days before start of calendar | |
13053 | 91 |
92 (defun calendar-islamic-from-absolute (date) | |
93 "Compute the Islamic date (month day year) corresponding to absolute DATE. | |
94 The absolute date is the number of days elapsed since the (imaginary) | |
95 Gregorian date Sunday, December 31, 1 BC." | |
96 (if (< date calendar-islamic-epoch) | |
92644 | 97 (list 0 0 0) ; pre-Islamic date |
13053 | 98 (let* ((approx (/ (- date calendar-islamic-epoch) |
92644 | 99 355)) ; approximation from below |
100 (year ; search forward from the approximation | |
13053 | 101 (+ approx |
102 (calendar-sum y approx | |
103 (>= date (calendar-absolute-from-islamic | |
104 (list 1 1 (1+ y)))) | |
105 1))) | |
92644 | 106 (month ; search forward from Muharram |
13053 | 107 (1+ (calendar-sum m 1 |
108 (> date | |
109 (calendar-absolute-from-islamic | |
110 (list m | |
111 (islamic-calendar-last-day-of-month | |
112 m year) | |
113 year))) | |
114 1))) | |
92644 | 115 (day ; calculate the day by subtraction |
13053 | 116 (- date |
117 (1- (calendar-absolute-from-islamic (list month 1 year)))))) | |
118 (list month day year)))) | |
119 | |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
120 ;;;###cal-autoload |
13053 | 121 (defun calendar-islamic-date-string (&optional date) |
122 "String of Islamic date before sunset of Gregorian DATE. | |
123 Returns the empty string if DATE is pre-Islamic. | |
124 Defaults to today's date if DATE is not given. | |
125 Driven by the variable `calendar-date-display-form'." | |
126 (let ((calendar-month-name-array calendar-islamic-month-name-array) | |
127 (islamic-date (calendar-islamic-from-absolute | |
128 (calendar-absolute-from-gregorian | |
129 (or date (calendar-current-date)))))) | |
130 (if (< (extract-calendar-year islamic-date) 1) | |
131 "" | |
132 (calendar-date-string islamic-date nil t)))) | |
133 | |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
134 ;;;###cal-autoload |
13053 | 135 (defun calendar-print-islamic-date () |
136 "Show the Islamic calendar equivalent of the date under the cursor." | |
137 (interactive) | |
138 (let ((i (calendar-islamic-date-string (calendar-cursor-to-date t)))) | |
139 (if (string-equal i "") | |
140 (message "Date is pre-Islamic") | |
141 (message "Islamic date (until sunset): %s" i)))) | |
142 | |
93184
63a7509590a7
(calendar-islamic-read-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92991
diff
changeset
|
143 (defun calendar-islamic-read-date () |
63a7509590a7
(calendar-islamic-read-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92991
diff
changeset
|
144 "Interactively read the arguments for an Islamic date command. |
63a7509590a7
(calendar-islamic-read-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92991
diff
changeset
|
145 Reads a year, month, and day." |
92991
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
146 (let* ((today (calendar-current-date)) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
147 (year (calendar-read |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
148 "Islamic calendar year (>0): " |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
149 (lambda (x) (> x 0)) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
150 (int-to-string |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
151 (extract-calendar-year |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
152 (calendar-islamic-from-absolute |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
153 (calendar-absolute-from-gregorian today)))))) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
154 (month-array calendar-islamic-month-name-array) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
155 (completion-ignore-case t) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
156 (month (cdr (assoc-string |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
157 (completing-read |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
158 "Islamic calendar month name: " |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
159 (mapcar 'list (append month-array nil)) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
160 nil t) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
161 (calendar-make-alist month-array 1) t))) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
162 (last (islamic-calendar-last-day-of-month month year)) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
163 (day (calendar-read |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
164 (format "Islamic calendar day (1-%d): " last) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
165 (lambda (x) (and (< 0 x) (<= x last)))))) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
166 (list (list month day year)))) |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
167 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
168 ;;;###cal-autoload |
13053 | 169 (defun calendar-goto-islamic-date (date &optional noecho) |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
170 "Move cursor to Islamic DATE; echo Islamic date unless NOECHO is non-nil." |
93184
63a7509590a7
(calendar-islamic-read-date): New name for
Glenn Morris <rgm@gnu.org>
parents:
92991
diff
changeset
|
171 (interactive (calendar-islamic-read-date)) |
13053 | 172 (calendar-goto-date (calendar-gregorian-from-absolute |
173 (calendar-absolute-from-islamic date))) | |
174 (or noecho (calendar-print-islamic-date))) | |
175 | |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
176 (defvar displayed-month) ; from generate-calendar |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
177 (defvar displayed-year) |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
178 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
179 ;;;###holiday-autoload |
13053 | 180 (defun holiday-islamic (month day string) |
181 "Holiday on MONTH, DAY (Islamic) called STRING. | |
182 If MONTH, DAY (Islamic) is visible, the value returned is corresponding | |
183 Gregorian date in the form of the list (((month day year) STRING)). Returns | |
184 nil if it is not visible in the current calendar window." | |
93462
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
185 ;; Islamic date corresponding to the center of the calendar window. |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
186 ;; Since the calendar displays 3 months at a time, there are approx |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
187 ;; 45 visible days either side of this date. Given the length of |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
188 ;; the Islamic months, this means up to two different months are |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
189 ;; visible either side of the central date. |
13053 | 190 (let* ((islamic-date (calendar-islamic-from-absolute |
191 (calendar-absolute-from-gregorian | |
192 (list displayed-month 15 displayed-year)))) | |
193 (m (extract-calendar-month islamic-date)) | |
194 (y (extract-calendar-year islamic-date)) | |
93373
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
195 date) |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
196 (unless (< m 1) ; Islamic calendar doesn't apply |
93462
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
197 ;; Since converting to absolute dates can be a complex |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
198 ;; operation, we try to speed things up by excluding those date |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
199 ;; ranges that can't possibly be visible. |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
200 ;; We can view the situation (see above) as if we had a calendar |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
201 ;; window displaying 5 months at a time. When month m is |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
202 ;; central, months m-2:m+2 (modulo 12) might be visible. |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
203 ;; Recall from holiday-fixed that with a 3 month calendar |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
204 ;; window, November is special, because we can do a one-sided |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
205 ;; inclusion test. When November is central is when the end of |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
206 ;; year first appears on the calendar. Similarly, with a 5 |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
207 ;; month window, October is special. When October is central is |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
208 ;; when the end of year first appears, and when January is |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
209 ;; central, October is no longer visible. October is visible |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
210 ;; when the central month is >= 8. |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
211 ;; Hence to test if any given month might be visible, we can |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
212 ;; shift things and ask about October. |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
213 ;; At the same time, we work out the appropriate year y to use. |
13053 | 214 (increment-calendar-month m y (- 10 month)) |
93462
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
215 (and (> m 7) ; Islamic date might be visible |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
216 (calendar-date-is-visible-p |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
217 (setq date (calendar-gregorian-from-absolute |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
218 (calendar-absolute-from-islamic (list month day y))))) |
263786b8fe73
(Commentary): Replace with reference to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93373
diff
changeset
|
219 (list (list date string)))))) |
13053 | 220 |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
221 (autoload 'diary-list-entries-1 "diary-lib") |
92677
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
222 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
223 ;;;###diary-autoload |
13053 | 224 (defun list-islamic-diary-entries () |
225 "Add any Islamic date entries from the diary file to `diary-entries-list'. | |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
226 Islamic date diary entries must be prefaced by `islamic-diary-entry-symbol' |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
227 \(normally an `I'). The same `diary-date-forms' govern the style |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
228 of the Islamic calendar entries, except that the Islamic month |
93268
691804e8889b
(list-islamic-diary-entries): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
93223
diff
changeset
|
229 names cannot be abbreviated. The Islamic months are numbered |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
230 from 1 to 12 with Muharram being 1 and 12 being Dhu al-Hijjah. |
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
231 If an Islamic date diary entry begins with `diary-nonmarking-symbol', |
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
232 the entry will appear in the diary listing, but will not be |
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
233 marked in the calendar. This function is provided for use with |
13053 | 234 `nongregorian-diary-listing-hook'." |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
235 (diary-list-entries-1 calendar-islamic-month-name-array |
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
236 islamic-diary-entry-symbol |
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
237 'calendar-islamic-from-absolute)) |
13053 | 238 |
92991
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
239 (autoload 'calendar-mark-1 "diary-lib") |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
240 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
241 ;;;###diary-autoload |
92991
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
242 (defun mark-islamic-calendar-date-pattern (month day year &optional color) |
13053 | 243 "Mark dates in calendar window that conform to Islamic date MONTH/DAY/YEAR. |
92991
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
244 A value of 0 in any position is a wildcard. Optional argument COLOR is |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
245 passed to `mark-visible-calendar-date' as MARK." |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
246 (calendar-mark-1 month day year 'calendar-islamic-from-absolute |
24a6717aed7f
(calendar-mark-1): Autoload it.
Glenn Morris <rgm@gnu.org>
parents:
92971
diff
changeset
|
247 'calendar-absolute-from-islamic color)) |
13053 | 248 |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
249 (autoload 'diary-mark-entries-1 "diary-lib") |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
250 |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
251 ;;;###diary-autoload |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
252 (defun mark-islamic-diary-entries () |
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
253 "Mark days in the calendar window that have Islamic date diary entries. |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
254 Marks each entry in `diary-file' (or included files) visible in the calendar |
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
255 window. See `list-islamic-diary-entries' for more information." |
93471
31158dd82f24
(mark-islamic-diary-entries): Fix argument order in call to
Glenn Morris <rgm@gnu.org>
parents:
93462
diff
changeset
|
256 (diary-mark-entries-1 'mark-islamic-calendar-date-pattern |
31158dd82f24
(mark-islamic-diary-entries): Fix argument order in call to
Glenn Morris <rgm@gnu.org>
parents:
93462
diff
changeset
|
257 calendar-islamic-month-name-array |
92971
56c7e60586c9
(number, original-date, add-to-diary-list)
Glenn Morris <rgm@gnu.org>
parents:
92926
diff
changeset
|
258 islamic-diary-entry-symbol |
93471
31158dd82f24
(mark-islamic-diary-entries): Fix argument order in call to
Glenn Morris <rgm@gnu.org>
parents:
93462
diff
changeset
|
259 'calendar-islamic-from-absolute)) |
92926
b87a8e95883b
(displayed-month, displayed-year)
Glenn Morris <rgm@gnu.org>
parents:
92832
diff
changeset
|
260 |
93373
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
261 |
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
262 (autoload 'diary-insert-entry-1 "diary-lib") |
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
263 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
264 ;;;###cal-autoload |
13053 | 265 (defun insert-islamic-diary-entry (arg) |
266 "Insert a diary entry. | |
267 For the Islamic date corresponding to the date indicated by point. | |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
268 Prefix argument ARG makes the entry nonmarking." |
13053 | 269 (interactive "P") |
93373
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
270 (diary-insert-entry-1 nil arg calendar-islamic-month-name-array |
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
271 islamic-diary-entry-symbol |
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
272 'calendar-islamic-from-absolute)) |
13053 | 273 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
274 ;;;###cal-autoload |
13053 | 275 (defun insert-monthly-islamic-diary-entry (arg) |
276 "Insert a monthly diary entry. | |
277 For the day of the Islamic month corresponding to the date indicated by point. | |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
278 Prefix argument ARG makes the entry nonmarking." |
13053 | 279 (interactive "P") |
93373
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
280 (diary-insert-entry-1 'monthly arg calendar-islamic-month-name-array |
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
281 islamic-diary-entry-symbol |
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
282 'calendar-islamic-from-absolute)) |
13053 | 283 |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
284 ;;;###cal-autoload |
13053 | 285 (defun insert-yearly-islamic-diary-entry (arg) |
286 "Insert an annual diary entry. | |
287 For the day of the Islamic year corresponding to the date indicated by point. | |
92645
611e312d3f05
(islamic-calendar-leap-year-p)
Glenn Morris <rgm@gnu.org>
parents:
92644
diff
changeset
|
288 Prefix argument ARG makes the entry nonmarking." |
13053 | 289 (interactive "P") |
93373
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
290 (diary-insert-entry-1 'yearly arg calendar-islamic-month-name-array |
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
291 islamic-diary-entry-symbol |
6facf919dde4
Autoload diary-insert-entry-1.
Glenn Morris <rgm@gnu.org>
parents:
93268
diff
changeset
|
292 'calendar-islamic-from-absolute)) |
13053 | 293 |
92677
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
294 (defvar date) |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
295 |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
296 ;; To be called from diary-sexp-entry, where DATE, ENTRY are bound. |
92832
0f2bf92fe13d
(generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents:
92677
diff
changeset
|
297 ;;;###diary-autoload |
92677
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
298 (defun diary-islamic-date () |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
299 "Islamic calendar equivalent of date diary entry." |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
300 (let ((i (calendar-islamic-date-string date))) |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
301 (if (string-equal i "") |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
302 "Date is pre-Islamic" |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
303 (format "Islamic date (until sunset): %s" i)))) |
3f32c597cb6b
(diary-islamic-date): Move to end.
Glenn Morris <rgm@gnu.org>
parents:
92645
diff
changeset
|
304 |
14684
66450c507ee4
Renamed from cal-islamic.el to avoid 14-character limitation.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
305 (provide 'cal-islam) |
13053 | 306 |
92585
c9eb56890fe0
Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents:
87649
diff
changeset
|
307 ;; arch-tag: a951b6c1-6f47-48d5-bac3-1b505cd719f7 |
14684
66450c507ee4
Renamed from cal-islamic.el to avoid 14-character limitation.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
308 ;;; cal-islam.el ends here |