annotate lisp/calendar/cal-french.el @ 17085:4dafa5431293

Change coding system name koi8 to koi8-r. Remove prefix "coding-system-" from coding system symbol names.
author Kenichi Handa <handa@m17n.org>
date Wed, 26 Feb 1997 12:27:06 +0000
parents 4df6e0ffab90
children d1fc8a2d353f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 ;;; cal-french.el --- calendar functions for the French Revolutionary calendar.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2
13048
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
3 ;; Copyright (C) 1988, 1989, 1992, 1994, 1995 Free Software Foundation, Inc.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13048
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13048
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13048
diff changeset
24 ;; Boston, MA 02111-1307, USA.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 ;;; Commentary:
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28 ;; This collection of functions implements the features of calendar.el and
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 ;; diary.el that deal with the French Revolutionary calendar.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30
7761
b6ac896a491a Fix typo: Mayan -> French Revolutionary
Paul Eggert <eggert@twinsun.com>
parents: 7639
diff changeset
31 ;; Technical details of the French Revolutionary calendar can be found in
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
32 ;; ``Calendrical Calculations, Part II: Three Historical Calendars'' by
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
33 ;; E. M. Reingold, N. Dershowitz, and S. M. Clamen, Software--Practice and
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
34 ;; Experience, Volume 23, Number 4 (April, 1993), pages 383-404.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 ;; Comments, corrections, and improvements should be sent to
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 ;; Edward M. Reingold Department of Computer Science
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 ;; Urbana, Illinois 61801
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 ;;; Code:
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 (require 'calendar)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
46 (defvar french-calendar-accents
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
47 (and (char-table-p standard-display-table)
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
48 (equal (aref standard-display-table 161) [161]))
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
49 "True if diacritical marks are available.")
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
50
13048
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
51 (defconst french-calendar-epoch (calendar-absolute-from-gregorian '(9 22 1792))
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
52 "Absolute date of start of French Revolutionary calendar = September 22, 1792.")
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
53
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (defconst french-calendar-month-name-array
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
55 (if french-calendar-accents
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
56 ["Vendémiaire" "Brumaire" "Frimaire" "Nivôse" "Pluviôse" "Ventôse"
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
57 "Germinal" "Floréal" "Prairial" "Messidor" "Thermidor" "Fructidor"]
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
58 ["Vende'miaire" "Brumaire" "Frimaire" "Nivo^se" "Pluvio^se" "Vento^se"
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
59 "Germinal" "Flore'al" "Prairial" "Messidor" "Thermidor" "Fructidor"]))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (defconst french-calendar-day-name-array
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 ["Primidi" "Duodi" "Tridi" "Quartidi" "Quintidi" "Sextidi" "Septidi"
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 "Octidi" "Nonidi" "Decadi"])
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 (defconst french-calendar-special-days-array
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
66 (if french-calendar-accents
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
67 ["de la Vertu" "du Genie" "du Labour" "de la Raison"
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
68 "de la Récompense" "de la Révolution"]
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
69 ["de la Vertu" "du Genie" "du Labour" "de la Raison" "de la Re'compense"
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
70 "de la Re'volution"]))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 (defun french-calendar-leap-year-p (year)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 "True if YEAR is a leap year on the French Revolutionary calendar.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 For Gregorian years 1793 to 1805, the years of actual operation of the
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 calendar, uses historical practice based on equinoxes is followed (years 3, 7,
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 and 11 were leap years; 15 and 20 would have been leap years). For later
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 years uses the proposed rule of Romme (never adopted)--leap years fall every
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 four years except century years not divisible 400 and century years that are
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 multiples of 4000."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 (or (memq year '(3 7 11));; Actual practice--based on equinoxes
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 (memq year '(15 20)) ;; Anticipated practice--based on equinoxes
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 (and (> year 20) ;; Romme's proposal--never adopted
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 (zerop (% year 4))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 (not (memq (% year 400) '(100 200 300)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 (not (zerop (% year 4000))))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 (defun french-calendar-last-day-of-month (month year)
1338
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
88 "Return last day of MONTH, YEAR on the French Revolutionary calendar.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 The 13th month is not really a month, but the 5 (6 in leap years) day period of
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 `sansculottides' at the end of the year."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 (if (< month 13)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 30
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 (if (french-calendar-leap-year-p year)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 6
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 5)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 (defun calendar-absolute-from-french (date)
1338
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
98 "Compute absolute date from French Revolutionary date DATE.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 The absolute date is the number of days elapsed since the (imaginary)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 Gregorian date Sunday, December 31, 1 BC."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 (let ((month (extract-calendar-month date))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 (day (extract-calendar-day date))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 (year (extract-calendar-year date)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 (+ (* 365 (1- year));; Days in prior years
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 ;; Leap days in prior years
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 (if (< year 20)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 (/ year 4);; Actual and anticipated practice (years 3, 7, 11, 15)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 ;; Romme's proposed rule (using the Principle of Inclusion/Exclusion)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 (+ (/ (1- year) 4);; Luckily, there were 4 leap years before year 20
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 (- (/ (1- year) 100))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (/ (1- year) 400)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 (- (/ (1- year) 4000))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 (* 30 (1- month));; Days in prior months this year
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 day;; Days so far this month
13048
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
115 (1- french-calendar-epoch))));; Days before start of calendar
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 (defun calendar-french-from-absolute (date)
1338
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
118 "Compute the French Revolutionary equivalent for absolute date DATE.
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
119 The result is a list of the form (MONTH DAY YEAR).
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
120 The absolute date is the number of days elapsed since the
7639
67b7d1ea7b2e Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6736
diff changeset
121 \(imaginary) Gregorian date Sunday, December 31, 1 BC."
13048
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
122 (if (< date french-calendar-epoch)
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 (list 0 0 0);; pre-French Revolutionary date
13048
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
124 (let* ((approx ;; Approximation from below.
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
125 (/ (- date french-calendar-epoch) 366))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 (year ;; Search forward from the approximation.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 (+ approx
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 (calendar-sum y approx
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 (>= date (calendar-absolute-from-french (list 1 1 (1+ y))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 1)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 (month ;; Search forward from Vendemiaire.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 (1+ (calendar-sum m 1
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 (> date
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 (calendar-absolute-from-french
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 (list m
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 (french-calendar-last-day-of-month m year)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 year)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 1)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 (day ;; Calculate the day by subtraction.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (- date
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (1- (calendar-absolute-from-french (list month 1 year))))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 (list month day year))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
144 (defun calendar-french-date-string (&optional date)
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
145 "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
146 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
147 Defaults to today's date if DATE is not given."
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 (let* ((french-date (calendar-french-from-absolute
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 (calendar-absolute-from-gregorian
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
150 (or date (calendar-current-date)))))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (y (extract-calendar-year french-date))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 (m (extract-calendar-month french-date))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (d (extract-calendar-day french-date)))
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
154 (cond
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
155 ((< y 1) "")
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
156 ((= m 13) (format (if french-calendar-accents
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
157 "Jour %s de l'Année %d de la Révolution"
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
158 "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
159 (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
160 y))
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
161 (t (format
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
162 (if french-calendar-accents
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
163 "Décade %s, %s de %s de l'Année %d de la Révolution"
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
164 "De'cade %s, %s de %s de l'Anne'e %d de la Re'volution")
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
165 (make-string (1+ (/ (1- d) 10)) ?I)
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
166 (aref french-calendar-day-name-array (% (1- d) 10))
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
167 (aref french-calendar-month-name-array (1- m))
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
168 y)))))
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
169
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
170 (defun calendar-print-french-date ()
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
171 "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
172 (interactive)
5833
10ea561bcaa5 (calendar-print-french-date,diary-french-date):
Richard M. Stallman <rms@gnu.org>
parents: 5699
diff changeset
173 (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
174 (if (string-equal f "")
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 (message "Date is pre-French Revolution")
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
176 (message f))))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 (defun calendar-goto-french-date (date &optional noecho)
1338
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
179 "Move cursor to French Revolutionary date DATE.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 Echo French Revolutionary date unless NOECHO is t."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 (interactive
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 (let* ((year (calendar-read
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
183 (if french-calendar-accents
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
184 "Année de la Révolution (>0): "
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
185 "Anne'e de la Re'volution (>0): ")
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 '(lambda (x) (> x 0))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 (int-to-string
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 (extract-calendar-year
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 (calendar-french-from-absolute
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (calendar-absolute-from-gregorian
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 (calendar-current-date)))))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (month-list
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 (mapcar 'list
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 (append french-calendar-month-name-array
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 (if (french-calendar-leap-year-p year)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 (mapcar
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 '(lambda (x) (concat "Jour " x))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 french-calendar-special-days-array)
13048
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
199 (reverse
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 (cdr;; we don't want rev. day in a non-leap yr.
13048
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
201 (reverse
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 (mapcar
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 '(lambda (x) (concat "Jour " x))
5416
3733a396e16a (calendar-goto-french-date): Fix special day
Richard M. Stallman <rms@gnu.org>
parents: 2945
diff changeset
204 french-calendar-special-days-array))))))))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 (completion-ignore-case t)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 (month (cdr (assoc
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 (capitalize
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 (completing-read
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 "Mois ou Sansculottide: "
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 month-list
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 nil t))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (calendar-make-alist
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 month-list
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 1
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 '(lambda (x) (capitalize (car x)))))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (decade (if (> month 12)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 1
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 (calendar-read
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
219 (if french-calendar-accents
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
220 "Décade (1-3): "
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
221 "De'cade (1-3): ")
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 '(lambda (x) (memq x '(1 2 3))))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (day (if (> month 12)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (- month 12)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 (calendar-read
5416
3733a396e16a (calendar-goto-french-date): Fix special day
Richard M. Stallman <rms@gnu.org>
parents: 2945
diff changeset
226 "Jour (1-10): "
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 '(lambda (x) (and (<= 1 x) (<= x 10))))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 (month (if (> month 12) 13 month))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 (day (+ day (* 10 (1- decade)))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 (list (list month day year))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 (calendar-goto-date (calendar-gregorian-from-absolute
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 (calendar-absolute-from-french date)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 (or noecho (calendar-print-french-date)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (defun diary-french-date ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 "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
237 (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
238 (if (string-equal f "")
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
239 "Date is pre-French Revolution"
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
240 f)))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 (provide 'cal-french)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 ;;; cal-french.el ends here