diff options
| author | Paul Eggert | 1993-08-29 17:28:19 +0000 |
|---|---|---|
| committer | Paul Eggert | 1993-08-29 17:28:19 +0000 |
| commit | 3a2e3ab5ba7d7a8d9d1410fe60aa1bc159410b35 (patch) | |
| tree | 06b29da8b12ee77ae9ee1885cede88e462afedd3 | |
| parent | 6bc457fea523673a7f898e9e14d3c652b3d66653 (diff) | |
| download | emacs-3a2e3ab5ba7d7a8d9d1410fe60aa1bc159410b35.tar.gz emacs-3a2e3ab5ba7d7a8d9d1410fe60aa1bc159410b35.zip | |
Use integers instead of floating point where they will do.
(solar-equinoxes-solstices): Invert seasons in southern hemisphere.
(solar-degrees-to-quadrant): Use `floor' instead of `truncate'.
| -rw-r--r-- | lisp/calendar/solar.el | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lisp/calendar/solar.el b/lisp/calendar/solar.el index 61f3b6c4260..ccfb4a34464 100644 --- a/lisp/calendar/solar.el +++ b/lisp/calendar/solar.el | |||
| @@ -145,7 +145,7 @@ Returns nil if nothing was entered." | |||
| 145 | 145 | ||
| 146 | (defun solar-degrees-to-quadrant (angle) | 146 | (defun solar-degrees-to-quadrant (angle) |
| 147 | "Determines the quadrant of ANGLE." | 147 | "Determines the quadrant of ANGLE." |
| 148 | (1+ (truncate (/ (mod angle 360.0) 90.0)))) | 148 | (1+ (floor (mod angle 360) 90))) |
| 149 | 149 | ||
| 150 | (defun solar-arctan (x quad) | 150 | (defun solar-arctan (x quad) |
| 151 | "Arctangent of X in quadrant QUAD." | 151 | "Arctangent of X in quadrant QUAD." |
| @@ -188,7 +188,7 @@ Returns nil if nothing was entered." | |||
| 188 | (* 1.916 (solar-sin-degrees mean-anomaly)) | 188 | (* 1.916 (solar-sin-degrees mean-anomaly)) |
| 189 | (* 0.020 (solar-sin-degrees (* 2 mean-anomaly))) | 189 | (* 0.020 (solar-sin-degrees (* 2 mean-anomaly))) |
| 190 | 282.634) | 190 | 282.634) |
| 191 | 360.0))) | 191 | 360))) |
| 192 | 192 | ||
| 193 | (defun solar-right-ascension (longitude) | 193 | (defun solar-right-ascension (longitude) |
| 194 | "Right ascension of the sun, given its LONGITUDE." | 194 | "Right ascension of the sun, given its LONGITUDE." |
| @@ -231,7 +231,7 @@ of hours. Returns nil if the sun does not rise at that location on that day." | |||
| 231 | (mod (- (+ local-sunrise solar-right-ascension-at-sunrise) | 231 | (mod (- (+ local-sunrise solar-right-ascension-at-sunrise) |
| 232 | (+ (* 0.065710 approx-sunrise) | 232 | (+ (* 0.065710 approx-sunrise) |
| 233 | 6.622)) | 233 | 6.622)) |
| 234 | 24.0))) | 234 | 24))) |
| 235 | (+ (- local-mean-sunrise (solar-degrees-to-hours calendar-longitude)) | 235 | (+ (- local-mean-sunrise (solar-degrees-to-hours calendar-longitude)) |
| 236 | (/ calendar-time-zone 60.0)))))) | 236 | (/ calendar-time-zone 60.0)))))) |
| 237 | 237 | ||
| @@ -262,7 +262,7 @@ of hours. Returns nil if the sun does not set at that location on that day." | |||
| 262 | (local-mean-sunset | 262 | (local-mean-sunset |
| 263 | (mod (- (+ local-sunset solar-right-ascension-at-sunset) | 263 | (mod (- (+ local-sunset solar-right-ascension-at-sunset) |
| 264 | (+ (* 0.065710 approx-sunset) 6.622)) | 264 | (+ (* 0.065710 approx-sunset) 6.622)) |
| 265 | 24.0))) | 265 | 24))) |
| 266 | (+ (- local-mean-sunset (solar-degrees-to-hours calendar-longitude)) | 266 | (+ (- local-mean-sunset (solar-degrees-to-hours calendar-longitude)) |
| 267 | (/ calendar-time-zone 60.0)))))) | 267 | (/ calendar-time-zone 60.0)))))) |
| 268 | 268 | ||
| @@ -372,7 +372,7 @@ several minutes." | |||
| 372 | app | 372 | app |
| 373 | (correction 1000)) | 373 | (correction 1000)) |
| 374 | (while (> correction 0.00001) | 374 | (while (> correction 0.00001) |
| 375 | (setq app (mod (solar-apparent-longitude-of-sun date) 360.0)) | 375 | (setq app (mod (solar-apparent-longitude-of-sun date) 360)) |
| 376 | (setq correction (* 58 (solar-sin-degrees (- (* k 90) app)))) | 376 | (setq correction (* 58 (solar-sin-degrees (- (* k 90) app)))) |
| 377 | (setq date (list (extract-calendar-month date) | 377 | (setq date (list (extract-calendar-month date) |
| 378 | (+ (extract-calendar-day date) correction) | 378 | (+ (extract-calendar-day date) correction) |
| @@ -489,18 +489,24 @@ Requires floating point." | |||
| 489 | (date (solar-equinoxes/solstices k y)) | 489 | (date (solar-equinoxes/solstices k y)) |
| 490 | (day (extract-calendar-day date)) | 490 | (day (extract-calendar-day date)) |
| 491 | (time (* 24 (- day (truncate day)))) | 491 | (time (* 24 (- day (truncate day)))) |
| 492 | (s-hemi (and calendar-latitude (< calendar-latitude 0))) | ||
| 492 | ;; Time zone/DST can't move the date out of range, | 493 | ;; Time zone/DST can't move the date out of range, |
| 493 | ;; so let solar-time-string do the conversion. | 494 | ;; so let solar-time-string do the conversion. |
| 494 | (date (list (extract-calendar-month date) | 495 | (date (list (extract-calendar-month date) |
| 495 | (truncate day) | 496 | (truncate day) |
| 496 | (extract-calendar-year date)))) | 497 | (extract-calendar-year date)))) |
| 497 | (list (list date | 498 | (list |
| 498 | (format "%s %s" | 499 | (list date |
| 499 | (cond ((= k 0) "Vernal Equinox") | 500 | (format "%s %s" |
| 500 | ((= k 1) "Summer Solstice") | 501 | (cond ((= k 0) |
| 501 | ((= k 2) "Fall Equinox") | 502 | (if s-hemi "Autumnal Equinox" "Vernal Equinox")) |
| 502 | ((= k 3) "Winter Solstice")) | 503 | ((= k 1) |
| 503 | (solar-time-string time date))))))) | 504 | (if s-hemi "Winter Solstice" "Summer Solstice")) |
| 505 | ((= k 2) | ||
| 506 | (if s-hemi "Vernal Equinox" "Autumnal Equinox")) | ||
| 507 | ((= k 3) | ||
| 508 | (if s-hemi "Summer Solstice" "Winter Solstice"))) | ||
| 509 | (solar-time-string time date))))))) | ||
| 504 | 510 | ||
| 505 | (provide 'solar) | 511 | (provide 'solar) |
| 506 | 512 | ||