annotate lisp/calendar/cal-islam.el @ 82569:16c43d5ebaaa

Move tree-widget/ from etc/ to etc/images/
author Glenn Morris <rgm@gnu.org>
date Wed, 22 Aug 2007 04:58:31 +0000
parents b98604865ea0
children 0dcd1f3c9909 f55f9811f5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
2
75346
7a3f13e2dd57 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68721
diff changeset
3 ;; Copyright (C) 1995, 1997, 2001, 2002, 2003, 2004, 2005, 2006, 2007
67465
a55ee709ec8d Update copyright pending Emacs 22.
Glenn Morris <rgm@gnu.org>
parents: 65144
diff changeset
4 ;; Free Software Foundation, Inc.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
5
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
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
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
8 ;; Keywords: calendar
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
9 ;; Human-Keywords: Islamic calendar, calendar, diary
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
10
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
12
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
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
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
16 ;; any later version.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
17
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
21 ;; GNU General Public License for more details.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
22
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13053
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62402
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62402
diff changeset
26 ;; Boston, MA 02110-1301, USA.
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
27
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
28 ;;; Commentary:
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
29
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
30 ;; This collection of functions implements the features of calendar.el and
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
31 ;; diary.el that deal with the Islamic calendar.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
32
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 20268
diff changeset
33 ;; Technical details of all the calendrical calculations can be found in
61148
7f7db25577d9 Update reference to "Calendrical Calculations" book; there's a new edition.
Paul Eggert <eggert@twinsun.com>
parents: 54075
diff changeset
34 ;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold
7f7db25577d9 Update reference to "Calendrical Calculations" book; there's a new edition.
Paul Eggert <eggert@twinsun.com>
parents: 54075
diff changeset
35 ;; and Nachum Dershowitz, Cambridge University Press (2001).
20462
d179de7ad92e Add reference to new Calendrical Calculations book.
Paul Eggert <eggert@twinsun.com>
parents: 20268
diff changeset
36
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
37 ;;; Code:
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
38
65144
b3c4cec1dbcd (date, number, original-date): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 64085
diff changeset
39 (defvar date)
52119
226327fe046f (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
40 (defvar displayed-month)
226327fe046f (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
41 (defvar displayed-year)
65144
b3c4cec1dbcd (date, number, original-date): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 64085
diff changeset
42 (defvar number)
b3c4cec1dbcd (date, number, original-date): Add defvars.
Juanma Barranquero <lekktu@gmail.com>
parents: 64085
diff changeset
43 (defvar original-date)
52119
226327fe046f (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
44
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
45 (require 'cal-julian)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
46
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
47 (defvar calendar-islamic-month-name-array
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
48 ["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
49 "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
50 "Array of strings giving the names of the Islamic months.")
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
51
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
52 (defvar calendar-islamic-epoch (calendar-absolute-from-julian '(7 16 622))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
53 "Absolute date of start of Islamic calendar = August 29, 284 A.D. (Julian).")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
54
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
55 (defun islamic-calendar-leap-year-p (year)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
56 "Returns t if YEAR is a leap year on the Islamic calendar."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
57 (memq (% year 30)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
58 (list 2 5 7 10 13 16 18 21 24 26 29)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
59
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
60 (defun islamic-calendar-last-day-of-month (month year)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
61 "The last day in MONTH during YEAR on the Islamic calendar."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
62 (cond
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
63 ((memq month (list 1 3 5 7 9 11)) 30)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
64 ((memq month (list 2 4 6 8 10)) 29)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
65 (t (if (islamic-calendar-leap-year-p year) 30 29))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
66
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
67 (defun islamic-calendar-day-number (date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
68 "Return the day number within the year of the Islamic date DATE."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
69 (let* ((month (extract-calendar-month date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
70 (day (extract-calendar-day date)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
71 (+ (* 30 (/ month 2))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
72 (* 29 (/ (1- month) 2))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
73 day)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
74
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
75 (defun calendar-absolute-from-islamic (date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
76 "Absolute date of Islamic DATE.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
77 The absolute date is the number of days elapsed since the (imaginary)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
78 Gregorian date Sunday, December 31, 1 BC."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
79 (let* ((month (extract-calendar-month date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
80 (day (extract-calendar-day date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
81 (year (extract-calendar-year date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
82 (y (% year 30))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
83 (leap-years-in-cycle
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
84 (cond
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
85 ((< y 3) 0) ((< y 6) 1) ((< y 8) 2) ((< y 11) 3) ((< y 14) 4)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
86 ((< y 17) 5) ((< y 19) 6) ((< y 22) 7) ((< y 25) 8) ((< y 27) 9)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
87 (t 10))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
88 (+ (islamic-calendar-day-number date);; days so far this year
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
89 (* (1- year) 354) ;; days in all non-leap years
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
90 (* 11 (/ year 30)) ;; leap days in complete cycles
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
91 leap-years-in-cycle ;; leap days this cycle
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
92 (1- calendar-islamic-epoch)))) ;; days before start of calendar
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
93
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
94 (defun calendar-islamic-from-absolute (date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
95 "Compute the Islamic date (month day year) corresponding to absolute DATE.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
96 The absolute date is the number of days elapsed since the (imaginary)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
97 Gregorian date Sunday, December 31, 1 BC."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
98 (if (< date calendar-islamic-epoch)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
99 (list 0 0 0);; pre-Islamic date
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
100 (let* ((approx (/ (- date calendar-islamic-epoch)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
101 355));; Approximation from below.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
102 (year ;; Search forward from the approximation.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
103 (+ approx
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
104 (calendar-sum y approx
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
105 (>= date (calendar-absolute-from-islamic
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
106 (list 1 1 (1+ y))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
107 1)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
108 (month ;; Search forward from Muharram.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
109 (1+ (calendar-sum m 1
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
110 (> date
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
111 (calendar-absolute-from-islamic
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
112 (list m
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
113 (islamic-calendar-last-day-of-month
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
114 m year)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
115 year)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
116 1)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
117 (day ;; Calculate the day by subtraction.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
118 (- date
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
119 (1- (calendar-absolute-from-islamic (list month 1 year))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
120 (list month day year))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
121
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
122 (defun calendar-islamic-date-string (&optional date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
123 "String of Islamic date before sunset of Gregorian DATE.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
124 Returns the empty string if DATE is pre-Islamic.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
125 Defaults to today's date if DATE is not given.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
126 Driven by the variable `calendar-date-display-form'."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
127 (let ((calendar-month-name-array calendar-islamic-month-name-array)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
128 (islamic-date (calendar-islamic-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
129 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
130 (or date (calendar-current-date))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
131 (if (< (extract-calendar-year islamic-date) 1)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
132 ""
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
133 (calendar-date-string islamic-date nil t))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
134
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
135 (defun calendar-print-islamic-date ()
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
136 "Show the Islamic calendar equivalent of the date under the cursor."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
137 (interactive)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
138 (let ((i (calendar-islamic-date-string (calendar-cursor-to-date t))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
139 (if (string-equal i "")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
140 (message "Date is pre-Islamic")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
141 (message "Islamic date (until sunset): %s" i))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
142
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
143 (defun calendar-goto-islamic-date (date &optional noecho)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
144 "Move cursor to Islamic DATE; echo Islamic date unless NOECHO is t."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
145 (interactive
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
146 (let* ((today (calendar-current-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
147 (year (calendar-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
148 "Islamic calendar year (>0): "
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
149 '(lambda (x) (> x 0))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
150 (int-to-string
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
151 (extract-calendar-year
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
152 (calendar-islamic-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
153 (calendar-absolute-from-gregorian today))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
154 (month-array calendar-islamic-month-name-array)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
155 (completion-ignore-case t)
54075
5c162955af7a (calendar-goto-islamic-date, mark-islamic-diary-entries): Use
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
156 (month (cdr (assoc-string
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
157 (completing-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
158 "Islamic calendar month name: "
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
159 (mapcar 'list (append month-array nil))
24184
5b4ebdd66a82 (calendar-goto-islamic-date)
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
160 nil t)
54075
5c162955af7a (calendar-goto-islamic-date, mark-islamic-diary-entries): Use
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
161 (calendar-make-alist month-array 1) t)))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
162 (last (islamic-calendar-last-day-of-month month year))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
163 (day (calendar-read
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
164 (format "Islamic calendar day (1-%d): " last)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
165 '(lambda (x) (and (< 0 x) (<= x last))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
166 (list (list month day year))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
167 (calendar-goto-date (calendar-gregorian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
168 (calendar-absolute-from-islamic date)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
169 (or noecho (calendar-print-islamic-date)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
170
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
171 (defun diary-islamic-date ()
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
172 "Islamic calendar equivalent of date diary entry."
17384
d7471b786af3 (diary-islamic-date): Use `date'.
Richard M. Stallman <rms@gnu.org>
parents: 14684
diff changeset
173 (let ((i (calendar-islamic-date-string date)))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
174 (if (string-equal i "")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
175 "Date is pre-Islamic"
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
176 (format "Islamic date (until sunset): %s" i))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
177
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
178 (defun holiday-islamic (month day string)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
179 "Holiday on MONTH, DAY (Islamic) called STRING.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
180 If MONTH, DAY (Islamic) is visible, the value returned is corresponding
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
181 Gregorian date in the form of the list (((month day year) STRING)). Returns
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
182 nil if it is not visible in the current calendar window."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
183 (let* ((islamic-date (calendar-islamic-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
184 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
185 (list displayed-month 15 displayed-year))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
186 (m (extract-calendar-month islamic-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
187 (y (extract-calendar-year islamic-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
188 (date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
189 (if (< m 1)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
190 nil;; Islamic calendar doesn't apply.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
191 (increment-calendar-month m y (- 10 month))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
192 (if (> m 7);; Islamic date might be visible
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
193 (let ((date (calendar-gregorian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
194 (calendar-absolute-from-islamic (list month day y)))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
195 (if (calendar-date-is-visible-p date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
196 (list (list date string))))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
197
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
198 (defun list-islamic-diary-entries ()
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
199 "Add any Islamic date entries from the diary file to `diary-entries-list'.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
200 Islamic date diary entries must be prefaced by an `islamic-diary-entry-symbol'
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
201 \(normally an `I'). The same diary date forms govern the style of the Islamic
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
202 calendar entries, except that the Islamic month names must be spelled in full.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
203 The Islamic months are numbered from 1 to 12 with Muharram being 1 and 12 being
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
204 Dhu al-Hijjah. If an Islamic date diary entry begins with a
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
205 `diary-nonmarking-symbol', the entry will appear in the diary listing, but will
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
206 not be marked in the calendar. This function is provided for use with the
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
207 `nongregorian-diary-listing-hook'."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
208 (if (< 0 number)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
209 (let ((buffer-read-only nil)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
210 (diary-modified (buffer-modified-p))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
211 (gdate original-date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
212 (mark (regexp-quote diary-nonmarking-symbol)))
82083
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
213 (dotimes (idummy number)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
214 (let* ((d diary-date-forms)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
215 (idate (calendar-islamic-from-absolute
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
216 (calendar-absolute-from-gregorian gdate)))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
217 (month (extract-calendar-month idate))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
218 (day (extract-calendar-day idate))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
219 (year (extract-calendar-year idate)))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
220 (while d
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
221 (let*
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
222 ((date-form (if (equal (car (car d)) 'backup)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
223 (cdr (car d))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
224 (car d)))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
225 (backup (equal (car (car d)) 'backup))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
226 (dayname
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
227 (format "%s\\|%s\\.?"
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
228 (calendar-day-name gdate)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
229 (calendar-day-name gdate 'abbrev)))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
230 (calendar-month-name-array
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
231 calendar-islamic-month-name-array)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
232 (monthname
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
233 (concat
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
234 "\\*\\|"
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
235 (calendar-month-name month)))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
236 (month (concat "\\*\\|0*" (int-to-string month)))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
237 (day (concat "\\*\\|0*" (int-to-string day)))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
238 (year
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
239 (concat
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
240 "\\*\\|0*" (int-to-string year)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
241 (if abbreviated-calendar-year
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
242 (concat "\\|" (int-to-string (% year 100)))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
243 "")))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
244 (regexp
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
245 (concat
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
246 "\\(\\`\\|\^M\\|\n\\)" mark "?"
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
247 (regexp-quote islamic-diary-entry-symbol)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
248 "\\("
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
249 (mapconcat 'eval date-form "\\)\\(")
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
250 "\\)"))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
251 (case-fold-search t))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
252 (goto-char (point-min))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
253 (while (re-search-forward regexp nil t)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
254 (if backup (re-search-backward "\\<" nil t))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
255 (if (and (or (char-equal (preceding-char) ?\^M)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
256 (char-equal (preceding-char) ?\n))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
257 (not (looking-at " \\|\^I")))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
258 ;; Diary entry that consists only of date.
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
259 (backward-char 1)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
260 ;; Found a nonempty diary entry--make it visible and
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
261 ;; add it to the list.
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
262 (let ((entry-start (point))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
263 (date-start))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
264 (re-search-backward "\^M\\|\n\\|\\`")
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
265 (setq date-start (point))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
266 (re-search-forward "\^M\\|\n" nil t 2)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
267 (while (looking-at " \\|\^I")
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
268 (re-search-forward "\^M\\|\n" nil t))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
269 (backward-char 1)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
270 (subst-char-in-region date-start (point) ?\^M ?\n t)
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
271 (add-to-diary-list
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
272 gdate
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
273 (buffer-substring-no-properties entry-start (point))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
274 (buffer-substring-no-properties
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
275 (1+ date-start) (1- entry-start))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
276 (copy-marker entry-start))))))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
277 (setq d (cdr d))))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
278 (setq gdate
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
279 (calendar-gregorian-from-absolute
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
280 (1+ (calendar-absolute-from-gregorian gdate)))))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
281 (set-buffer-modified-p diary-modified))
c2109b15d473 (list-islamic-diary-entries): Use dotimes rather than
Glenn Morris <rgm@gnu.org>
parents: 77279
diff changeset
282 (goto-char (point-min))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
283
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
284 (defun mark-islamic-diary-entries ()
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
285 "Mark days in the calendar window that have Islamic date diary entries.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
286 Each entry in diary-file (or included files) visible in the calendar window
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
287 is marked. Islamic date entries are prefaced by a islamic-diary-entry-symbol
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
288 \(normally an `I'). The same diary-date-forms govern the style of the Islamic
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
289 calendar entries, except that the Islamic month names must be spelled in full.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
290 The Islamic months are numbered from 1 to 12 with Muharram being 1 and 12 being
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
291 Dhu al-Hijjah. Islamic date diary entries that begin with a
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
292 diary-nonmarking-symbol will not be marked in the calendar. This function is
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
293 provided for use as part of the nongregorian-diary-marking-hook."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
294 (let ((d diary-date-forms))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
295 (while d
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
296 (let*
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
297 ((date-form (if (equal (car (car d)) 'backup)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
298 (cdr (car d))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
299 (car d)));; ignore 'backup directive
52119
226327fe046f (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
300 (dayname (diary-name-pattern calendar-day-name-array
226327fe046f (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
301 calendar-day-abbrev-array))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
302 (monthname
52119
226327fe046f (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
303 (format "%s\\|\\*"
226327fe046f (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
304 (diary-name-pattern calendar-islamic-month-name-array)))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
305 (month "[0-9]+\\|\\*")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
306 (day "[0-9]+\\|\\*")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
307 (year "[0-9]+\\|\\*")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
308 (l (length date-form))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
309 (d-name-pos (- l (length (memq 'dayname date-form))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
310 (d-name-pos (if (/= l d-name-pos) (+ 2 d-name-pos)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
311 (m-name-pos (- l (length (memq 'monthname date-form))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
312 (m-name-pos (if (/= l m-name-pos) (+ 2 m-name-pos)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
313 (d-pos (- l (length (memq 'day date-form))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
314 (d-pos (if (/= l d-pos) (+ 2 d-pos)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
315 (m-pos (- l (length (memq 'month date-form))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
316 (m-pos (if (/= l m-pos) (+ 2 m-pos)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
317 (y-pos (- l (length (memq 'year date-form))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
318 (y-pos (if (/= l y-pos) (+ 2 y-pos)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
319 (regexp
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
320 (concat
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
321 "\\(\\`\\|\^M\\|\n\\)"
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
322 (regexp-quote islamic-diary-entry-symbol)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
323 "\\("
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
324 (mapconcat 'eval date-form "\\)\\(")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
325 "\\)"))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
326 (case-fold-search t))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
327 (goto-char (point-min))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
328 (while (re-search-forward regexp nil t)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
329 (let* ((dd-name
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
330 (if d-name-pos
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
331 (buffer-substring
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
332 (match-beginning d-name-pos)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
333 (match-end d-name-pos))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
334 (mm-name
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
335 (if m-name-pos
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
336 (buffer-substring
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
337 (match-beginning m-name-pos)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
338 (match-end m-name-pos))))
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 61148
diff changeset
339 (mm (string-to-number
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
340 (if m-pos
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
341 (buffer-substring
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
342 (match-beginning m-pos)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
343 (match-end m-pos))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
344 "")))
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 61148
diff changeset
345 (dd (string-to-number
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
346 (if d-pos
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
347 (buffer-substring
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
348 (match-beginning d-pos)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
349 (match-end d-pos))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
350 "")))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
351 (y-str (if y-pos
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
352 (buffer-substring
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
353 (match-beginning y-pos)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
354 (match-end y-pos))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
355 (yy (if (not y-str)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
356 0
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
357 (if (and (= (length y-str) 2)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
358 abbreviated-calendar-year)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
359 (let* ((current-y
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
360 (extract-calendar-year
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
361 (calendar-islamic-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
362 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
363 (calendar-current-date)))))
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 61148
diff changeset
364 (y (+ (string-to-number y-str)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
365 (* 100 (/ current-y 100)))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
366 (if (> (- y current-y) 50)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
367 (- y 100)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
368 (if (> (- current-y y) 50)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
369 (+ y 100)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
370 y)))
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 61148
diff changeset
371 (string-to-number y-str)))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
372 (if dd-name
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
373 (mark-calendar-days-named
54075
5c162955af7a (calendar-goto-islamic-date, mark-islamic-diary-entries): Use
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
374 (cdr (assoc-string dd-name
24184
5b4ebdd66a82 (calendar-goto-islamic-date)
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
375 (calendar-make-alist
5b4ebdd66a82 (calendar-goto-islamic-date)
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
376 calendar-day-name-array
54075
5c162955af7a (calendar-goto-islamic-date, mark-islamic-diary-entries): Use
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
377 0 nil calendar-day-abbrev-array) t)))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
378 (if mm-name
52119
226327fe046f (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
379 (setq mm (if (string-equal mm-name "*") 0
54075
5c162955af7a (calendar-goto-islamic-date, mark-islamic-diary-entries): Use
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
380 (cdr (assoc-string
52119
226327fe046f (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
381 mm-name
226327fe046f (displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents: 49598
diff changeset
382 (calendar-make-alist
54075
5c162955af7a (calendar-goto-islamic-date, mark-islamic-diary-entries): Use
Glenn Morris <rgm@gnu.org>
parents: 52401
diff changeset
383 calendar-islamic-month-name-array) t)))))
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
384 (mark-islamic-calendar-date-pattern mm dd yy)))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
385 (setq d (cdr d)))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
386
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
387 (defun mark-islamic-calendar-date-pattern (month day year)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
388 "Mark dates in calendar window that conform to Islamic date MONTH/DAY/YEAR.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
389 A value of 0 in any position is a wildcard."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
390 (save-excursion
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
391 (set-buffer calendar-buffer)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
392 (if (and (/= 0 month) (/= 0 day))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
393 (if (/= 0 year)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
394 ;; Fully specified Islamic date.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
395 (let ((date (calendar-gregorian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
396 (calendar-absolute-from-islamic
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
397 (list month day year)))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
398 (if (calendar-date-is-visible-p date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
399 (mark-visible-calendar-date date)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
400 ;; Month and day in any year--this taken from the holiday stuff.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
401 (let* ((islamic-date (calendar-islamic-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
402 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
403 (list displayed-month 15 displayed-year))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
404 (m (extract-calendar-month islamic-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
405 (y (extract-calendar-year islamic-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
406 (date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
407 (if (< m 1)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
408 nil;; Islamic calendar doesn't apply.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
409 (increment-calendar-month m y (- 10 month))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
410 (if (> m 7);; Islamic date might be visible
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
411 (let ((date (calendar-gregorian-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
412 (calendar-absolute-from-islamic
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
413 (list month day y)))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
414 (if (calendar-date-is-visible-p date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
415 (mark-visible-calendar-date date)))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
416 ;; Not one of the simple cases--check all visible dates for match.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
417 ;; Actually, the following code takes care of ALL of the cases, but
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
418 ;; it's much too slow to be used for the simple (common) cases.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
419 (let ((m displayed-month)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
420 (y displayed-year)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
421 (first-date)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
422 (last-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
423 (increment-calendar-month m y -1)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
424 (setq first-date
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
425 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
426 (list m 1 y)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
427 (increment-calendar-month m y 2)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
428 (setq last-date
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
429 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
430 (list m (calendar-last-day-of-month m y) y)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
431 (calendar-for-loop date from first-date to last-date do
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
432 (let* ((i-date (calendar-islamic-from-absolute date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
433 (i-month (extract-calendar-month i-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
434 (i-day (extract-calendar-day i-date))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
435 (i-year (extract-calendar-year i-date)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
436 (and (or (zerop month)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
437 (= month i-month))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
438 (or (zerop day)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
439 (= day i-day))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
440 (or (zerop year)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
441 (= year i-year))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
442 (mark-visible-calendar-date
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
443 (calendar-gregorian-from-absolute date)))))))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
444
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
445 (defun insert-islamic-diary-entry (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
446 "Insert a diary entry.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
447 For the Islamic date corresponding to the date indicated by point.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
448 Prefix arg will make the entry nonmarking."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
449 (interactive "P")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
450 (let* ((calendar-month-name-array calendar-islamic-month-name-array))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
451 (make-diary-entry
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
452 (concat
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
453 islamic-diary-entry-symbol
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 38449
diff changeset
454 (calendar-date-string
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
455 (calendar-islamic-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
456 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
457 (calendar-cursor-to-date t)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
458 nil t))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
459 arg)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
460
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
461 (defun insert-monthly-islamic-diary-entry (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
462 "Insert a monthly diary entry.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
463 For the day of the Islamic month corresponding to the date indicated by point.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
464 Prefix arg will make the entry nonmarking."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
465 (interactive "P")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
466 (let* ((calendar-date-display-form
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
467 (if european-calendar-style '(day " * ") '("* " day )))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
468 (calendar-month-name-array calendar-islamic-month-name-array))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
469 (make-diary-entry
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
470 (concat
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
471 islamic-diary-entry-symbol
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 38449
diff changeset
472 (calendar-date-string
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
473 (calendar-islamic-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
474 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
475 (calendar-cursor-to-date t)))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
476 arg)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
477
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
478 (defun insert-yearly-islamic-diary-entry (arg)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
479 "Insert an annual diary entry.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
480 For the day of the Islamic year corresponding to the date indicated by point.
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
481 Prefix arg will make the entry nonmarking."
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
482 (interactive "P")
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
483 (let* ((calendar-date-display-form
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
484 (if european-calendar-style
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
485 '(day " " monthname)
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
486 '(monthname " " day)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
487 (calendar-month-name-array calendar-islamic-month-name-array))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
488 (make-diary-entry
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
489 (concat
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
490 islamic-diary-entry-symbol
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 38449
diff changeset
491 (calendar-date-string
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
492 (calendar-islamic-from-absolute
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
493 (calendar-absolute-from-gregorian
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
494 (calendar-cursor-to-date t)))))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
495 arg)))
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
496
14684
66450c507ee4 Renamed from cal-islamic.el to avoid 14-character limitation.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
497 (provide 'cal-islam)
13053
621d48117fde Initial revision
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
diff changeset
498
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 52119
diff changeset
499 ;;; 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
500 ;;; cal-islam.el ends here