annotate lisp/calendar/cal-french.el @ 93333:53eee5c271f4

* vc.el: Add new backend function 'status-extra-headers. (vc-default-status-extra-headers): New function. (vc-status-headers): Call 'status-extra-headers. Add colors. * vc-git.el (vc-git-status-extra-headers): New function.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 28 Mar 2008 03:50:26 +0000
parents 943c6058b43a
children 2aa65ff3876d
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: 28781
diff changeset
1 ;;; cal-french.el --- calendar functions for the French Revolutionary calendar
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2
67465
a55ee709ec8d Update copyright pending Emacs 22.
Glenn Morris <rgm@gnu.org>
parents: 65145
diff changeset
3 ;; Copyright (C) 1988, 1989, 1992, 1994, 1995, 1997, 2001, 2002, 2003,
79703
974a828870fe Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78216
diff changeset
4 ;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
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: 65145
diff changeset
7 ;; Maintainer: Glenn Morris <rgm@gnu.org>
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1338
diff changeset
8 ;; Keywords: calendar
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1338
diff changeset
9 ;; Human-Keywords: French Revolutionary calendar, calendar, diary
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12
6736
3e1323443b1a Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents: 5833
diff changeset
13 ;; 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
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)
6736
3e1323443b1a Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents: 5833
diff changeset
16 ;; any later version.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17
6736
3e1323443b1a Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents: 5833
diff changeset
18 ;; 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
19 ;; 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
20 ;; 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
21 ;; 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
22
3e1323443b1a Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents: 5833
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: 13048
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: 61148
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 61148
diff changeset
26 ;; Boston, MA 02110-1301, USA.
957
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 ;;; Commentary:
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 ;; This collection of functions implements the features of calendar.el and
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 ;; diary.el that deal with the French Revolutionary calendar.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32
7761
b6ac896a491a Fix typo: Mayan -> French Revolutionary
Paul Eggert <eggert@twinsun.com>
parents: 7639
diff changeset
33 ;; Technical details of the French Revolutionary calendar can be found in
61148
7f7db25577d9 Update reference to "Calendrical Calculations" book; there's a new edition.
Paul Eggert <eggert@twinsun.com>
parents: 54073
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: 54073
diff changeset
35 ;; and Nachum Dershowitz, Cambridge University Press (2001), and in
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
36 ;; ``Calendrical Calculations, Part II: Three Historical Calendars'' by
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
37 ;; 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
38 ;; Experience, Volume 23, Number 4 (April, 1993), pages 383-404.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 ;;; Code:
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 (require 'calendar)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43
92905
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
44 (defconst french-calendar-epoch (calendar-absolute-from-gregorian '(9 22 1792))
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
45 "Absolute date of start of French Revolutionary calendar = Sept 22, 1792.")
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
46
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
47 (defconst french-calendar-month-name-array
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
48 ["Vende'miaire" "Brumaire" "Frimaire" "Nivo^se" "Pluvio^se" "Vento^se"
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
49 "Germinal" "Flore'al" "Prairial" "Messidor" "Thermidor" "Fructidor"]
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
50 "Array of month names in the French calendar.")
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
51
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
52 (defconst french-calendar-multibyte-month-name-array
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
53 ["Vendémiaire" "Brumaire" "Frimaire" "Nivôse" "Pluviôse" "Ventôse"
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
54 "Germinal" "Floréal" "Prairial" "Messidor" "Thermidor" "Fructidor"]
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
55 "Array of multibyte month names in the French calendar.")
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
56
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
57 (defconst french-calendar-day-name-array
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
58 ["Primidi" "Duodi" "Tridi" "Quartidi" "Quintidi" "Sextidi" "Septidi"
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
59 "Octidi" "Nonidi" "Decadi"]
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
60 "Array of day names in the French calendar.")
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
61
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
62 (defconst french-calendar-special-days-array
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
63 ["de la Vertu" "du Ge'nie" "du Travail" "de la Raison" "des Re'compenses"
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
64 "de la Re'volution"]
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
65 "Array of special day names in the French calendar.")
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
66
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
67 (defconst french-calendar-multibyte-special-days-array
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
68 ["de la Vertu" "du Génie" "du Travail" "de la Raison" "des Récompenses"
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
69 "de la Révolution"]
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
70 "Array of multibyte special day names in the French calendar.")
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
71
19885
266e93ddaf0e (french-calendar-accents): Change variable to function.
Richard M. Stallman <rms@gnu.org>
parents: 17570
diff changeset
72 (defun french-calendar-accents ()
92964
943c6058b43a (french-calendar-accents): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 92905
diff changeset
73 "Return non-nil if diacritical marks are available."
19885
266e93ddaf0e (french-calendar-accents): Change variable to function.
Richard M. Stallman <rms@gnu.org>
parents: 17570
diff changeset
74 (and (or window-system
92851
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
75 (terminal-coding-system))
19885
266e93ddaf0e (french-calendar-accents): Change variable to function.
Richard M. Stallman <rms@gnu.org>
parents: 17570
diff changeset
76 (or enable-multibyte-characters
92851
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
77 (and (char-table-p standard-display-table)
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
78 (equal (aref standard-display-table 161) [161])))))
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
79
20474
2ff24b456bb7 (calendar-french-single-byteify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
80 (defun french-calendar-month-name-array ()
92629
3d76a52b916c (french-calendar-month-name-array)
Glenn Morris <rgm@gnu.org>
parents: 92628
diff changeset
81 "Return the array of month names, depending on whether accents are available."
20474
2ff24b456bb7 (calendar-french-single-byteify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
82 (if (french-calendar-accents)
2ff24b456bb7 (calendar-french-single-byteify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
83 french-calendar-multibyte-month-name-array
2ff24b456bb7 (calendar-french-single-byteify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
84 french-calendar-month-name-array))
2ff24b456bb7 (calendar-french-single-byteify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
85
2ff24b456bb7 (calendar-french-single-byteify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
86 (defun french-calendar-day-name-array ()
92629
3d76a52b916c (french-calendar-month-name-array)
Glenn Morris <rgm@gnu.org>
parents: 92628
diff changeset
87 "Return the array of day names."
20474
2ff24b456bb7 (calendar-french-single-byteify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
88 french-calendar-day-name-array)
2ff24b456bb7 (calendar-french-single-byteify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
89
20393
6f1b751fc31d (french-calendar-special-days-array): New function.
Karl Heuer <kwzh@gnu.org>
parents: 20245
diff changeset
90 (defun french-calendar-special-days-array ()
92629
3d76a52b916c (french-calendar-month-name-array)
Glenn Morris <rgm@gnu.org>
parents: 92628
diff changeset
91 "Return the special day names, depending on whether accents are available."
20393
6f1b751fc31d (french-calendar-special-days-array): New function.
Karl Heuer <kwzh@gnu.org>
parents: 20245
diff changeset
92 (if (french-calendar-accents)
6f1b751fc31d (french-calendar-special-days-array): New function.
Karl Heuer <kwzh@gnu.org>
parents: 20245
diff changeset
93 french-calendar-multibyte-special-days-array
6f1b751fc31d (french-calendar-special-days-array): New function.
Karl Heuer <kwzh@gnu.org>
parents: 20245
diff changeset
94 french-calendar-special-days-array))
6f1b751fc31d (french-calendar-special-days-array): New function.
Karl Heuer <kwzh@gnu.org>
parents: 20245
diff changeset
95
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 (defun french-calendar-leap-year-p (year)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 "True if YEAR is a leap year on the French Revolutionary calendar.
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 For Gregorian years 1793 to 1805, the years of actual operation of the
19885
266e93ddaf0e (french-calendar-accents): Change variable to function.
Richard M. Stallman <rms@gnu.org>
parents: 17570
diff changeset
99 calendar, follows historical practice based on equinoxes (years 3, 7,
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 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
101 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
102 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
103 multiples of 4000."
92628
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
104 (or (memq year '(3 7 11)) ; actual practice--based on equinoxes
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
105 (memq year '(15 20)) ; anticipated practice--based on equinoxes
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
106 (and (> year 20) ; Romme's proposal--never adopted
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 (zerop (% year 4))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 (not (memq (% year 400) '(100 200 300)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 (not (zerop (% year 4000))))))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (defun french-calendar-last-day-of-month (month year)
1338
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
112 "Return last day of MONTH, YEAR on the French Revolutionary calendar.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 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
114 `sansculottides' at the end of the year."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 (if (< month 13)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 30
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 (if (french-calendar-leap-year-p year)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 6
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 5)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 (defun calendar-absolute-from-french (date)
1338
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
122 "Compute absolute date from French Revolutionary date DATE.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 The absolute date is the number of days elapsed since the (imaginary)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 Gregorian date Sunday, December 31, 1 BC."
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 (let ((month (extract-calendar-month date))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 (day (extract-calendar-day date))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 (year (extract-calendar-year date)))
92628
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
128 (+ (* 365 (1- year)) ; days in prior years
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
129 ;; Leap days in prior years.
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 (if (< year 20)
92628
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
131 (/ year 4) ; actual and anticipated practice (years 3, 7, 11, 15)
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
132 ;; Romme's proposed rule (using the Principle of Inclusion/Exclusion).
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
133 (+ (/ (1- year) 4) ; luckily, there were 4 leap years before year 20
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 (- (/ (1- year) 100))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 (/ (1- year) 400)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 (- (/ (1- year) 4000))))
92628
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
137 (* 30 (1- month)) ; days in prior months this year
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
138 day ; days so far this month
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
139 (1- french-calendar-epoch)))) ; days before start of calendar
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (defun calendar-french-from-absolute (date)
1338
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
142 "Compute the French Revolutionary equivalent for absolute date DATE.
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
143 The result is a list of the form (MONTH DAY YEAR).
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
144 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
145 \(imaginary) Gregorian date Sunday, December 31, 1 BC."
13048
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
146 (if (< date french-calendar-epoch)
92628
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
147 (list 0 0 0) ; pre-French Revolutionary date
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
148 (let* ((approx ; approximation from below
13048
6c21adf788d5 Minor fixes.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents: 7761
diff changeset
149 (/ (- date french-calendar-epoch) 366))
92628
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
150 (year ; search forward from the approximation
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (+ approx
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 (calendar-sum y approx
92851
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
153 (>= date (calendar-absolute-from-french
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
154 (list 1 1 (1+ y))))
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
155 1)))
92628
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
156 (month ; search forward from Vendemiaire
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 (1+ (calendar-sum m 1
92851
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
158 (> date
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
159 (calendar-absolute-from-french
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
160 (list m
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
161 (french-calendar-last-day-of-month
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
162 m year)
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
163 year)))
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
164 1)))
92628
3b8495c1770f Formatting changes only.
Glenn Morris <rgm@gnu.org>
parents: 92612
diff changeset
165 (day ; calculate the day by subtraction
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (- date
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 (1- (calendar-absolute-from-french (list month 1 year))))))
92851
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
168 (list month day year))))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169
92829
8777b384ba72 (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92629
diff changeset
170 ;;;###cal-autoload
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
171 (defun calendar-french-date-string (&optional date)
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
172 "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
173 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
174 Defaults to today's date if DATE is not given."
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 (let* ((french-date (calendar-french-from-absolute
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 (calendar-absolute-from-gregorian
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
177 (or date (calendar-current-date)))))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 (y (extract-calendar-year french-date))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 (m (extract-calendar-month french-date))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 (d (extract-calendar-day french-date)))
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
181 (cond
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
182 ((< y 1) "")
19885
266e93ddaf0e (french-calendar-accents): Change variable to function.
Richard M. Stallman <rms@gnu.org>
parents: 17570
diff changeset
183 ((= m 13) (format (if (french-calendar-accents)
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
184 "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
185 "Jour %s de l'Anne'e %d de la Re'volution")
20393
6f1b751fc31d (french-calendar-special-days-array): New function.
Karl Heuer <kwzh@gnu.org>
parents: 20245
diff changeset
186 (aref (french-calendar-special-days-array) (1- d))
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
187 y))
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
188 (t (format
19885
266e93ddaf0e (french-calendar-accents): Change variable to function.
Richard M. Stallman <rms@gnu.org>
parents: 17570
diff changeset
189 (if (french-calendar-accents)
28781
dc2a0cf401ab (french-calendar-multibyte-special-days-array)
Gerd Moellmann <gerd@gnu.org>
parents: 24191
diff changeset
190 "%d %s an %d de la Révolution"
dc2a0cf401ab (french-calendar-multibyte-special-days-array)
Gerd Moellmann <gerd@gnu.org>
parents: 24191
diff changeset
191 "%d %s an %d de la Re'volution")
dc2a0cf401ab (french-calendar-multibyte-special-days-array)
Gerd Moellmann <gerd@gnu.org>
parents: 24191
diff changeset
192 d
19885
266e93ddaf0e (french-calendar-accents): Change variable to function.
Richard M. Stallman <rms@gnu.org>
parents: 17570
diff changeset
193 (aref (french-calendar-month-name-array) (1- m))
15550
4df6e0ffab90 (french-calendar-accents): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
194 y)))))
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
195
92829
8777b384ba72 (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92629
diff changeset
196 ;;;###cal-autoload
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
197 (defun calendar-print-french-date ()
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
198 "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
199 (interactive)
20763
129b8b78151c (calendar-french-single-byteify): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents: 20474
diff changeset
200 (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
201 (if (string-equal f "")
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 (message "Date is pre-French Revolution")
17570
daaffe2dece5 (calendar-print-french-date): Label French date in echo area.
Richard M. Stallman <rms@gnu.org>
parents: 17381
diff changeset
203 (message "French Revolutionary date: %s" f))))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204
92829
8777b384ba72 (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92629
diff changeset
205 ;;;###cal-autoload
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 (defun calendar-goto-french-date (date &optional noecho)
1338
3ea4e9dc49b2 Dox fixes.
Richard M. Stallman <rms@gnu.org>
parents: 957
diff changeset
207 "Move cursor to French Revolutionary date DATE.
92905
0cea6abac18e (french-calendar-accents): Move definition after constants.
Glenn Morris <rgm@gnu.org>
parents: 92851
diff changeset
208 Echo French Revolutionary date unless NOECHO is non-nil."
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 (interactive
20763
129b8b78151c (calendar-french-single-byteify): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents: 20474
diff changeset
210 (let ((accents (french-calendar-accents))
92851
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
211 (months (french-calendar-month-name-array))
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
212 (special-days (french-calendar-special-days-array)))
20474
2ff24b456bb7 (calendar-french-single-byteify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
213 (let* ((year
92851
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
214 (progn
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
215 (calendar-read
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
216 (if accents
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
217 "Année de la Révolution (>0): "
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
218 "Anne'e de la Re'volution (>0): ")
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
219 (lambda (x) (> x 0))
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
220 (int-to-string
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
221 (extract-calendar-year
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
222 (calendar-french-from-absolute
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
223 (calendar-absolute-from-gregorian
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
224 (calendar-current-date))))))))
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
225 (month-list
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
226 (mapcar 'list
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
227 (append months
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
228 (if (french-calendar-leap-year-p year)
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
229 (mapcar
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
230 (lambda (x) (concat "Jour " x))
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
231 french-calendar-special-days-array)
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
232 (reverse
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
233 (cdr ; we don't want rev. day in a non-leap yr
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
234 (reverse
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
235 (mapcar
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
236 (lambda (x)
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
237 (concat "Jour " x))
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
238 special-days))))))))
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
239 (completion-ignore-case t)
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
240 (month (cdr (assoc-string
24191
4f1b1bddae88 (calendar-goto-french-date): Use assoc-ignore-case and do not
Richard M. Stallman <rms@gnu.org>
parents: 20763
diff changeset
241 (completing-read
4f1b1bddae88 (calendar-goto-french-date): Use assoc-ignore-case and do not
Richard M. Stallman <rms@gnu.org>
parents: 20763
diff changeset
242 "Mois ou Sansculottide: "
4f1b1bddae88 (calendar-goto-french-date): Use assoc-ignore-case and do not
Richard M. Stallman <rms@gnu.org>
parents: 20763
diff changeset
243 month-list
4f1b1bddae88 (calendar-goto-french-date): Use assoc-ignore-case and do not
Richard M. Stallman <rms@gnu.org>
parents: 20763
diff changeset
244 nil t)
92851
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
245 (calendar-make-alist month-list 1 'car) t)))
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
246 (day (if (> month 12)
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
247 (- month 12)
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
248 (calendar-read
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
249 "Jour (1-30): "
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
250 (lambda (x) (and (<= 1 x) (<= x 30))))))
f14a38040473 Whitespace only.
Glenn Morris <rgm@gnu.org>
parents: 92829
diff changeset
251 (month (if (> month 12) 13 month)))
20474
2ff24b456bb7 (calendar-french-single-byteify): New function.
Richard M. Stallman <rms@gnu.org>
parents: 20462
diff changeset
252 (list (list month day year)))))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (calendar-goto-date (calendar-gregorian-from-absolute
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (calendar-absolute-from-french date)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (or noecho (calendar-print-french-date)))
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256
92612
716eff3e7232 Comment.
Glenn Morris <rgm@gnu.org>
parents: 92582
diff changeset
257 (defvar date)
716eff3e7232 Comment.
Glenn Morris <rgm@gnu.org>
parents: 92582
diff changeset
258
716eff3e7232 Comment.
Glenn Morris <rgm@gnu.org>
parents: 92582
diff changeset
259 ;; To be called from list-sexp-diary-entries, where DATE is bound.
92829
8777b384ba72 (generated-autoload-file): Don't set, instead use different values of
Glenn Morris <rgm@gnu.org>
parents: 92629
diff changeset
260 ;;;###diary-autoload
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (defun diary-french-date ()
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 "French calendar equivalent of date diary entry."
17381
d1fc8a2d353f (diary-french-date): Use `date'.
Richard M. Stallman <rms@gnu.org>
parents: 15550
diff changeset
263 (let ((f (calendar-french-date-string date)))
5699
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
264 (if (string-equal f "")
a2d78b648542 (calendar-french-date-string): New function.
Richard M. Stallman <rms@gnu.org>
parents: 5416
diff changeset
265 "Date is pre-French Revolution"
17381
d1fc8a2d353f (diary-french-date): Use `date'.
Richard M. Stallman <rms@gnu.org>
parents: 15550
diff changeset
266 (format "French Revolutionary date: %s" f))))
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (provide 'cal-french)
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269
92582
68c1d9ecc30d Unquote lambda functions. Add autoload cookies to functions formerly
Glenn Morris <rgm@gnu.org>
parents: 79703
diff changeset
270 ;; arch-tag: 7e8045a3-8609-46b5-9cde-cf40ce541cf9
957
2619b7a9c11e entered into RCS
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 ;;; cal-french.el ends here