diff options
| author | Glenn Morris | 2008-06-26 22:28:24 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-06-26 22:28:24 +0000 |
| commit | 5c4e1641081dd766bb78d803a906bffe95a938b1 (patch) | |
| tree | 667b3aae9f1556166b0298c96f69456d1a255590 | |
| parent | c35f9821de5ec0cf127185890191ad0154600d0d (diff) | |
| download | emacs-5c4e1641081dd766bb78d803a906bffe95a938b1.tar.gz emacs-5c4e1641081dd766bb78d803a906bffe95a938b1.zip | |
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
(calendar-sunrise-sunset-month): New function.
| -rw-r--r-- | lisp/calendar/solar.el | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/lisp/calendar/solar.el b/lisp/calendar/solar.el index 6dbd9b3a33d..6ac89989256 100644 --- a/lisp/calendar/solar.el +++ b/lisp/calendar/solar.el | |||
| @@ -640,18 +640,20 @@ Corresponding value is nil if there is no sunrise/sunset." | |||
| 640 | (and set-time (calendar-date-equal date (car adj-set)) (cdr adj-set)) | 640 | (and set-time (calendar-date-equal date (car adj-set)) (cdr adj-set)) |
| 641 | (solar-daylight length)))) | 641 | (solar-daylight length)))) |
| 642 | 642 | ||
| 643 | (defun solar-sunrise-sunset-string (date) | 643 | (defun solar-sunrise-sunset-string (date &optional nolocation) |
| 644 | "String of *local* times of sunrise, sunset, and daylight on Gregorian DATE." | 644 | "String of *local* times of sunrise, sunset, and daylight on Gregorian DATE. |
| 645 | Optional NOLOCATION non-nil means do not print the location." | ||
| 645 | (let ((l (solar-sunrise-sunset date))) | 646 | (let ((l (solar-sunrise-sunset date))) |
| 646 | (format | 647 | (format |
| 647 | "%s, %s at %s (%s hours daylight)" | 648 | "%s, %s%s (%s hours daylight)" |
| 648 | (if (car l) | 649 | (if (car l) |
| 649 | (concat "Sunrise " (apply 'solar-time-string (car l))) | 650 | (concat "Sunrise " (apply 'solar-time-string (car l))) |
| 650 | "No sunrise") | 651 | "No sunrise") |
| 651 | (if (cadr l) | 652 | (if (cadr l) |
| 652 | (concat "sunset " (apply 'solar-time-string (cadr l))) | 653 | (concat "sunset " (apply 'solar-time-string (cadr l))) |
| 653 | "no sunset") | 654 | "no sunset") |
| 654 | (eval calendar-location-name) | 655 | (if nolocation "" |
| 656 | (format " at %s" (eval calendar-location-name))) | ||
| 655 | (nth 2 l)))) | 657 | (nth 2 l)))) |
| 656 | 658 | ||
| 657 | (defconst solar-data-list | 659 | (defconst solar-data-list |
| @@ -864,6 +866,27 @@ Accurate to a few seconds." | |||
| 864 | (calendar-date-string date t t) | 866 | (calendar-date-string date t t) |
| 865 | (solar-sunrise-sunset-string date)))) | 867 | (solar-sunrise-sunset-string date)))) |
| 866 | 868 | ||
| 869 | ;;;###cal-autoload | ||
| 870 | (defun calendar-sunrise-sunset-month (&optional event) | ||
| 871 | "Local time of sunrise and sunset for month under cursor or at EVENT." | ||
| 872 | (interactive (list last-nonmenu-event)) | ||
| 873 | (or (and calendar-latitude calendar-longitude calendar-time-zone) | ||
| 874 | (solar-setup)) | ||
| 875 | (let* ((date (calendar-cursor-to-date t event)) | ||
| 876 | (month (car date)) | ||
| 877 | (year (nth 2 date)) | ||
| 878 | (last (calendar-last-day-of-month month year)) | ||
| 879 | (title (format "Sunrise/sunset times for %s %d at %s" | ||
| 880 | (calendar-month-name month) year | ||
| 881 | (eval calendar-location-name)))) | ||
| 882 | (calendar-in-read-only-buffer solar-sunrises-buffer | ||
| 883 | (calendar-set-mode-line title) | ||
| 884 | (insert title ":\n\n") | ||
| 885 | (dotimes (i last) | ||
| 886 | (setq date (list month (1+ i) year)) | ||
| 887 | (insert (format "%s %2d: " (calendar-month-name month t) (1+ i)) | ||
| 888 | (solar-sunrise-sunset-string date t) "\n"))))) | ||
| 889 | |||
| 867 | (defvar date) | 890 | (defvar date) |
| 868 | 891 | ||
| 869 | ;; To be called from diary-list-sexp-entries, where DATE is bound. | 892 | ;; To be called from diary-list-sexp-entries, where DATE is bound. |