Mercurial > emacs
annotate lisp/calendar/cal-french.el @ 13230:ad1d4be6bb8d libc-951018 libc-951029 libc-951031 libc-951101 libc-951102 libc-951103 libc-951104 libc-951105 libc-951106 libc-951107 libc-951108 libc-951109 libc-951110 libc-951111 libc-951112 libc-951113 libc-951114 libc-951115 libc-951116 libc-951117 libc-951118 libc-951119 libc-951120 libc-951121 libc-951122 libc-951123 libc-951124 libc-951125 libc-951126 libc-951127 libc-951128 libc-951129 libc-951130
* config.guess: Recognize HP model 819 machines has having
a PA 1.1 processor.
author | Jeff Law <law@redhat.com> |
---|---|
date | Mon, 16 Oct 1995 15:40:29 +0000 |
parents | 6c21adf788d5 |
children | 83f275dcd93a |
rev | line source |
---|---|
957 | 1 ;;; cal-french.el --- calendar functions for the French Revolutionary calendar. |
2 | |
13048 | 3 ;; Copyright (C) 1988, 1989, 1992, 1994, 1995 Free Software Foundation, Inc. |
957 | 4 |
5 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> | |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1338
diff
changeset
|
6 ;; Keywords: calendar |
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
1338
diff
changeset
|
7 ;; Human-Keywords: French Revolutionary calendar, calendar, diary |
957 | 8 |
9 ;; This file is part of GNU Emacs. | |
10 | |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
14 ;; any later version. |
957 | 15 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
19 ;; GNU General Public License for more details. |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
20 |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5833
diff
changeset
|
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
957 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;; This collection of functions implements the features of calendar.el and | |
28 ;; diary.el that deal with the French Revolutionary calendar. | |
29 | |
7761
b6ac896a491a
Fix typo: Mayan -> French Revolutionary
Paul Eggert <eggert@twinsun.com>
parents:
7639
diff
changeset
|
30 ;; Technical details of the French Revolutionary calendar can be found in |
2945
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
2247
diff
changeset
|
31 ;; ``Calendrical Calculations, Part II: Three Historical Calendars'' |
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
2247
diff
changeset
|
32 ;; by E. M. Reingold, N. Dershowitz, and S. M. Clamen, |
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
2247
diff
changeset
|
33 ;; Software--Practice and Experience, Volume 23, Number 4 (April, 1993), |
2c1f0215fcc3
* holidays.el: Update reference to the papers in S-P&E.
Jim Blandy <jimb@redhat.com>
parents:
2247
diff
changeset
|
34 ;; pages 383-404. |
957 | 35 |
36 ;; Comments, corrections, and improvements should be sent to | |
37 ;; Edward M. Reingold Department of Computer Science | |
38 ;; (217) 333-6733 University of Illinois at Urbana-Champaign | |
39 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue | |
40 ;; Urbana, Illinois 61801 | |
41 | |
42 ;;; Code: | |
43 | |
44 (require 'calendar) | |
45 | |
13048 | 46 (defconst french-calendar-epoch (calendar-absolute-from-gregorian '(9 22 1792)) |
47 "Absolute date of start of French Revolutionary calendar = September 22, 1792.") | |
48 | |
957 | 49 (defconst french-calendar-month-name-array |
50 ["Vende'miaire" "Brumaire" "Frimaire" "Nivo^se" "Pluvio^se" "Vento^se" | |
51 "Germinal" "Flore'al" "Prairial" "Messidor" "Thermidor" "Fructidor"]) | |
52 | |
53 (defconst french-calendar-day-name-array | |
54 ["Primidi" "Duodi" "Tridi" "Quartidi" "Quintidi" "Sextidi" "Septidi" | |
55 "Octidi" "Nonidi" "Decadi"]) | |
56 | |
57 (defconst french-calendar-special-days-array | |
13048 | 58 ["de la Vertu" "du Genie" "du Labour" "de la Raison" "de la Re'compense" |
59 "de la Re'volution"]) | |
957 | 60 |
61 (defun french-calendar-leap-year-p (year) | |
62 "True if YEAR is a leap year on the French Revolutionary calendar. | |
63 For Gregorian years 1793 to 1805, the years of actual operation of the | |
64 calendar, uses historical practice based on equinoxes is followed (years 3, 7, | |
65 and 11 were leap years; 15 and 20 would have been leap years). For later | |
66 years uses the proposed rule of Romme (never adopted)--leap years fall every | |
67 four years except century years not divisible 400 and century years that are | |
68 multiples of 4000." | |
69 (or (memq year '(3 7 11));; Actual practice--based on equinoxes | |
70 (memq year '(15 20)) ;; Anticipated practice--based on equinoxes | |
71 (and (> year 20) ;; Romme's proposal--never adopted | |
72 (zerop (% year 4)) | |
73 (not (memq (% year 400) '(100 200 300))) | |
74 (not (zerop (% year 4000)))))) | |
75 | |
76 (defun french-calendar-last-day-of-month (month year) | |
1338 | 77 "Return last day of MONTH, YEAR on the French Revolutionary calendar. |
957 | 78 The 13th month is not really a month, but the 5 (6 in leap years) day period of |
79 `sansculottides' at the end of the year." | |
80 (if (< month 13) | |
81 30 | |
82 (if (french-calendar-leap-year-p year) | |
83 6 | |
84 5))) | |
85 | |
86 (defun calendar-absolute-from-french (date) | |
1338 | 87 "Compute absolute date from French Revolutionary date DATE. |
957 | 88 The absolute date is the number of days elapsed since the (imaginary) |
89 Gregorian date Sunday, December 31, 1 BC." | |
90 (let ((month (extract-calendar-month date)) | |
91 (day (extract-calendar-day date)) | |
92 (year (extract-calendar-year date))) | |
93 (+ (* 365 (1- year));; Days in prior years | |
94 ;; Leap days in prior years | |
95 (if (< year 20) | |
96 (/ year 4);; Actual and anticipated practice (years 3, 7, 11, 15) | |
97 ;; Romme's proposed rule (using the Principle of Inclusion/Exclusion) | |
98 (+ (/ (1- year) 4);; Luckily, there were 4 leap years before year 20 | |
99 (- (/ (1- year) 100)) | |
100 (/ (1- year) 400) | |
101 (- (/ (1- year) 4000)))) | |
102 (* 30 (1- month));; Days in prior months this year | |
103 day;; Days so far this month | |
13048 | 104 (1- french-calendar-epoch))));; Days before start of calendar |
957 | 105 |
106 (defun calendar-french-from-absolute (date) | |
1338 | 107 "Compute the French Revolutionary equivalent for absolute date DATE. |
108 The result is a list of the form (MONTH DAY YEAR). | |
109 The absolute date is the number of days elapsed since the | |
7639 | 110 \(imaginary) Gregorian date Sunday, December 31, 1 BC." |
13048 | 111 (if (< date french-calendar-epoch) |
957 | 112 (list 0 0 0);; pre-French Revolutionary date |
13048 | 113 (let* ((approx ;; Approximation from below. |
114 (/ (- date french-calendar-epoch) 366)) | |
957 | 115 (year ;; Search forward from the approximation. |
116 (+ approx | |
117 (calendar-sum y approx | |
118 (>= date (calendar-absolute-from-french (list 1 1 (1+ y)))) | |
119 1))) | |
120 (month ;; Search forward from Vendemiaire. | |
121 (1+ (calendar-sum m 1 | |
122 (> date | |
123 (calendar-absolute-from-french | |
124 (list m | |
125 (french-calendar-last-day-of-month m year) | |
126 year))) | |
127 1))) | |
128 (day ;; Calculate the day by subtraction. | |
129 (- date | |
130 (1- (calendar-absolute-from-french (list month 1 year)))))) | |
131 (list month day year)))) | |
132 | |
5699
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
133 (defun calendar-french-date-string (&optional date) |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
134 "String of French Revolutionary date of Gregorian DATE. |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
135 Returns the empty string if DATE is pre-French Revolutionary. |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
136 Defaults to today's date if DATE is not given." |
957 | 137 (let* ((french-date (calendar-french-from-absolute |
138 (calendar-absolute-from-gregorian | |
5699
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
139 (or date (calendar-current-date))))) |
957 | 140 (y (extract-calendar-year french-date)) |
141 (m (extract-calendar-month french-date)) | |
142 (d (extract-calendar-day french-date))) | |
5699
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
143 (cond |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
144 ((< y 1) "") |
13048 | 145 ((= m 13) (format "Jour %s de l'Anne'e %d de la Re'volution" |
5699
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
146 (aref french-calendar-special-days-array (1- d)) |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
147 y)) |
13048 | 148 (t (format "De'cade %s, %s de %s de l'Anne'e %d de la Re'volution" |
5699
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
149 (make-string (1+ (/ (1- d) 10)) ?I) |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
150 (aref french-calendar-day-name-array (% (1- d) 10)) |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
151 (aref french-calendar-month-name-array (1- m)) |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
152 y))))) |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
153 |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
154 (defun calendar-print-french-date () |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
155 "Show the French Revolutionary calendar equivalent of the selected date." |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
156 (interactive) |
5833
10ea561bcaa5
(calendar-print-french-date,diary-french-date):
Richard M. Stallman <rms@gnu.org>
parents:
5699
diff
changeset
|
157 (let ((f (calendar-french-date-string (calendar-cursor-to-date t)))) |
5699
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
158 (if (string-equal f "") |
957 | 159 (message "Date is pre-French Revolution") |
5699
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
160 (message f)))) |
957 | 161 |
162 (defun calendar-goto-french-date (date &optional noecho) | |
1338 | 163 "Move cursor to French Revolutionary date DATE. |
957 | 164 Echo French Revolutionary date unless NOECHO is t." |
165 (interactive | |
166 (let* ((year (calendar-read | |
13048 | 167 "Anne'e de la Re'volution (>0): " |
957 | 168 '(lambda (x) (> x 0)) |
169 (int-to-string | |
170 (extract-calendar-year | |
171 (calendar-french-from-absolute | |
172 (calendar-absolute-from-gregorian | |
173 (calendar-current-date))))))) | |
174 (month-list | |
175 (mapcar 'list | |
176 (append french-calendar-month-name-array | |
177 (if (french-calendar-leap-year-p year) | |
178 (mapcar | |
179 '(lambda (x) (concat "Jour " x)) | |
180 french-calendar-special-days-array) | |
13048 | 181 (reverse |
957 | 182 (cdr;; we don't want rev. day in a non-leap yr. |
13048 | 183 (reverse |
957 | 184 (mapcar |
185 '(lambda (x) (concat "Jour " x)) | |
5416
3733a396e16a
(calendar-goto-french-date): Fix special day
Richard M. Stallman <rms@gnu.org>
parents:
2945
diff
changeset
|
186 french-calendar-special-days-array)))))))) |
957 | 187 (completion-ignore-case t) |
188 (month (cdr (assoc | |
189 (capitalize | |
190 (completing-read | |
191 "Mois ou Sansculottide: " | |
192 month-list | |
193 nil t)) | |
194 (calendar-make-alist | |
195 month-list | |
196 1 | |
197 '(lambda (x) (capitalize (car x))))))) | |
198 (decade (if (> month 12) | |
199 1 | |
200 (calendar-read | |
201 "De'cade (1-3): " | |
202 '(lambda (x) (memq x '(1 2 3)))))) | |
203 (day (if (> month 12) | |
204 (- month 12) | |
205 (calendar-read | |
5416
3733a396e16a
(calendar-goto-french-date): Fix special day
Richard M. Stallman <rms@gnu.org>
parents:
2945
diff
changeset
|
206 "Jour (1-10): " |
957 | 207 '(lambda (x) (and (<= 1 x) (<= x 10)))))) |
208 (month (if (> month 12) 13 month)) | |
209 (day (+ day (* 10 (1- decade))))) | |
210 (list (list month day year)))) | |
211 (calendar-goto-date (calendar-gregorian-from-absolute | |
212 (calendar-absolute-from-french date))) | |
213 (or noecho (calendar-print-french-date))) | |
214 | |
215 (defun diary-french-date () | |
216 "French calendar equivalent of date diary entry." | |
5833
10ea561bcaa5
(calendar-print-french-date,diary-french-date):
Richard M. Stallman <rms@gnu.org>
parents:
5699
diff
changeset
|
217 (let ((f (calendar-french-date-string (calendar-cursor-to-date t)))) |
5699
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
218 (if (string-equal f "") |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
219 "Date is pre-French Revolution" |
a2d78b648542
(calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents:
5416
diff
changeset
|
220 f))) |
957 | 221 |
222 (provide 'cal-french) | |
223 | |
224 ;;; cal-french.el ends here |