aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-01-30 00:25:00 +0000
committerRichard M. Stallman1994-01-30 00:25:00 +0000
commit6a2aa94c255d85ea55ab4f26cdcedf8f4ce92fa9 (patch)
tree338999b4137efcc81f0a953cf06073ba58d57c34
parent8f22b9e08eb5e4323ea149a2e408ff720935fd1b (diff)
downloademacs-6a2aa94c255d85ea55ab4f26cdcedf8f4ce92fa9.tar.gz
emacs-6a2aa94c255d85ea55ab4f26cdcedf8f4ce92fa9.zip
(calendar-version): New function.
Adjustments to commentary at top of file. (diary-entry-marker, calendar-today-marker, calendar-holiday-marker): Don't autoload them; change definitions to support monochrome and color workstations. (calendar-french-date-string,calendar-mayan-date-string): Autoload them. (calendar-day-of-year-string, calendar-iso-date-string, calendar-julian-date-string,calendar-islamic-date-string, calendar-hebrew-date-string,calendar-astro-date-string): New functions (calendar-print-day-of-year, calendar-print-iso-date, calendar-print-iso-date,calendar-print-julian-date, calendar-print-islamic-date,calendar-print-hebrew-date, calendar-print-astro-day-number): Use them. (calendar-mode-map): Add mouse support. (calendar-unmark,mark-visible-calendar-date,calendar-mark-today): Rewritten.
-rw-r--r--lisp/calendar/calendar.el271
1 files changed, 167 insertions, 104 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index f63a0a3fbfd..1954e8a9d65 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -1,6 +1,7 @@
1;;; calendar.el --- Calendar functions. 1;;; calendar.el --- Calendar functions.
2 2
3;;; Copyright (C) 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. 3;;; Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994 Free Software
4;;; Foundation, Inc.
4 5
5;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> 6;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
6;; Keywords: calendar 7;; Keywords: calendar
@@ -8,7 +9,9 @@
8;; Hebrew calendar, Islamic calendar, ISO calendar, Julian day number, 9;; Hebrew calendar, Islamic calendar, ISO calendar, Julian day number,
9;; diary, holidays 10;; diary, holidays
10 11
11(defconst calendar-version "Version 5.2, released October 20, 1993") 12(defun calendar-version ()
13 (interactive)
14 (message "Version 5.3, January 25, 1994"))
12 15
13;; This file is part of GNU Emacs. 16;; This file is part of GNU Emacs.
14 17
@@ -53,6 +56,7 @@
53 56
54;; The following files are part of the calendar/diary code: 57;; The following files are part of the calendar/diary code:
55 58
59;; cal-menu.el Menu support
56;; diary.el, diary-ins.el Diary functions 60;; diary.el, diary-ins.el Diary functions
57;; holidays.el Holiday functions 61;; holidays.el Holiday functions
58;; cal-french.el French Revolutionary calendar 62;; cal-french.el French Revolutionary calendar
@@ -133,9 +137,40 @@ number of days of diary entries displayed.")
133 "*If t, dates with diary entries will be marked in the calendar window. 137 "*If t, dates with diary entries will be marked in the calendar window.
134The marking symbol is specified by the variable `diary-entry-marker'.") 138The marking symbol is specified by the variable `diary-entry-marker'.")
135 139
136;;;###autoload 140(defvar diary-entry-marker
137(defvar diary-entry-marker "+" 141 (if (not window-system)
138 "*The symbol used to mark dates that have diary entries.") 142 "+"
143 (require 'faces)
144 (make-face 'diary-face)
145 (if (x-display-color-p)
146 (set-face-foreground 'diary-face "red")
147 (copy-face 'bold 'diary-face))
148 'diary-face)
149 "*Used to mark dates that have diary entries.
150Can be either a single-character string or a face.")
151
152(defvar calendar-today-marker
153 (if (not window-system)
154 "="
155 (require 'faces)
156 (make-face 'calendar-today-face)
157 (set-face-underline-p 'calendar-today-face t)
158 'calendar-today-face)
159 "*Used to mark today's date.
160Can be either a single-character string or a face.")
161
162(defvar calendar-holiday-marker
163 (if (not window-system)
164 "*"
165 (require 'faces)
166 (make-face 'holiday-face)
167 (if (x-display-color-p)
168 (set-face-background 'holiday-face "pink")
169 (set-face-background 'holiday-face "black")
170 (set-face-foreground 'holiday-face "white"))
171 'holiday-face)
172 "*Used to mark notable dates in the calendar.
173Can be either a single-character string or a face.")
139 174
140;;;###autoload 175;;;###autoload
141(defvar view-calendar-holidays-initially nil 176(defvar view-calendar-holidays-initially nil
@@ -149,10 +184,6 @@ displayed.")
149The marking symbol is specified by the variable `calendar-holiday-marker'.") 184The marking symbol is specified by the variable `calendar-holiday-marker'.")
150 185
151;;;###autoload 186;;;###autoload
152(defvar calendar-holiday-marker "*"
153 "*The symbol used to mark notable dates in the calendar.")
154
155;;;###autoload
156(defvar all-hebrew-calendar-holidays nil 187(defvar all-hebrew-calendar-holidays nil
157 "*If nil, show only major holidays from the Hebrew calendar. 188 "*If nil, show only major holidays from the Hebrew calendar.
158 189
@@ -200,8 +231,8 @@ and reentering it will cause these functions to be called again.")
200This can be used, for example, to replace today's date with asterisks; a 231This can be used, for example, to replace today's date with asterisks; a
201function `calendar-star-date' is included for this purpose: 232function `calendar-star-date' is included for this purpose:
202 (setq today-visible-calendar-hook 'calendar-star-date) 233 (setq today-visible-calendar-hook 'calendar-star-date)
203It could also be used to mark the current date with `='; a function is also 234It can also be used to mark the current date with calendar-today-marker;
204provided for this: 235a function is also provided for this:
205 (setq today-visible-calendar-hook 'calendar-mark-today) 236 (setq today-visible-calendar-hook 'calendar-mark-today)
206 237
207The corresponding variable `today-invisible-calendar-hook' is the list of 238The corresponding variable `today-invisible-calendar-hook' is the list of
@@ -1149,17 +1180,23 @@ calendar."
1149 t) 1180 t)
1150 1181
1151(autoload 'calendar-print-french-date "cal-french" 1182(autoload 'calendar-print-french-date "cal-french"
1152 "Show the French Revolutionary calendar equivalent of the date under the 1183 "Show the French Revolutionary calendar equivalent of the date under the cursor."
1153cursor."
1154 t) 1184 t)
1155 1185
1156(autoload 'calendar-goto-french-date "cal-french" 1186(autoload 'calendar-goto-french-date "cal-french"
1157 "Move cursor to French Revolutionary date." 1187 "Move cursor to French Revolutionary date."
1158 t) 1188 t)
1159 1189
1190(autoload 'calendar-french-date-string "cal-french"
1191 "String of French Revolutionary date of Gregorian DATE."
1192 t)
1193
1194(autoload 'calendar-mayan-date-string "cal-mayan"
1195 "String of Mayan date of Gregorian DATE."
1196 t)
1197
1160(autoload 'calendar-print-mayan-date "cal-mayan" 1198(autoload 'calendar-print-mayan-date "cal-mayan"
1161 "Show the Mayan long count, Tzolkin, and Haab equivalents of the date 1199 "Show the Mayan long count, Tzolkin, and Haab equivalents of the date under the cursor."
1162under the cursor."
1163 t) 1200 t)
1164 1201
1165(autoload 'calendar-goto-mayan-long-count-date "cal-mayan" 1202(autoload 'calendar-goto-mayan-long-count-date "cal-mayan"
@@ -1389,6 +1426,7 @@ the inserted text. Value is always t."
1389(if calendar-mode-map 1426(if calendar-mode-map
1390 nil 1427 nil
1391 (setq calendar-mode-map (make-sparse-keymap)) 1428 (setq calendar-mode-map (make-sparse-keymap))
1429 (if window-system (require 'cal-menu))
1392 (calendar-for-loop i from 0 to 9 do 1430 (calendar-for-loop i from 0 to 9 do
1393 (define-key calendar-mode-map (int-to-string i) 'digit-argument)) 1431 (define-key calendar-mode-map (int-to-string i) 'digit-argument))
1394 (let ((l (list 'narrow-to-region 'mark-word 'mark-sexp 'mark-paragraph 1432 (let ((l (list 'narrow-to-region 'mark-word 'mark-sexp 'mark-paragraph
@@ -1687,7 +1725,7 @@ calendar. The holidays are displayed in another window.
1687 1725
1688The variable `mark-diary-entries-in-calendar' can be set to t to cause any 1726The variable `mark-diary-entries-in-calendar' can be set to t to cause any
1689dates visible with calendar entries to be marked with the symbol specified by 1727dates visible with calendar entries to be marked with the symbol specified by
1690the variable `diary-entry-marker', normally a plus sign. 1728the variable `diary-entry-marker'.
1691 1729
1692The variable `calendar-load-hook', whose default value is nil, is list of 1730The variable `calendar-load-hook', whose default value is nil, is list of
1693functions to be called when the calendar is first loaded. 1731functions to be called when the calendar is first loaded.
@@ -1702,10 +1740,11 @@ The variable `today-visible-calendar-hook', whose default value is nil, is the
1702list of functions called after the calendar buffer has been prepared with the 1740list of functions called after the calendar buffer has been prepared with the
1703calendar when the current date is visible in the window. This can be used, 1741calendar when the current date is visible in the window. This can be used,
1704for example, to replace today's date with asterisks; a function 1742for example, to replace today's date with asterisks; a function
1705calendar-star-date is included for this purpose: (setq 1743calendar-star-date is included for this purpose:
1706today-visible-calendar-hook 'calendar-star-date) It could also be used to mark 1744 (setq today-visible-calendar-hook 'calendar-star-date)
1707the current date with `*'; a function is also provided for this: (setq 1745It could also be used to mark the current date; a function is also provided
1708today-visible-calendar-hook 'calendar-mark-today) 1746for this:
1747 (setq today-visible-calendar-hook 'calendar-mark-today)
1709 1748
1710The variable `today-invisible-calendar-hook', whose default value is nil, is 1749The variable `today-invisible-calendar-hook', whose default value is nil, is
1711the list of functions called after the calendar buffer has been prepared with 1750the list of functions called after the calendar buffer has been prepared with
@@ -2461,32 +2500,11 @@ If FILTER is provided, apply it to each item in the list."
2461 (% (calendar-absolute-from-gregorian date) 7)) 2500 (% (calendar-absolute-from-gregorian date) 7))
2462 2501
2463(defun calendar-unmark () 2502(defun calendar-unmark ()
2464 "Delete the diary and holiday marks from the calendar." 2503 "Delete all diary/holiday marks/highlighting from the calendar."
2465 (interactive) 2504 (interactive)
2466 (setq mark-diary-entries-in-calendar nil)
2467 (setq mark-holidays-in-calendar nil) 2505 (setq mark-holidays-in-calendar nil)
2468 (save-excursion 2506 (setq mark-diary-entries-in-calendar nil)
2469 (goto-line 3) 2507 (redraw-calendar))
2470 (beginning-of-line)
2471 (let ((buffer-read-only nil)
2472 (start (point))
2473 (star-date (search-forward "**" nil t))
2474 (star-point (point)))
2475 (if star-date
2476 (progn ;; Don't delete today as left by calendar-star-date
2477 (subst-char-in-region start (- star-point 2)
2478 (string-to-char diary-entry-marker) ? t)
2479 (subst-char-in-region start (- star-point 2)
2480 (string-to-char calendar-holiday-marker) ? t)
2481 (subst-char-in-region star-point (point-max)
2482 (string-to-char diary-entry-marker) ? t)
2483 (subst-char-in-region star-point (point-max)
2484 (string-to-char calendar-holiday-marker) ? t))
2485 (subst-char-in-region start (point-max)
2486 (string-to-char diary-entry-marker) ? t)
2487 (subst-char-in-region start (point-max)
2488 (string-to-char calendar-holiday-marker) ? t))
2489 (set-buffer-modified-p nil))))
2490 2508
2491(defun calendar-date-is-visible-p (date) 2509(defun calendar-date-is-visible-p (date)
2492 "Returns t if DATE is legal and is visible in the calendar window." 2510 "Returns t if DATE is legal and is visible in the calendar window."
@@ -2512,17 +2530,22 @@ If FILTER is provided, apply it to each item in the list."
2512 (= (extract-calendar-year date1) (extract-calendar-year date2)))) 2530 (= (extract-calendar-year date1) (extract-calendar-year date2))))
2513 2531
2514(defun mark-visible-calendar-date (date &optional mark) 2532(defun mark-visible-calendar-date (date &optional mark)
2515 "Leave mark DATE with MARK. MARK defaults to diary-entry-marker." 2533 "Mark DATE in the calendar window with MARK.
2534MARK is either a single-character string or a face.
2535MARK defaults to diary-entry-marker."
2516 (if (calendar-date-is-legal-p date) 2536 (if (calendar-date-is-legal-p date)
2517 (save-excursion 2537 (save-excursion
2518 (set-buffer calendar-buffer) 2538 (set-buffer calendar-buffer)
2519 (calendar-cursor-to-visible-date date) 2539 (calendar-cursor-to-visible-date date)
2520 (forward-char 1) 2540 (let ((mark (or mark diary-entry-marker)))
2521 (let ((buffer-read-only nil)) 2541 (if (stringp mark)
2522 (delete-char 1) 2542 (let ((buffer-read-only nil))
2523 (insert (if mark mark diary-entry-marker)) 2543 (forward-char 1)
2524 (forward-char -2)) 2544 (delete-char 1)
2525 (set-buffer-modified-p nil)))) 2545 (insert mark)
2546 (forward-char -2))
2547 (overlay-put
2548 (make-overlay (1-(point)) (1+ (point))) 'face mark))))))
2526 2549
2527(defun calendar-star-date () 2550(defun calendar-star-date ()
2528 "Replace the date under the cursor in the calendar window with asterisks. 2551 "Replace the date under the cursor in the calendar window with asterisks.
@@ -2540,15 +2563,13 @@ calendar window has been prepared."
2540 (set-buffer-modified-p nil))) 2563 (set-buffer-modified-p nil)))
2541 2564
2542(defun calendar-mark-today () 2565(defun calendar-mark-today ()
2543 "Mark the date under the cursor in the calendar window with an equal sign. 2566 "Mark the date under the cursor in the calendar window.
2544This function can be used with the today-visible-calendar-hook run after the 2567The date is marked with calendar-today-marker. This function can be used with
2545calendar window has been prepared." 2568the today-visible-calendar-hook run after the calendar window has been
2546 (let ((buffer-read-only nil)) 2569prepared."
2547 (forward-char 1) 2570 (mark-visible-calendar-date
2548 (delete-char 1) 2571 (calendar-cursor-to-date)
2549 (insert "=") 2572 calendar-today-marker))
2550 (backward-char 2)
2551 (set-buffer-modified-p nil)))
2552 2573
2553(defun calendar-date-compare (date1 date2) 2574(defun calendar-date-compare (date1 date2)
2554 "Returns t if DATE1 is before DATE2, nil otherwise. 2575 "Returns t if DATE1 is before DATE2, nil otherwise.
@@ -2619,17 +2640,22 @@ If DAY is omitted, it defaults to 1 if N>0, and MONTH's last day otherwise."
2619 (calendar-gregorian-from-absolute 2640 (calendar-gregorian-from-absolute
2620 (calendar-nth-named-absday n dayname month year day))) 2641 (calendar-nth-named-absday n dayname month year day)))
2621 2642
2643(defun calendar-day-of-year-string (&optional date)
2644 "String of day number of year of Gregorian DATE.
2645Defaults to today's date if DATE is not given."
2646 (let* ((d (or date (calendar-current-date)))
2647 (year (extract-calendar-year d))
2648 (day (calendar-day-number d))
2649 (days-remaining (- (calendar-day-number (list 12 31 year)) day)))
2650 (format "Day %d of %d; %d day%s remaining in the year"
2651 day year days-remaining (if (= days-remaining 1) "" "s"))))
2652
2622(defun calendar-print-day-of-year () 2653(defun calendar-print-day-of-year ()
2623 "Show the day number in the year and the number of days remaining in the 2654 "Show day number in year/days remaining in year for date under the cursor."
2624year for the date under the cursor."
2625 (interactive) 2655 (interactive)
2626 (let* ((date (or (calendar-cursor-to-date) 2656 (message (calendar-day-of-year-string
2627 (error "Cursor is not on a date!"))) 2657 (or (calendar-cursor-to-date)
2628 (year (extract-calendar-year date)) 2658 (error "Cursor is not on a date!")))))
2629 (day (calendar-day-number date))
2630 (days-remaining (- (calendar-day-number (list 12 31 year)) day)))
2631 (message "Day %d of %d; %d day%s remaining in the year"
2632 day year days-remaining (if (= days-remaining 1) "" "s"))))
2633 2659
2634(defun calendar-absolute-from-iso (date) 2660(defun calendar-absolute-from-iso (date)
2635 "The number of days elapsed between the Gregorian date 12/31/1 BC and DATE. 2661 "The number of days elapsed between the Gregorian date 12/31/1 BC and DATE.
@@ -2667,19 +2693,25 @@ date Sunday, December 31, 1 BC."
2667 (% date 7) 2693 (% date 7)
2668 year))) 2694 year)))
2669 2695
2696(defun calendar-iso-date-string (&optional date)
2697 "String of ISO date of Gregorian DATE.
2698Defaults to today's date if DATE is not given."
2699 (let* ((d (calendar-absolute-from-gregorian
2700 (or date (calendar-current-date))))
2701 (day (% d 7))
2702 (iso-date (calendar-iso-from-absolute d)))
2703 (format "Day %s of week %d of %d."
2704 (if (zerop day) 7 day)
2705 (extract-calendar-month iso-date)
2706 (extract-calendar-year iso-date))))
2707
2670(defun calendar-print-iso-date () 2708(defun calendar-print-iso-date ()
2671 "Show equivalent ISO date for the date under the cursor." 2709 "Show equivalent ISO date for the date under the cursor."
2672 (interactive) 2710 (interactive)
2673 (let* ((greg-date 2711 (message "ISO date: %s"
2674 (or (calendar-cursor-to-date) 2712 (calendar-iso-date-string
2675 (error "Cursor is not on a date!"))) 2713 (or (calendar-cursor-to-date)
2676 (day (% (calendar-absolute-from-gregorian greg-date) 7)) 2714 (error "Cursor is not on a date!")))))
2677 (iso-date (calendar-iso-from-absolute
2678 (calendar-absolute-from-gregorian greg-date))))
2679 (message "ISO date: Day %s of week %d of %d."
2680 (if (zerop day) 7 day)
2681 (extract-calendar-month iso-date)
2682 (extract-calendar-year iso-date))))
2683 2715
2684(defun calendar-julian-from-absolute (date) 2716(defun calendar-julian-from-absolute (date)
2685 "Compute the Julian (month day year) corresponding to the absolute DATE. 2717 "Compute the Julian (month day year) corresponding to the absolute DATE.
@@ -2721,16 +2753,23 @@ The Gregorian date Sunday, December 31, 1 BC is imaginary."
2721 (/ (1- year) 4) 2753 (/ (1- year) 4)
2722 -2))) 2754 -2)))
2723 2755
2756(defun calendar-julian-date-string (&optional date)
2757 "String of Julian date of Gregorian DATE.
2758Defaults to today's date if DATE is not given.
2759Driven by the variable `calendar-date-display-form'."
2760 (calendar-date-string
2761 (calendar-julian-from-absolute
2762 (calendar-absolute-from-gregorian
2763 (or date (calendar-current-date))))
2764 nil t))
2765
2724(defun calendar-print-julian-date () 2766(defun calendar-print-julian-date ()
2725 "Show the Julian calendar equivalent of the date under the cursor." 2767 "Show the Julian calendar equivalent of the date under the cursor."
2726 (interactive) 2768 (interactive)
2727 (message "Julian date: %s" 2769 (message "Julian date: %s"
2728 (calendar-date-string 2770 (calendar-julian-date-string
2729 (calendar-julian-from-absolute 2771 (or (calendar-cursor-to-date)
2730 (calendar-absolute-from-gregorian 2772 (error "Cursor is not on a date!")))))
2731 (or (calendar-cursor-to-date)
2732 (error "Cursor is not on a date!"))))
2733 nil t)))
2734 2773
2735(defun islamic-calendar-leap-year-p (year) 2774(defun islamic-calendar-leap-year-p (year)
2736 "Returns t if YEAR is a leap year on the Islamic calendar." 2775 "Returns t if YEAR is a leap year on the Islamic calendar."
@@ -2802,18 +2841,28 @@ Gregorian date Sunday, December 31, 1 BC."
2802 ["Muharram" "Safar" "Rabi I" "Rabi II" "Jumada I" "Jumada II" 2841 ["Muharram" "Safar" "Rabi I" "Rabi II" "Jumada I" "Jumada II"
2803 "Rajab" "Sha'ban" "Ramadan" "Shawwal" "Dhu al-Qada" "Dhu al-Hijjah"]) 2842 "Rajab" "Sha'ban" "Ramadan" "Shawwal" "Dhu al-Qada" "Dhu al-Hijjah"])
2804 2843
2805(defun calendar-print-islamic-date () 2844(defun calendar-islamic-date-string (&optional date)
2806 "Show the Islamic calendar equivalent of the date under the cursor." 2845 "String of Islamic date before sunset of Gregorian DATE.
2807 (interactive) 2846Returns the empty string if DATE is pre-Islamic.
2847Defaults to today's date if DATE is not given.
2848Driven by the variable `calendar-date-display-form'."
2808 (let ((calendar-month-name-array calendar-islamic-month-name-array) 2849 (let ((calendar-month-name-array calendar-islamic-month-name-array)
2809 (islamic-date (calendar-islamic-from-absolute 2850 (islamic-date (calendar-islamic-from-absolute
2810 (calendar-absolute-from-gregorian 2851 (calendar-absolute-from-gregorian
2811 (or (calendar-cursor-to-date) 2852 (or date (calendar-current-date))))))
2812 (error "Cursor is not on a date!"))))))
2813 (if (< (extract-calendar-year islamic-date) 1) 2853 (if (< (extract-calendar-year islamic-date) 1)
2854 ""
2855 (calendar-date-string islamic-date nil t))))
2856
2857(defun calendar-print-islamic-date ()
2858 "Show the Islamic calendar equivalent of the date under the cursor."
2859 (interactive)
2860 (let ((i (calendar-islamic-date-string
2861 (or (calendar-cursor-to-date)
2862 (error "Cursor is not on a date!")))))
2863 (if (string-equal i "")
2814 (message "Date is pre-Islamic") 2864 (message "Date is pre-Islamic")
2815 (message "Islamic date (until sunset): %s" 2865 (message "Islamic date (until sunset): %s" i))))
2816 (calendar-date-string islamic-date nil t)))))
2817 2866
2818(defun calendar-hebrew-from-absolute (date) 2867(defun calendar-hebrew-from-absolute (date)
2819 "Compute the Hebrew date (month day year) corresponding to absolute DATE. 2868 "Compute the Hebrew date (month day year) corresponding to absolute DATE.
@@ -2936,19 +2985,27 @@ Gregorian date Sunday, December 31, 1 BC."
2936 ["Nisan" "Iyar" "Sivan" "Tammuz" "Av" "Elul" "Tishri" 2985 ["Nisan" "Iyar" "Sivan" "Tammuz" "Av" "Elul" "Tishri"
2937 "Heshvan" "Kislev" "Teveth" "Shevat" "Adar I" "Adar II"]) 2986 "Heshvan" "Kislev" "Teveth" "Shevat" "Adar I" "Adar II"])
2938 2987
2939(defun calendar-print-hebrew-date () 2988(defun calendar-hebrew-date-string (&optional date)
2940 "Show the Hebrew calendar equivalent of the date under the cursor." 2989 "String of Hebrew date before sunset of Gregorian DATE.
2941 (interactive) 2990Defaults to today's date if DATE is not given.
2991Driven by the variable `calendar-date-display-form'."
2942 (let* ((hebrew-date (calendar-hebrew-from-absolute 2992 (let* ((hebrew-date (calendar-hebrew-from-absolute
2943 (calendar-absolute-from-gregorian 2993 (calendar-absolute-from-gregorian
2944 (or (calendar-cursor-to-date) 2994 (or date (calendar-current-date)))))
2945 (error "Cursor is not on a date!")))))
2946 (calendar-month-name-array 2995 (calendar-month-name-array
2947 (if (hebrew-calendar-leap-year-p (extract-calendar-year hebrew-date)) 2996 (if (hebrew-calendar-leap-year-p (extract-calendar-year hebrew-date))
2948 calendar-hebrew-month-name-array-leap-year 2997 calendar-hebrew-month-name-array-leap-year
2949 calendar-hebrew-month-name-array-common-year))) 2998 calendar-hebrew-month-name-array-common-year)))
2950 (message "Hebrew date (until sunset): %s" 2999 (calendar-date-string hebrew-date nil t)))
2951 (calendar-date-string hebrew-date nil t)))) 3000
3001(defun calendar-print-hebrew-date ()
3002 "Show the Hebrew calendar equivalent of the date under the cursor."
3003 (interactive)
3004 (message "Hebrew date (until sunset): %s"
3005 (calendar-hebrew-date-string
3006 (calendar-hebrew-from-absolute
3007 (or (calendar-cursor-to-date)
3008 (error "Cursor is not on a date!"))))))
2952 3009
2953(defun hebrew-calendar-yahrzeit (death-date year) 3010(defun hebrew-calendar-yahrzeit (death-date year)
2954 "Absolute date of the anniversary of Hebrew DEATH-DATE in Hebrew YEAR." 3011 "Absolute date of the anniversary of Hebrew DEATH-DATE in Hebrew YEAR."
@@ -3062,15 +3119,21 @@ from the cursor position."
3062 (display-buffer yahrzeit-buffer) 3119 (display-buffer yahrzeit-buffer)
3063 (message "Computing yahrzeits...done"))) 3120 (message "Computing yahrzeits...done")))
3064 3121
3122(defun calendar-astro-date-string (&optional date)
3123 "String of astronomical (Julian) day number of afternoon of Gregorian DATE.
3124Defaults to today's date if DATE is not given."
3125 (int-to-string
3126 (+ 1721425 (calendar-absolute-from-gregorian
3127 (or date (calendar-current-date))))))
3128
3065(defun calendar-print-astro-day-number () 3129(defun calendar-print-astro-day-number ()
3066 "Show astronomical (Julian) day number of afternoon on date shown by cursor." 3130 "Show astronomical (Julian) day number of afternoon on date shown by cursor."
3067 (interactive) 3131 (interactive)
3068 (message 3132 (message
3069 "Astronomical (Julian) day number after noon UTC: %d" 3133 "Astronomical (Julian) day number after noon UTC: %s"
3070 (+ 1721425 3134 (calendar-astro-date-string
3071 (calendar-absolute-from-gregorian 3135 (or (calendar-cursor-to-date)
3072 (or (calendar-cursor-to-date) 3136 (error "Cursor is not on a date!")))))
3073 (error "Cursor is not on a date!"))))))
3074 3137
3075(defun calendar-goto-astro-day-number (daynumber &optional noecho) 3138(defun calendar-goto-astro-day-number (daynumber &optional noecho)
3076 "Move cursor to astronomical (Julian) DAYNUMBER. 3139 "Move cursor to astronomical (Julian) DAYNUMBER.