diff options
| author | Glenn Morris | 2008-04-01 02:44:52 +0000 |
|---|---|---|
| committer | Glenn Morris | 2008-04-01 02:44:52 +0000 |
| commit | f1e3fbeb91740012f8193211cfb63118d3450ff1 (patch) | |
| tree | 49f14442d8de4c1ca1016edc8c0ff210ddbafe2f | |
| parent | 4bd7ad5f76944cc2c3cebd40747a1546dfcfae2d (diff) | |
| download | emacs-f1e3fbeb91740012f8193211cfb63118d3450ff1.tar.gz emacs-f1e3fbeb91740012f8193211cfb63118d3450ff1.zip | |
(Commentary): Point to calendar.el.
(solar-equinoxes-solstices): Reduce nesting of some lets.
| -rw-r--r-- | lisp/calendar/solar.el | 92 |
1 files changed, 44 insertions, 48 deletions
diff --git a/lisp/calendar/solar.el b/lisp/calendar/solar.el index e11e0332636..3d8b1d4f8ba 100644 --- a/lisp/calendar/solar.el +++ b/lisp/calendar/solar.el | |||
| @@ -28,9 +28,8 @@ | |||
| 28 | 28 | ||
| 29 | ;;; Commentary: | 29 | ;;; Commentary: |
| 30 | 30 | ||
| 31 | ;; This collection of functions implements the features of calendar.el, | 31 | ;; See calendar.el. This file implements features that deal with |
| 32 | ;; diary.el, and holiday.el that deal with times of day, sunrise/sunset, and | 32 | ;; times of day, sunrise/sunset, and equinoxes/solstices. |
| 33 | ;; equinoxes/solstices. | ||
| 34 | 33 | ||
| 35 | ;; Based on the ``Almanac for Computers 1984,'' prepared by the Nautical | 34 | ;; Based on the ``Almanac for Computers 1984,'' prepared by the Nautical |
| 36 | ;; Almanac Office, United States Naval Observatory, Washington, 1984, on | 35 | ;; Almanac Office, United States Naval Observatory, Washington, 1984, on |
| @@ -48,10 +47,6 @@ | |||
| 48 | ;; 2. Equinox/solstice times will be accurate to the minute for years | 47 | ;; 2. Equinox/solstice times will be accurate to the minute for years |
| 49 | ;; 1951--2050. For other years the times will be within +/- 1 minute. | 48 | ;; 1951--2050. For other years the times will be within +/- 1 minute. |
| 50 | 49 | ||
| 51 | ;; Technical details of all the calendrical calculations can be found in | ||
| 52 | ;; ``Calendrical Calculations: The Millennium Edition'' by Edward M. Reingold | ||
| 53 | ;; and Nachum Dershowitz, Cambridge University Press (2001). | ||
| 54 | |||
| 55 | ;;; Code: | 50 | ;;; Code: |
| 56 | 51 | ||
| 57 | (require 'calendar) | 52 | (require 'calendar) |
| @@ -1018,47 +1013,48 @@ solstice. These formulae are only to be used between 1000 BC and 3000 AD." | |||
| 1018 | (defun solar-equinoxes-solstices () | 1013 | (defun solar-equinoxes-solstices () |
| 1019 | "Local date and time of equinoxes and solstices, if visible in the calendar. | 1014 | "Local date and time of equinoxes and solstices, if visible in the calendar. |
| 1020 | Requires floating point." | 1015 | Requires floating point." |
| 1021 | (let ((m displayed-month) | 1016 | (let* ((m displayed-month) |
| 1022 | (y displayed-year)) | 1017 | (y displayed-year) |
| 1023 | (increment-calendar-month m y (cond ((= 1 (% m 3)) -1) | 1018 | (calendar-standard-time-zone-name |
| 1024 | ((= 2 (% m 3)) 1) | 1019 | (if calendar-time-zone calendar-standard-time-zone-name "UTC")) |
| 1025 | (t 0))) | 1020 | (calendar-daylight-savings-starts |
| 1026 | (let* ((calendar-standard-time-zone-name | 1021 | (if calendar-time-zone calendar-daylight-savings-starts)) |
| 1027 | (if calendar-time-zone calendar-standard-time-zone-name "UTC")) | 1022 | (calendar-daylight-savings-ends |
| 1028 | (calendar-daylight-savings-starts | 1023 | (if calendar-time-zone calendar-daylight-savings-ends)) |
| 1029 | (if calendar-time-zone calendar-daylight-savings-starts)) | 1024 | (calendar-time-zone (if calendar-time-zone calendar-time-zone 0)) |
| 1030 | (calendar-daylight-savings-ends | 1025 | (k (progn |
| 1031 | (if calendar-time-zone calendar-daylight-savings-ends)) | 1026 | (increment-calendar-month m y (cond ((= 1 (% m 3)) -1) |
| 1032 | (calendar-time-zone (if calendar-time-zone calendar-time-zone 0)) | 1027 | ((= 2 (% m 3)) 1) |
| 1033 | (k (1- (/ m 3))) | 1028 | (t 0))) |
| 1034 | (d0 (solar-equinoxes/solstices k y)) | 1029 | (1- (/ m 3)))) |
| 1035 | (d1 (list (car d0) (floor (cadr d0)) (nth 2 d0))) | 1030 | (d0 (solar-equinoxes/solstices k y)) |
| 1036 | (h0 (* 24 (- (cadr d0) (floor (cadr d0))))) | 1031 | (d1 (list (car d0) (floor (cadr d0)) (nth 2 d0))) |
| 1037 | (adj (dst-adjust-time d1 h0)) | 1032 | (h0 (* 24 (- (cadr d0) (floor (cadr d0))))) |
| 1038 | (d (list (caar adj) | 1033 | (adj (dst-adjust-time d1 h0)) |
| 1039 | (+ (car (cdar adj)) | 1034 | (d (list (caar adj) |
| 1040 | (/ (cadr adj) 24.0)) | 1035 | (+ (car (cdar adj)) |
| 1041 | (cadr (cdar adj)))) | 1036 | (/ (cadr adj) 24.0)) |
| 1042 | ;; The following is nearly as accurate, but not quite: | 1037 | (cadr (cdar adj)))) |
| 1043 | ;; (d0 (solar-date-next-longitude | 1038 | ;; The following is nearly as accurate, but not quite: |
| 1044 | ;; (calendar-astro-from-absolute | 1039 | ;; (d0 (solar-date-next-longitude |
| 1045 | ;; (calendar-absolute-from-gregorian | 1040 | ;; (calendar-astro-from-absolute |
| 1046 | ;; (list (+ 3 (* k 3)) 15 y))) | 1041 | ;; (calendar-absolute-from-gregorian |
| 1047 | ;; 90)) | 1042 | ;; (list (+ 3 (* k 3)) 15 y))) |
| 1048 | ;; (abs-day (calendar-absolute-from-astro d))) | 1043 | ;; 90)) |
| 1049 | (abs-day (calendar-absolute-from-gregorian d))) | 1044 | ;; (abs-day (calendar-absolute-from-astro d))) |
| 1050 | (list | 1045 | (abs-day (calendar-absolute-from-gregorian d))) |
| 1051 | (list (calendar-gregorian-from-absolute (floor abs-day)) | 1046 | (list |
| 1052 | (format "%s %s" | 1047 | (list (calendar-gregorian-from-absolute (floor abs-day)) |
| 1053 | (nth k (if (and calendar-latitude | 1048 | (format "%s %s" |
| 1054 | (< (calendar-latitude) 0)) | 1049 | (nth k (if (and calendar-latitude |
| 1055 | solar-s-hemi-seasons | 1050 | (< (calendar-latitude) 0)) |
| 1056 | solar-n-hemi-seasons)) | 1051 | solar-s-hemi-seasons |
| 1057 | (solar-time-string | 1052 | solar-n-hemi-seasons)) |
| 1058 | (* 24 (- abs-day (floor abs-day))) | 1053 | (solar-time-string |
| 1059 | (if (dst-in-effect abs-day) | 1054 | (* 24 (- abs-day (floor abs-day))) |
| 1060 | calendar-daylight-time-zone-name | 1055 | (if (dst-in-effect abs-day) |
| 1061 | calendar-standard-time-zone-name)))))))) | 1056 | calendar-daylight-time-zone-name |
| 1057 | calendar-standard-time-zone-name))))))) | ||
| 1062 | 1058 | ||
| 1063 | 1059 | ||
| 1064 | (provide 'solar) | 1060 | (provide 'solar) |