Commit adaeaa8e authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(calendar-french-date-string): New function.

(calendar-print-french-date, diary-french-date): Use it.
parent abd93e66
...@@ -127,28 +127,37 @@ The absolute date is the number of days elapsed since the ...@@ -127,28 +127,37 @@ The absolute date is the number of days elapsed since the
(1- (calendar-absolute-from-french (list month 1 year)))))) (1- (calendar-absolute-from-french (list month 1 year))))))
(list month day year)))) (list month day year))))
(defun calendar-print-french-date () (defun calendar-french-date-string (&optional date)
"Show the French Revolutionary calendar equivalent of the selected date." "String of French Revolutionary date of Gregorian DATE.
(interactive) Returns the empty string if DATE is pre-French Revolutionary.
Defaults to today's date if DATE is not given."
(let* ((french-date (calendar-french-from-absolute (let* ((french-date (calendar-french-from-absolute
(calendar-absolute-from-gregorian (calendar-absolute-from-gregorian
(or (calendar-cursor-to-date) (or date (calendar-current-date)))))
(error "Cursor is not on a date!")))))
(y (extract-calendar-year french-date)) (y (extract-calendar-year french-date))
(m (extract-calendar-month french-date)) (m (extract-calendar-month french-date))
(d (extract-calendar-day french-date))) (d (extract-calendar-day french-date)))
(if (< y 1) (cond
(message "Date is pre-French Revolution") ((< y 1) "")
(if (= m 13) ((= m 13) (format "Jour %s de l'Anne'e %d de la Revolution"
(message "Jour %s de l'Anne'e %d de la Revolution"
(aref french-calendar-special-days-array (1- d)) (aref french-calendar-special-days-array (1- d))
y) y))
(message "Decade %s, %s de %s de l'Anne'e %d de la Revolution" (t (format "Decade %s, %s de %s de l'Anne'e %d de la Revolution"
(make-string (1+ (/ (1- d) 10)) ?I) (make-string (1+ (/ (1- d) 10)) ?I)
(aref french-calendar-day-name-array (% (1- d) 10)) (aref french-calendar-day-name-array (% (1- d) 10))
(aref french-calendar-month-name-array (1- m)) (aref french-calendar-month-name-array (1- m))
y))))) y)))))
(defun calendar-print-french-date ()
"Show the French Revolutionary calendar equivalent of the selected date."
(interactive)
(let ((f (calendar-french-date-string
(or (calendar-cursor-to-date)
(error "Cursor is not on a date!")))))
(if (string-equal f "")
(message "Date is pre-French Revolution")
(message f))))
(defun calendar-goto-french-date (date &optional noecho) (defun calendar-goto-french-date (date &optional noecho)
"Move cursor to French Revolutionary date DATE. "Move cursor to French Revolutionary date DATE.
Echo French Revolutionary date unless NOECHO is t." Echo French Revolutionary date unless NOECHO is t."
...@@ -204,21 +213,12 @@ Echo French Revolutionary date unless NOECHO is t." ...@@ -204,21 +213,12 @@ Echo French Revolutionary date unless NOECHO is t."
(defun diary-french-date () (defun diary-french-date ()
"French calendar equivalent of date diary entry." "French calendar equivalent of date diary entry."
(let* ((french-date (calendar-french-from-absolute (let ((f (calendar-french-date-string
(calendar-absolute-from-gregorian date))) (or (calendar-cursor-to-date)
(y (extract-calendar-year french-date)) (error "Cursor is not on a date!")))))
(m (extract-calendar-month french-date)) (if (string-equal f "")
(d (extract-calendar-day french-date))) "Date is pre-French Revolution"
(if (> y 0) f)))
(if (= m 13)
(format "Jour %s de l'Anne'e %d de la Revolution"
(aref french-calendar-special-days-array (1- d))
y)
(format "Decade %s, %s de %s de l'Anne'e %d de la Revolution"
(make-string (1+ (/ (1- d) 10)) ?I)
(aref french-calendar-day-name-array (% (1- d) 10))
(aref french-calendar-month-name-array (1- m))
y)))))
(provide 'cal-french) (provide 'cal-french)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment