Mercurial > emacs
annotate lisp/calendar/solar.el @ 110585:677b6dea1d61
gnus-sum.el (gnus-auto-center-group): Transform into a defcustom.
gnus.el (gnus-group-fast-parameter): Return the last matching parameter instead of the first matching parameter.
auth-source.el (auth-source-user-or-password): Query for password, although there are no existing auth sources.
auth-source.el (auth-source-user-or-password): Use the existing auth sources, if any, for creation.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Sun, 26 Sep 2010 12:47:09 +0000 |
parents | b799d38f522a |
children | 417b1e4d63cd |
rev | line source |
---|---|
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
20462
diff
changeset
|
1 ;;; solar.el --- calendar functions for solar events |
956 | 2 |
68721 | 3 ;; Copyright (C) 1992, 1993, 1995, 1997, 2001, 2002, 2003, 2004, 2005, |
106815 | 4 ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
956 | 5 |
6 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu> | |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
7 ;; Denis B. Roegel <Denis.Roegel@loria.fr> |
65919
5c09efcfc1d9
Update maintainer email address.
Glenn Morris <rgm@gnu.org>
parents:
65145
diff
changeset
|
8 ;; Maintainer: Glenn Morris <rgm@gnu.org> |
2249
94fc2ce49c55
Corrected Keywords header
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2248
diff
changeset
|
9 ;; Keywords: calendar |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
10 ;; Human-Keywords: sunrise, sunset, equinox, solstice, calendar, diary, holidays |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
11 ;; Package: calendar |
956 | 12 |
13 ;; This file is part of GNU Emacs. | |
14 | |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93809
diff
changeset
|
15 ;; GNU Emacs is free software: you can redistribute it and/or modify |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5835
diff
changeset
|
16 ;; it under the terms of the GNU General Public License as published by |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93809
diff
changeset
|
17 ;; the Free Software Foundation, either version 3 of the License, or |
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93809
diff
changeset
|
18 ;; (at your option) any later version. |
956 | 19 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5835
diff
changeset
|
20 ;; GNU Emacs is distributed in the hope that it will be useful, |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5835
diff
changeset
|
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5835
diff
changeset
|
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5835
diff
changeset
|
23 ;; GNU General Public License for more details. |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5835
diff
changeset
|
24 |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
5835
diff
changeset
|
25 ;; You should have received a copy of the GNU General Public License |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93809
diff
changeset
|
26 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
956 | 27 |
28 ;;; Commentary: | |
29 | |
93490
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
30 ;; See calendar.el. This file implements features that deal with |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
31 ;; times of day, sunrise/sunset, and equinoxes/solstices. |
956 | 32 |
33 ;; Based on the ``Almanac for Computers 1984,'' prepared by the Nautical | |
13045
2779e3cf6cfa
Added code to support Chinese calendar. Minor fixes as well.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
12908
diff
changeset
|
34 ;; Almanac Office, United States Naval Observatory, Washington, 1984, on |
2779e3cf6cfa
Added code to support Chinese calendar. Minor fixes as well.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
12908
diff
changeset
|
35 ;; ``Astronomical Formulae for Calculators,'' 3rd ed., by Jean Meeus, |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
36 ;; Willmann-Bell, Inc., 1985, on ``Astronomical Algorithms'' by Jean Meeus, |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
37 ;; Willmann-Bell, Inc., 1991, and on ``Planetary Programs and Tables from |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
38 ;; -4000 to +2800'' by Pierre Bretagnon and Jean-Louis Simon, Willmann-Bell, |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
39 ;; Inc., 1986. |
13045
2779e3cf6cfa
Added code to support Chinese calendar. Minor fixes as well.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
12908
diff
changeset
|
40 |
956 | 41 ;; |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
42 ;; Accuracy: |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
43 ;; 1. Sunrise/sunset times will be accurate to the minute for years |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
44 ;; 1951--2050. For other years the times will be within +/- 2 minutes. |
956 | 45 ;; |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
46 ;; 2. Equinox/solstice times will be accurate to the minute for years |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
47 ;; 1951--2050. For other years the times will be within +/- 1 minute. |
956 | 48 |
49 ;;; Code: | |
50 | |
93230 | 51 (require 'calendar) |
3866
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
52 (require 'cal-dst) |
93641
8a8d2922328b
Update for cal-julian name changes.
Glenn Morris <rgm@gnu.org>
parents:
93490
diff
changeset
|
53 ;; calendar-astro-to-absolute and v versa are cal-autoloads. |
93230 | 54 ;;;(require 'cal-julian) |
3866
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
55 |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
56 |
17626 | 57 (defcustom calendar-time-display-form |
3866
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
58 '(12-hours ":" minutes am-pm |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
59 (if time-zone " (") time-zone (if time-zone ")")) |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
60 "The pseudo-pattern that governs the way a time of day is formatted. |
3866
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
61 |
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
62 A pseudo-pattern is a list of expressions that can involve the keywords |
47252
0fcc52168240
(calendar-time-display-form): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents:
46617
diff
changeset
|
63 `12-hours', `24-hours', and `minutes', all numbers in string form, |
0fcc52168240
(calendar-time-display-form): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents:
46617
diff
changeset
|
64 and `am-pm' and `time-zone', both alphabetic strings. |
3866
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
65 |
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
66 For example, the form |
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
67 |
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
68 '(24-hours \":\" minutes |
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
69 (if time-zone \" (\") time-zone (if time-zone \")\")) |
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
70 |
17626 | 71 would give military-style times like `21:07 (UTC)'." |
72 :type 'sexp | |
73 :group 'calendar) | |
3866
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
74 |
17626 | 75 (defcustom calendar-latitude nil |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
76 "Latitude of `calendar-location-name' in degrees. |
9714
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
77 The value can be either a decimal fraction (one place of accuracy is |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
78 sufficient), + north, - south, such as 40.7 for New York City, or the value |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
79 can be a vector [degrees minutes north/south] such as [40 50 north] for New |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
80 York City. |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
81 |
17626 | 82 This variable should be set in `site-start'.el." |
83 :type '(choice (const nil) | |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
84 (number :tag "Exact") |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
85 (vector :value [0 0 north] |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
86 (integer :tag "Degrees") |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
87 (integer :tag "Minutes") |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
88 (choice :tag "Position" |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
89 (const north) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
90 (const south)))) |
17626 | 91 :group 'calendar) |
3866
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
92 |
17626 | 93 (defcustom calendar-longitude nil |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
94 "Longitude of `calendar-location-name' in degrees. |
9714
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
95 The value can be either a decimal fraction (one place of accuracy is |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
96 sufficient), + east, - west, such as -73.9 for New York City, or the value |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
97 can be a vector [degrees minutes east/west] such as [73 55 west] for New |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
98 York City. |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
99 |
17626 | 100 This variable should be set in `site-start'.el." |
101 :type '(choice (const nil) | |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
102 (number :tag "Exact") |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
103 (vector :value [0 0 west] |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
104 (integer :tag "Degrees") |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
105 (integer :tag "Minutes") |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
106 (choice :tag "Position" |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
107 (const east) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
108 (const west)))) |
17626 | 109 :group 'calendar) |
9714
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
110 |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
111 (defcustom calendar-location-name |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
112 '(let ((float-output-format "%.1f")) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
113 (format "%s%s, %s%s" |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
114 (if (numberp calendar-latitude) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
115 (abs calendar-latitude) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
116 (+ (aref calendar-latitude 0) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
117 (/ (aref calendar-latitude 1) 60.0))) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
118 (if (numberp calendar-latitude) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
119 (if (> calendar-latitude 0) "N" "S") |
93093
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
120 (if (eq (aref calendar-latitude 2) 'north) "N" "S")) |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
121 (if (numberp calendar-longitude) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
122 (abs calendar-longitude) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
123 (+ (aref calendar-longitude 0) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
124 (/ (aref calendar-longitude 1) 60.0))) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
125 (if (numberp calendar-longitude) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
126 (if (> calendar-longitude 0) "E" "W") |
93093
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
127 (if (eq (aref calendar-longitude 2) 'east) "E" "W")))) |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
128 "Expression evaluating to the name of the calendar location. |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
129 For example, \"New York City\". The default value is just the |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
130 variable `calendar-latitude' paired with the variable `calendar-longitude'. |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
131 |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
132 This variable should be set in `site-start'.el." |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
133 :type 'sexp |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
134 :group 'calendar) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
135 |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
136 (defcustom solar-error 0.5 |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
137 "Tolerance (in minutes) for sunrise/sunset calculations. |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
138 |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
139 A larger value makes the calculations for sunrise/sunset faster, but less |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
140 accurate. The default is half a minute (30 seconds), so that sunrise/sunset |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
141 times will be correct to the minute. |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
142 |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
143 It is useless to set the value smaller than 4*delta, where delta is the |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
144 accuracy in the longitude of the sun (given by the function |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
145 `solar-ecliptic-coordinates') in degrees since (delta/360) x (86400/60) = 4 x |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
146 delta. At present, delta = 0.01 degrees, so the value of the variable |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
147 `solar-error' should be at least 0.04 minutes (about 2.5 seconds)." |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
148 :type 'number |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
149 :group 'calendar) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
150 |
103318
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
151 (defcustom solar-n-hemi-seasons |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
152 '("Vernal Equinox" "Summer Solstice" "Autumnal Equinox" "Winter Solstice") |
103318
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
153 "List of season changes for the northern hemisphere." |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
154 :type '(list |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
155 (string :tag "Vernal Equinox") |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
156 (string :tag "Summer Solstice") |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
157 (string :tag "Autumnal Equinox") |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
158 (string :tag "Winter Solstice")) |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
159 :group 'calendar) |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
160 |
103318
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
161 (defcustom solar-s-hemi-seasons |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
162 '("Autumnal Equinox" "Winter Solstice" "Vernal Equinox" "Summer Solstice") |
103318
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
163 "List of season changes for the southern hemisphere." |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
164 :type '(list |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
165 (string :tag "Autumnal Equinox") |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
166 (string :tag "Winter Solstice") |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
167 (string :tag "Vernal Equinox") |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
168 (string :tag "Summer Solstice")) |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
169 :group 'calendar) |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
170 |
e47b96db18de
(solar-n-hemi-seasons, solar-s-hemi-seasons):
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
171 ;;; End of user options. |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
172 |
92996 | 173 (defvar solar-sidereal-time-greenwich-midnight nil |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
174 "Sidereal time at Greenwich at midnight (universal time).") |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
175 |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
176 (defvar solar-northern-spring-or-summer-season nil |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
177 "Non-nil if northern spring or summer and nil otherwise. |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
178 Needed for polar areas, in order to know whether the day lasts 0 or 24 hours.") |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
179 |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
180 |
9714
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
181 (defsubst calendar-latitude () |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
182 "Ensure the variable `calendar-latitude' is a signed decimal fraction." |
9714
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
183 (if (numberp calendar-latitude) |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
184 calendar-latitude |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
185 (let ((lat (+ (aref calendar-latitude 0) |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
186 (/ (aref calendar-latitude 1) 60.0)))) |
93093
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
187 (if (eq (aref calendar-latitude 2) 'north) |
9714
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
188 lat |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
189 (- lat))))) |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
190 |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
191 (defsubst calendar-longitude () |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
192 "Ensure the variable `calendar-longitude' is a signed decimal fraction." |
9714
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
193 (if (numberp calendar-longitude) |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
194 calendar-longitude |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
195 (let ((long (+ (aref calendar-longitude 0) |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
196 (/ (aref calendar-longitude 1) 60.0)))) |
93093
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
197 (if (eq (aref calendar-longitude 2) 'east) |
9714
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
198 long |
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
199 (- long))))) |
3866
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
200 |
92928
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
201 (defun solar-get-number (prompt) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
202 "Return a number from the minibuffer, prompting with PROMPT. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
203 Returns nil if nothing was entered." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
204 (let ((x (read-string prompt ""))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
205 (unless (string-equal x "") |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
206 (string-to-number x)))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
207 |
956 | 208 (defun solar-setup () |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
209 "Prompt for `calendar-longitude', `calendar-latitude', `calendar-time-zone'." |
956 | 210 (beep) |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
211 (or calendar-longitude |
956 | 212 (setq calendar-longitude |
213 (solar-get-number | |
214 "Enter longitude (decimal fraction; + east, - west): "))) | |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
215 (or calendar-latitude |
956 | 216 (setq calendar-latitude |
217 (solar-get-number | |
218 "Enter latitude (decimal fraction; + north, - south): "))) | |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
219 (or calendar-time-zone |
956 | 220 (setq calendar-time-zone |
221 (solar-get-number | |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
222 "Enter difference from Coordinated Universal Time (in minutes): ") |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
223 ))) |
956 | 224 |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
225 (defun solar-sin-degrees (x) |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
226 "Return sin of X degrees." |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
227 (sin (degrees-to-radians (mod x 360.0)))) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
228 |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
229 (defun solar-cosine-degrees (x) |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
230 "Return cosine of X degrees." |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
231 (cos (degrees-to-radians (mod x 360.0)))) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
232 |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
233 (defun solar-tangent-degrees (x) |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
234 "Return tangent of X degrees." |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
235 (tan (degrees-to-radians (mod x 360.0)))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48674
diff
changeset
|
236 |
956 | 237 (defun solar-xy-to-quadrant (x y) |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
238 "Determine the quadrant of the point X, Y." |
956 | 239 (if (> x 0) |
240 (if (> y 0) 1 4) | |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
241 (if (> y 0) 2 3))) |
956 | 242 |
243 (defun solar-degrees-to-quadrant (angle) | |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
244 "Determine the quadrant of ANGLE degrees." |
4660
2516bc453477
Use integers instead of floating point where they will do.
Paul Eggert <eggert@twinsun.com>
parents:
4657
diff
changeset
|
245 (1+ (floor (mod angle 360) 90))) |
956 | 246 |
247 (defun solar-arctan (x quad) | |
248 "Arctangent of X in quadrant QUAD." | |
249 (let ((deg (radians-to-degrees (atan x)))) | |
93093
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
250 (cond ((= quad 2) (+ deg 180)) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
251 ((= quad 3) (+ deg 180)) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
252 ((= quad 4) (+ deg 360)) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
253 (t deg)))) |
956 | 254 |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
255 (defun solar-atn2 (x y) |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
256 "Arctangent of point X, Y." |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
257 (if (zerop x) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
258 (if (> y 0) 90 270) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
259 (solar-arctan (/ y x) (solar-xy-to-quadrant x y)))) |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
260 |
956 | 261 (defun solar-arccos (x) |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
262 "Arccosine of X." |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
263 (let ((y (sqrt (- 1 (* x x))))) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
264 (solar-atn2 x y))) |
956 | 265 |
266 (defun solar-arcsin (y) | |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
267 "Arcsin of Y." |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
268 (let ((x (sqrt (- 1 (* y y))))) |
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
269 (solar-atn2 x y))) |
956 | 270 |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
271 (defsubst solar-degrees-to-hours (degrees) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
272 "Convert DEGREES to hours." |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
273 (/ degrees 15.0)) |
956 | 274 |
9714
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
275 (defsubst solar-hours-to-days (hour) |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
276 "Convert HOUR to decimal fraction of a day." |
9714
c14b023ca6fe
Allow vector form of latitude/longitude. Fix documentation.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7778
diff
changeset
|
277 (/ hour 24.0)) |
956 | 278 |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
279 (defun solar-right-ascension (longitude obliquity) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
280 "Right ascension of the sun, in hours, given LONGITUDE and OBLIQUITY. |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
281 Both arguments are in degrees." |
956 | 282 (solar-degrees-to-hours |
283 (solar-arctan | |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
284 (* (solar-cosine-degrees obliquity) (solar-tangent-degrees longitude)) |
956 | 285 (solar-degrees-to-quadrant longitude)))) |
286 | |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
287 (defun solar-declination (longitude obliquity) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
288 "Declination of the sun, in degrees, given LONGITUDE and OBLIQUITY. |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
289 Both arguments are in degrees." |
956 | 290 (solar-arcsin |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
291 (* (solar-sin-degrees obliquity) |
956 | 292 (solar-sin-degrees longitude)))) |
293 | |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
294 (defun solar-ecliptic-coordinates (time sunrise-flag) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
295 "Return solar longitude, ecliptic inclination, equation of time, nutation. |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
296 Values are for TIME in Julian centuries of Ephemeris Time since |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
297 January 1st, 2000, at 12 ET. Longitude and inclination are in |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
298 degrees, equation of time in hours, and nutation in seconds of longitude. |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
299 If SUNRISE-FLAG is non-nil, only calculate longitude and inclination." |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
300 (let* ((l (+ 280.46645 |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
301 (* 36000.76983 time) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48674
diff
changeset
|
302 (* 0.0003032 time time))) ; sun mean longitude |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
303 (ml (+ 218.3165 |
92657 | 304 (* 481267.8813 time))) ; moon mean longitude |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
305 (m (+ 357.52910 |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
306 (* 35999.05030 time) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
307 (* -0.0001559 time time) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48674
diff
changeset
|
308 (* -0.00000048 time time time))) ; sun mean anomaly |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
309 (i (+ 23.43929111 (* -0.013004167 time) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
310 (* -0.00000016389 time time) |
92657 | 311 (* 0.0000005036 time time time))) ; mean inclination |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
312 (c (+ (* (+ 1.914600 |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
313 (* -0.004817 time) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
314 (* -0.000014 time time)) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
315 (solar-sin-degrees m)) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
316 (* (+ 0.019993 (* -0.000101 time)) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
317 (solar-sin-degrees (* 2 m))) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
318 (* 0.000290 |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48674
diff
changeset
|
319 (solar-sin-degrees (* 3 m))))) ; center equation |
92657 | 320 (L (+ l c)) ; total longitude |
321 ;; Longitude of moon's ascending node on the ecliptic. | |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
322 (omega (+ 125.04 |
92657 | 323 (* -1934.136 time))) |
324 ;; nut = nutation in longitude, measured in seconds of angle. | |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
325 (nut (unless sunrise-flag |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
326 (+ (* -17.20 (solar-sin-degrees omega)) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
327 (* -1.32 (solar-sin-degrees (* 2 l))) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
328 (* -0.23 (solar-sin-degrees (* 2 ml))) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
329 (* 0.21 (solar-sin-degrees (* 2 omega)))))) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
330 (ecc (unless sunrise-flag ; eccentricity of earth's orbit |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
331 (+ 0.016708617 |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
332 (* -0.000042037 time) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
333 (* -0.0000001236 time time)))) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
334 (app (+ L ; apparent longitude of sun |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
335 -0.00569 |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
336 (* -0.00478 |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
337 (solar-sin-degrees omega)))) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
338 (y (unless sunrise-flag |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
339 (* (solar-tangent-degrees (/ i 2)) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
340 (solar-tangent-degrees (/ i 2))))) |
92657 | 341 ;; Equation of time, in hours. |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
342 (time-eq (unless sunrise-flag |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
343 (/ (* 12 (+ (* y (solar-sin-degrees (* 2 l))) |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
344 (* -2 ecc (solar-sin-degrees m)) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
345 (* 4 ecc y (solar-sin-degrees m) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
346 (solar-cosine-degrees (* 2 l))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
347 (* -0.5 y y (solar-sin-degrees (* 4 l))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
348 (* -1.25 ecc ecc (solar-sin-degrees (* 2 m))))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
349 3.1415926535)))) |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
350 (list app i time-eq nut))) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
351 |
92928
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
352 (defun solar-ephemeris-correction (year) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
353 "Ephemeris time minus Universal Time during Gregorian YEAR. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
354 Result is in days. For the years 1800-1987, the maximum error is |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
355 1.9 seconds. For the other years, the maximum error is about 30 seconds." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
356 (cond ((and (<= 1988 year) (< year 2020)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
357 (/ (+ year -2000 67.0) 60.0 60.0 24.0)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
358 ((and (<= 1900 year) (< year 1988)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
359 (let* ((theta (/ (- (calendar-astro-from-absolute |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
360 (calendar-absolute-from-gregorian |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
361 (list 7 1 year))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
362 (calendar-astro-from-absolute |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
363 (calendar-absolute-from-gregorian |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
364 '(1 1 1900)))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
365 36525.0)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
366 (theta2 (* theta theta)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
367 (theta3 (* theta2 theta)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
368 (theta4 (* theta2 theta2)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
369 (theta5 (* theta3 theta2))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
370 (+ -0.00002 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
371 (* 0.000297 theta) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
372 (* 0.025184 theta2) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
373 (* -0.181133 theta3) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
374 (* 0.553040 theta4) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
375 (* -0.861938 theta5) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
376 (* 0.677066 theta3 theta3) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
377 (* -0.212591 theta4 theta3)))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
378 ((and (<= 1800 year) (< year 1900)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
379 (let* ((theta (/ (- (calendar-astro-from-absolute |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
380 (calendar-absolute-from-gregorian |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
381 (list 7 1 year))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
382 (calendar-astro-from-absolute |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
383 (calendar-absolute-from-gregorian |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
384 '(1 1 1900)))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
385 36525.0)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
386 (theta2 (* theta theta)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
387 (theta3 (* theta2 theta)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
388 (theta4 (* theta2 theta2)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
389 (theta5 (* theta3 theta2))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
390 (+ -0.000009 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
391 (* 0.003844 theta) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
392 (* 0.083563 theta2) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
393 (* 0.865736 theta3) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
394 (* 4.867575 theta4) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
395 (* 15.845535 theta5) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
396 (* 31.332267 theta3 theta3) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
397 (* 38.291999 theta4 theta3) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
398 (* 28.316289 theta4 theta4) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
399 (* 11.636204 theta4 theta5) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
400 (* 2.043794 theta5 theta5)))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
401 ((and (<= 1620 year) (< year 1800)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
402 (let ((x (/ (- year 1600) 10.0))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
403 (/ (+ (* 2.19167 x x) (* -40.675 x) 196.58333) 60.0 60.0 24.0))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
404 (t (let* ((tmp (- (calendar-astro-from-absolute |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
405 (calendar-absolute-from-gregorian |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
406 (list 1 1 year))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
407 2382148)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
408 (second (- (/ (* tmp tmp) 41048480.0) 15))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
409 (/ second 60.0 60.0 24.0))))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
410 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
411 (defun solar-ephemeris-time (time) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
412 "Ephemeris Time at moment TIME. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
413 TIME is a pair with the first component being the number of Julian centuries |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
414 elapsed at 0 Universal Time, and the second component being the universal |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
415 time. For instance, the pair corresponding to November 28, 1995 at 16 UT is |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
416 \(-0.040945 16), -0.040945 being the number of Julian centuries elapsed between |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
417 Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
418 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
419 Result is in Julian centuries of ephemeris time." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
420 (let* ((t0 (car time)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
421 (ut (cadr time)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
422 (t1 (+ t0 (/ (/ ut 24.0) 36525))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
423 (y (+ 2000 (* 100 t1))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
424 (dt (* 86400 (solar-ephemeris-correction (floor y))))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
425 (+ t1 (/ (/ dt 86400) 36525)))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
426 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
427 (defun solar-equatorial-coordinates (time sunrise-flag) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
428 "Right ascension (in hours) and declination (in degrees) of the sun at TIME. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
429 TIME is a pair with the first component being the number of |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
430 Julian centuries elapsed at 0 Universal Time, and the second |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
431 component being the universal time. For instance, the pair |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
432 corresponding to November 28, 1995 at 16 UT is (-0.040945 16), |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
433 -0.040945 being the number of Julian centuries elapsed between |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
434 Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT. SUNRISE-FLAG is passed |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
435 to `solar-ecliptic-coordinates'." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
436 (let ((ec (solar-ecliptic-coordinates (solar-ephemeris-time time) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
437 sunrise-flag))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
438 (list (solar-right-ascension (car ec) (cadr ec)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
439 (solar-declination (car ec) (cadr ec))))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
440 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
441 (defun solar-horizontal-coordinates (time latitude longitude sunrise-flag) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
442 "Azimuth and height of the sun at TIME, LATITUDE, and LONGITUDE. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
443 TIME is a pair with the first component being the number of |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
444 Julian centuries elapsed at 0 Universal Time, and the second |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
445 component being the universal time. For instance, the pair |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
446 corresponding to November 28, 1995 at 16 UT is (-0.040945 16), |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
447 -0.040945 being the number of Julian centuries elapsed between |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
448 Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT. SUNRISE-FLAG |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
449 is passed to `solar-ecliptic-coordinates'. Azimuth and |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
450 height (between -180 and 180) are both in degrees." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
451 (let* ((ut (cadr time)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
452 (ec (solar-equatorial-coordinates time sunrise-flag)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
453 (st (+ solar-sidereal-time-greenwich-midnight |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
454 (* ut 1.00273790935))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
455 ;; Hour angle (in degrees). |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
456 (ah (- (* st 15) (* 15 (car ec)) (* -1 (calendar-longitude)))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
457 (de (cadr ec)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
458 (azimuth (solar-atn2 (- (* (solar-cosine-degrees ah) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
459 (solar-sin-degrees latitude)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
460 (* (solar-tangent-degrees de) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
461 (solar-cosine-degrees latitude))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
462 (solar-sin-degrees ah))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
463 (height (solar-arcsin |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
464 (+ (* (solar-sin-degrees latitude) (solar-sin-degrees de)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
465 (* (solar-cosine-degrees latitude) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
466 (solar-cosine-degrees de) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
467 (solar-cosine-degrees ah)))))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
468 (if (> height 180) (setq height (- height 360))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
469 (list azimuth height))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
470 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
471 (defun solar-moment (direction latitude longitude time height) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
472 "Sunrise/sunset at location. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
473 Sunrise if DIRECTION =-1 or sunset if =1 at LATITUDE, LONGITUDE, with midday |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
474 being TIME. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
475 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
476 TIME is a pair with the first component being the number of Julian centuries |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
477 elapsed at 0 Universal Time, and the second component being the universal |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
478 time. For instance, the pair corresponding to November 28, 1995 at 16 UT is |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
479 \(-0.040945 16), -0.040945 being the number of Julian centuries elapsed between |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
480 Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
481 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
482 HEIGHT is the angle the center of the sun has over the horizon for the contact |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
483 we are trying to find. For sunrise and sunset, it is usually -0.61 degrees, |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
484 accounting for the edge of the sun being on the horizon. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
485 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
486 Uses binary search." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
487 (let* ((ut (cadr time)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
488 (possible t) ; we assume that rise or set are possible |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
489 (utmin (+ ut (* direction 12.0))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
490 (utmax ut) ; the time searched is between utmin and utmax |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
491 ;; utmin and utmax are in hours. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
492 (utmoment-old 0.0) ; rise or set approximation |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
493 (utmoment 1.0) ; rise or set approximation |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
494 (hut 0) ; sun height at utmoment |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
495 (t0 (car time)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
496 (hmin (cadr (solar-horizontal-coordinates (list t0 utmin) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
497 latitude longitude t))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
498 (hmax (cadr (solar-horizontal-coordinates (list t0 utmax) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
499 latitude longitude t)))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
500 ;; -0.61 degrees is the height of the middle of the sun, when it |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
501 ;; rises or sets. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
502 (if (< hmin height) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
503 (if (> hmax height) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
504 (while ;;; (< i 20) ; we perform a simple dichotomy |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
505 ;;; (> (abs (- hut height)) epsilon) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
506 (>= (abs (- utmoment utmoment-old)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
507 (/ solar-error 60)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
508 (setq utmoment-old utmoment |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
509 utmoment (/ (+ utmin utmax) 2) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
510 hut (cadr (solar-horizontal-coordinates |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
511 (list t0 utmoment) latitude longitude t))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
512 (if (< hut height) (setq utmin utmoment)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
513 (if (> hut height) (setq utmax utmoment))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
514 (setq possible nil)) ; the sun never rises |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
515 (setq possible nil)) ; the sun never sets |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
516 (if possible utmoment))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
517 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
518 (defun solar-sunrise-and-sunset (time latitude longitude height) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
519 "Sunrise, sunset and length of day. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
520 Parameters are the midday TIME and the LATITUDE, LONGITUDE of the location. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
521 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
522 TIME is a pair with the first component being the number of Julian centuries |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
523 elapsed at 0 Universal Time, and the second component being the universal |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
524 time. For instance, the pair corresponding to November 28, 1995 at 16 UT is |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
525 \(-0.040945 16), -0.040945 being the number of Julian centuries elapsed between |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
526 Jan 1, 2000 at 12 UT and November 28, 1995 at 0 UT. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
527 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
528 HEIGHT is the angle the center of the sun has over the horizon for the contact |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
529 we are trying to find. For sunrise and sunset, it is usually -0.61 degrees, |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
530 accounting for the edge of the sun being on the horizon. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
531 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
532 Coordinates are included because this function is called with latitude=1 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
533 degrees to find out if polar regions have 24 hours of sun or only night." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
534 (let ((rise-time (solar-moment -1 latitude longitude time height)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
535 (set-time (solar-moment 1 latitude longitude time height)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
536 day-length) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
537 (if (not (and rise-time set-time)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
538 (if (or (and (> latitude 0) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
539 solar-northern-spring-or-summer-season) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
540 (and (< latitude 0) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
541 (not solar-northern-spring-or-summer-season))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
542 (setq day-length 24) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
543 (setq day-length 0)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
544 (setq day-length (- set-time rise-time))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
545 (list (if rise-time (+ rise-time (/ calendar-time-zone 60.0)) nil) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
546 (if set-time (+ set-time (/ calendar-time-zone 60.0)) nil) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
547 day-length))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
548 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
549 (defun solar-time-string (time time-zone) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
550 "Printable form for decimal fraction TIME in TIME-ZONE. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
551 Format used is given by `calendar-time-display-form'." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
552 (let* ((time (round (* 60 time))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
553 (24-hours (/ time 60)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
554 (minutes (format "%02d" (% time 60))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
555 (12-hours (format "%d" (1+ (% (+ 24-hours 11) 12)))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
556 (am-pm (if (>= 24-hours 12) "pm" "am")) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
557 (24-hours (format "%02d" 24-hours))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
558 (mapconcat 'eval calendar-time-display-form ""))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
559 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
560 (defun solar-daylight (time) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
561 "Printable form for TIME expressed in hours." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
562 (format "%d:%02d" |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
563 (floor time) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
564 (floor (* 60 (- time (floor time)))))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
565 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
566 (defun solar-julian-ut-centuries (date) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
567 "Number of Julian centuries since 1 Jan, 2000 at noon UT for Gregorian DATE." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
568 (/ (- (calendar-absolute-from-gregorian date) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
569 (calendar-absolute-from-gregorian '(1 1.5 2000))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
570 36525.0)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
571 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
572 (defun solar-date-to-et (date ut) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
573 "Ephemeris Time at Gregorian DATE at Universal Time UT (in hours). |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
574 Expressed in Julian centuries of Ephemeris Time." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
575 (solar-ephemeris-time (list (solar-julian-ut-centuries date) ut))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
576 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
577 (defun solar-time-equation (date ut) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
578 "Equation of time expressed in hours at Gregorian DATE at Universal time UT." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
579 (nth 2 (solar-ecliptic-coordinates (solar-date-to-et date ut) nil))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
580 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
581 (defun solar-exact-local-noon (date) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
582 "Date and Universal Time of local noon at *local date* DATE. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
583 The date may be different from the one asked for, but it will be the right |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
584 local date. The second component of date should be an integer." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
585 (let* ((nd date) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
586 (ut (- 12.0 (/ (calendar-longitude) 15))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
587 (te (solar-time-equation date ut))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
588 (setq ut (- ut te)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
589 (if (>= ut 24) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
590 (setq nd (list (car date) (1+ (cadr date)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
591 (nth 2 date)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
592 ut (- ut 24))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
593 (if (< ut 0) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
594 (setq nd (list (car date) (1- (cadr date)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
595 (nth 2 date)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
596 ut (+ ut 24))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
597 (setq nd (calendar-gregorian-from-absolute ; date standardization |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
598 (calendar-absolute-from-gregorian nd))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
599 (list nd ut))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
600 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
601 (defun solar-sidereal-time (t0) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
602 "Sidereal time (in hours) in Greenwich at T0 Julian centuries. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
603 T0 must correspond to 0 hours UT." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
604 (let* ((mean-sid-time (+ 6.6973746 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
605 (* 2400.051337 t0) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
606 (* 0.0000258622 t0 t0) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
607 (* -0.0000000017222 t0 t0 t0))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
608 (et (solar-ephemeris-time (list t0 0.0))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
609 (nut-i (solar-ecliptic-coordinates et nil)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
610 (nut (nth 3 nut-i)) ; nutation |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
611 (i (cadr nut-i))) ; inclination |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
612 (mod (+ (mod (+ mean-sid-time |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
613 (/ (/ (* nut (solar-cosine-degrees i)) 15) 3600)) 24.0) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
614 24.0) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
615 24.0))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
616 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
617 (defun solar-sunrise-sunset (date) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
618 "List of *local* times of sunrise, sunset, and daylight on Gregorian DATE. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
619 Corresponding value is nil if there is no sunrise/sunset." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
620 ;; First, get the exact moment of local noon. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
621 (let* ((exact-local-noon (solar-exact-local-noon date)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
622 ;; Get the time from the 2000 epoch. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
623 (t0 (solar-julian-ut-centuries (car exact-local-noon))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
624 ;; Store the sidereal time at Greenwich at midnight of UT time. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
625 ;; Find if summer or winter slightly above the equator. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
626 (equator-rise-set |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
627 (progn (setq solar-sidereal-time-greenwich-midnight |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
628 (solar-sidereal-time t0)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
629 (solar-sunrise-and-sunset |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
630 (list t0 (cadr exact-local-noon)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
631 1.0 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
632 (calendar-longitude) 0))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
633 ;; Store the spring/summer information, compute sunrise and |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
634 ;; sunset (two first components of rise-set). Length of day |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
635 ;; is the third component (it is only the difference between |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
636 ;; sunset and sunrise when there is a sunset and a sunrise) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
637 (rise-set |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
638 (progn |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
639 (setq solar-northern-spring-or-summer-season |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
640 (> (nth 2 equator-rise-set) 12)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
641 (solar-sunrise-and-sunset |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
642 (list t0 (cadr exact-local-noon)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
643 (calendar-latitude) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
644 (calendar-longitude) -0.61))) |
92958
5700422f1364
(solar-n-hemi-seasons, solar-s-hemi-seasons): Make constants.
Glenn Morris <rgm@gnu.org>
parents:
92928
diff
changeset
|
645 (rise-time (car rise-set)) |
5700422f1364
(solar-n-hemi-seasons, solar-s-hemi-seasons): Make constants.
Glenn Morris <rgm@gnu.org>
parents:
92928
diff
changeset
|
646 (adj-rise (if rise-time (dst-adjust-time date rise-time))) |
5700422f1364
(solar-n-hemi-seasons, solar-s-hemi-seasons): Make constants.
Glenn Morris <rgm@gnu.org>
parents:
92928
diff
changeset
|
647 (set-time (cadr rise-set)) |
5700422f1364
(solar-n-hemi-seasons, solar-s-hemi-seasons): Make constants.
Glenn Morris <rgm@gnu.org>
parents:
92928
diff
changeset
|
648 (adj-set (if set-time (dst-adjust-time date set-time))) |
92928
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
649 (length (nth 2 rise-set))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
650 (list |
92958
5700422f1364
(solar-n-hemi-seasons, solar-s-hemi-seasons): Make constants.
Glenn Morris <rgm@gnu.org>
parents:
92928
diff
changeset
|
651 (and rise-time (calendar-date-equal date (car adj-rise)) (cdr adj-rise)) |
5700422f1364
(solar-n-hemi-seasons, solar-s-hemi-seasons): Make constants.
Glenn Morris <rgm@gnu.org>
parents:
92928
diff
changeset
|
652 (and set-time (calendar-date-equal date (car adj-set)) (cdr adj-set)) |
92928
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
653 (solar-daylight length)))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
654 |
96344
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
655 (defun solar-sunrise-sunset-string (date &optional nolocation) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
656 "String of *local* times of sunrise, sunset, and daylight on Gregorian DATE. |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
657 Optional NOLOCATION non-nil means do not print the location." |
92928
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
658 (let ((l (solar-sunrise-sunset date))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
659 (format |
96344
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
660 "%s, %s%s (%s hours daylight)" |
92928
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
661 (if (car l) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
662 (concat "Sunrise " (apply 'solar-time-string (car l))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
663 "No sunrise") |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
664 (if (cadr l) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
665 (concat "sunset " (apply 'solar-time-string (cadr l))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
666 "no sunset") |
96344
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
667 (if nolocation "" |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
668 (format " at %s" (eval calendar-location-name))) |
92928
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
669 (nth 2 l)))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
670 |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
671 (defconst solar-data-list |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
672 '((403406 4.721964 1.621043) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
673 (195207 5.937458 62830.348067) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
674 (119433 1.115589 62830.821524) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
675 (112392 5.781616 62829.634302) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
676 (3891 5.5474 125660.5691) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
677 (2819 1.5120 125660.984) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
678 (1721 4.1897 62832.4766) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
679 (0 1.163 0.813) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
680 (660 5.415 125659.31) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
681 (350 4.315 57533.85) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
682 (334 4.553 -33.931) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
683 (314 5.198 777137.715) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
684 (268 5.989 78604.191) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
685 (242 2.911 5.412) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
686 (234 1.423 39302.098) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
687 (158 0.061 -34.861) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
688 (132 2.317 115067.698) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
689 (129 3.193 15774.337) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
690 (114 2.828 5296.670) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
691 (99 0.52 58849.27) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
692 (93 4.65 5296.11) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
693 (86 4.35 -3980.70) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
694 (78 2.75 52237.69) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
695 (72 4.50 55076.47) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
696 (68 3.23 261.08) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
697 (64 1.22 15773.85) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
698 (46 0.14 188491.03) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
699 (38 3.44 -7756.55) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
700 (37 4.37 264.89) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
701 (32 1.14 117906.27) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
702 (29 2.84 55075.75) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
703 (28 5.96 -7961.39) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
704 (27 5.09 188489.81) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
705 (27 1.72 2132.19) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
706 (25 2.56 109771.03) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
707 (24 1.92 54868.56) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
708 (21 0.09 25443.93) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
709 (21 5.98 -55731.43) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
710 (20 4.03 60697.74) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
711 (18 4.47 2132.79) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
712 (17 0.79 109771.63) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
713 (14 4.24 -7752.82) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
714 (13 2.01 188491.91) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
715 (13 2.65 207.81) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
716 (13 4.98 29424.63) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
717 (12 0.93 -7.99) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
718 (10 2.21 46941.14) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
719 (10 3.59 -68.29) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
720 (10 1.50 21463.25) |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
721 (10 2.55 157208.40)) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
722 "Data used for calculation of solar longitude.") |
956 | 723 |
62312
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
724 (defun solar-longitude (d) |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
725 "Longitude of sun on astronomical (Julian) day number D. |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
726 Accuracy is about 0.0006 degree (about 365.25*24*60*0.0006/360 = 1 minutes). |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
727 The values of `calendar-daylight-savings-starts', |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
728 `calendar-daylight-savings-starts-time', `calendar-daylight-savings-ends', |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
729 `calendar-daylight-savings-ends-time', `calendar-daylight-time-offset', and |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
730 `calendar-time-zone' are used to interpret local time." |
93641
8a8d2922328b
Update for cal-julian name changes.
Glenn Morris <rgm@gnu.org>
parents:
93490
diff
changeset
|
731 (let* ((a-d (calendar-astro-to-absolute d)) |
92657 | 732 ;; Get Universal Time. |
62312
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
733 (date (calendar-astro-from-absolute |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
734 (- a-d |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
735 (if (dst-in-effect a-d) |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
736 (/ calendar-daylight-time-offset 24.0 60.0) 0) |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
737 (/ calendar-time-zone 60.0 24.0)))) |
92657 | 738 ;; Get Ephemeris Time. |
62312
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
739 (date (+ date (solar-ephemeris-correction |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93787
diff
changeset
|
740 (calendar-extract-year |
62312
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
741 (calendar-gregorian-from-absolute |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
742 (floor |
93641
8a8d2922328b
Update for cal-julian name changes.
Glenn Morris <rgm@gnu.org>
parents:
93490
diff
changeset
|
743 (calendar-astro-to-absolute |
62312
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
744 date))))))) |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
745 (U (/ (- date 2451545) 3652500)) |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
746 (longitude |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
747 (+ 4.9353929 |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
748 (* 62833.1961680 U) |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
749 (* 0.0000001 |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
750 (apply '+ |
92598 | 751 (mapcar (lambda (x) |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
752 (* (car x) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
753 (sin (mod |
92928
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
754 (+ (cadr x) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
755 (* (nth 2 x) U)) |
110525
e950143ab9e0
* lisp/emacs-lisp/float-sup.el (float-pi): New name for `pi'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
756 (* 2 float-pi))))) |
62312
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
757 solar-data-list))))) |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
758 (aberration |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
759 (* 0.0000001 (- (* 17 (cos (+ 3.10 (* 62830.14 U)))) 973))) |
110525
e950143ab9e0
* lisp/emacs-lisp/float-sup.el (float-pi): New name for `pi'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
760 (A1 (mod (+ 2.18 (* U (+ -3375.70 (* 0.36 U)))) (* 2 float-pi))) |
e950143ab9e0
* lisp/emacs-lisp/float-sup.el (float-pi): New name for `pi'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
761 (A2 (mod (+ 3.51 (* U (+ 125666.39 (* 0.10 U)))) (* 2 float-pi))) |
62312
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
762 (nutation (* -0.0000001 (+ (* 834 (sin A1)) (* 64 (sin A2)))))) |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
763 (mod (radians-to-degrees (+ longitude aberration nutation)) 360.0))) |
cc808dc04a2d
(solar-data-list): Move definition up.
Richard M. Stallman <rms@gnu.org>
parents:
62168
diff
changeset
|
764 |
92928
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
765 (defun solar-date-next-longitude (d l) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
766 "First time after day D when solar longitude is a multiple of L degrees. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
767 D is a Julian day number. L must be an integer divisor of 360. |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
768 The result is for `calendar-location-name', and is in local time |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
769 \(including any daylight saving rules) expressed in astronomical (Julian) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
770 day numbers. The values of `calendar-daylight-savings-starts', |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
771 `calendar-daylight-savings-starts-time', `calendar-daylight-savings-ends', |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
772 `calendar-daylight-savings-ends-time', `calendar-daylight-time-offset', |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
773 and `calendar-time-zone' are used to interpret local time." |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
774 (let* ((long) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
775 (start d) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
776 (start-long (solar-longitude d)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
777 (next (mod (* l (1+ (floor (/ start-long l)))) 360)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
778 (end (+ d (* (/ l 360.0) 400))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
779 (end-long (solar-longitude end))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
780 (while ; bisection search for nearest minute |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
781 (< 0.00001 (- end start)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
782 ;; start <= d < end |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
783 ;; start-long <= next < end-long when next != 0 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
784 ;; when next = 0, we look for the discontinuity (start-long is near 360 |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
785 ;; and end-long is small (less than l). |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
786 (setq d (/ (+ start end) 2.0) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
787 long (solar-longitude d)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
788 (if (or (and (not (zerop next)) (< long next)) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
789 (and (zerop next) (< l long))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
790 (setq start d |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
791 start-long long) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
792 (setq end d |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
793 end-long long))) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
794 (/ (+ start end) 2.0))) |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
795 |
93787 | 796 ;; FIXME but there already is solar-sunrise-sunset. |
956 | 797 ;;;###autoload |
798 (defun sunrise-sunset (&optional arg) | |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
799 "Local time of sunrise and sunset for today. Accurate to a few seconds. |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
800 If called with an optional prefix argument ARG, prompt for date. |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
801 If called with an optional double prefix argument, prompt for |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
802 longitude, latitude, time zone, and date, and always use standard time. |
956 | 803 |
804 This function is suitable for execution in a .emacs file." | |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
805 (interactive "p") |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
806 (or arg (setq arg 1)) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
807 (if (and (< arg 16) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
808 (not (and calendar-latitude calendar-longitude calendar-time-zone))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
809 (solar-setup)) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
810 (let* ((calendar-longitude |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
811 (if (< arg 16) calendar-longitude |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
812 (solar-get-number |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
813 "Enter longitude (decimal fraction; + east, - west): "))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
814 (calendar-latitude |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
815 (if (< arg 16) calendar-latitude |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
816 (solar-get-number |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
817 "Enter latitude (decimal fraction; + north, - south): "))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
818 (calendar-time-zone |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
819 (if (< arg 16) calendar-time-zone |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
820 (solar-get-number |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
821 "Enter difference from Coordinated Universal Time (in minutes): "))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
822 (calendar-location-name |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
823 (if (< arg 16) calendar-location-name |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
824 (let ((float-output-format "%.1f")) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
825 (format "%s%s, %s%s" |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
826 (if (numberp calendar-latitude) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
827 (abs calendar-latitude) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
828 (+ (aref calendar-latitude 0) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
829 (/ (aref calendar-latitude 1) 60.0))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
830 (if (numberp calendar-latitude) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
831 (if (> calendar-latitude 0) "N" "S") |
93093
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
832 (if (eq (aref calendar-latitude 2) 'north) "N" "S")) |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
833 (if (numberp calendar-longitude) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
834 (abs calendar-longitude) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
835 (+ (aref calendar-longitude 0) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
836 (/ (aref calendar-longitude 1) 60.0))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
837 (if (numberp calendar-longitude) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
838 (if (> calendar-longitude 0) "E" "W") |
93093
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
839 (if (eq (aref calendar-longitude 2) 'east) |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
840 "E" "W")))))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
841 (calendar-standard-time-zone-name |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
842 (if (< arg 16) calendar-standard-time-zone-name |
92958
5700422f1364
(solar-n-hemi-seasons, solar-s-hemi-seasons): Make constants.
Glenn Morris <rgm@gnu.org>
parents:
92928
diff
changeset
|
843 (cond ((zerop calendar-time-zone) "UTC") |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
844 ((< calendar-time-zone 0) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
845 (format "UTC%dmin" calendar-time-zone)) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
846 (t (format "UTC+%dmin" calendar-time-zone))))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
847 (calendar-daylight-savings-starts |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
848 (if (< arg 16) calendar-daylight-savings-starts)) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
849 (calendar-daylight-savings-ends |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
850 (if (< arg 16) calendar-daylight-savings-ends)) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
851 (date (if (< arg 4) (calendar-current-date) (calendar-read-date))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
852 (date-string (calendar-date-string date t)) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
853 (time-string (solar-sunrise-sunset-string date)) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
854 (msg (format "%s: %s" date-string time-string)) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
855 (one-window (one-window-p t))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
856 (if (<= (length msg) (frame-width)) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
857 (message "%s" msg) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
858 (with-output-to-temp-buffer "*temp*" |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
859 (princ (concat date-string "\n" time-string))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
860 (message "%s" |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
861 (substitute-command-keys |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
862 (if one-window |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
863 (if pop-up-windows |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
864 "Type \\[delete-other-windows] to remove temp window." |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
865 "Type \\[switch-to-buffer] RET to remove temp window.") |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
866 "Type \\[switch-to-buffer-other-window] RET to restore old \ |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
867 contents of temp window.")))))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48674
diff
changeset
|
868 |
92841
bde51dafc021
Add calendar-specific autoload cookies.
Glenn Morris <rgm@gnu.org>
parents:
92822
diff
changeset
|
869 ;;;###cal-autoload |
96047
65c4c935e492
* calendar/calendar.el (calendar-cursor-to-date): Add argument `event'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94653
diff
changeset
|
870 (defun calendar-sunrise-sunset (&optional event) |
956 | 871 "Local time of sunrise and sunset for date under cursor. |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
872 Accurate to a few seconds." |
96047
65c4c935e492
* calendar/calendar.el (calendar-cursor-to-date): Add argument `event'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94653
diff
changeset
|
873 (interactive (list last-nonmenu-event)) |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
874 (or (and calendar-latitude calendar-longitude calendar-time-zone) |
956 | 875 (solar-setup)) |
96047
65c4c935e492
* calendar/calendar.el (calendar-cursor-to-date): Add argument `event'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94653
diff
changeset
|
876 (let ((date (calendar-cursor-to-date t event))) |
5698
d127e0963a2c
(calendar-sunrise-sunset): Add date to message.
Richard M. Stallman <rms@gnu.org>
parents:
5010
diff
changeset
|
877 (message "%s: %s" |
d127e0963a2c
(calendar-sunrise-sunset): Add date to message.
Richard M. Stallman <rms@gnu.org>
parents:
5010
diff
changeset
|
878 (calendar-date-string date t t) |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
879 (solar-sunrise-sunset-string date)))) |
956 | 880 |
96344
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
881 ;;;###cal-autoload |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
882 (defun calendar-sunrise-sunset-month (&optional event) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
883 "Local time of sunrise and sunset for month under cursor or at EVENT." |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
884 (interactive (list last-nonmenu-event)) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
885 (or (and calendar-latitude calendar-longitude calendar-time-zone) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
886 (solar-setup)) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
887 (let* ((date (calendar-cursor-to-date t event)) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
888 (month (car date)) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
889 (year (nth 2 date)) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
890 (last (calendar-last-day-of-month month year)) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
891 (title (format "Sunrise/sunset times for %s %d at %s" |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
892 (calendar-month-name month) year |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
893 (eval calendar-location-name)))) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
894 (calendar-in-read-only-buffer solar-sunrises-buffer |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
895 (calendar-set-mode-line title) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
896 (insert title ":\n\n") |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
897 (dotimes (i last) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
898 (setq date (list month (1+ i) year)) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
899 (insert (format "%s %2d: " (calendar-month-name month t) (1+ i)) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
900 (solar-sunrise-sunset-string date t) "\n"))))) |
6c2ff33de03a
(solar-sunrise-sunset-string): Add optional argument `nolocation'.
Glenn Morris <rgm@gnu.org>
parents:
96047
diff
changeset
|
901 |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
902 (defvar date) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
903 |
93787 | 904 ;; To be called from diary-list-sexp-entries, where DATE is bound. |
92841
bde51dafc021
Add calendar-specific autoload cookies.
Glenn Morris <rgm@gnu.org>
parents:
92822
diff
changeset
|
905 ;;;###diary-autoload |
956 | 906 (defun diary-sunrise-sunset () |
907 "Local time of sunrise and sunset as a diary entry. | |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
908 Accurate to a few seconds." |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
909 (or (and calendar-latitude calendar-longitude calendar-time-zone) |
956 | 910 (solar-setup)) |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
911 (solar-sunrise-sunset-string date)) |
956 | 912 |
92657 | 913 ;; From Meeus, 1991, page 167. |
52113
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
914 (defconst solar-seasons-data |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
915 '((485 324.96 1934.136) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
916 (203 337.23 32964.467) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
917 (199 342.08 20.186) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
918 (182 27.85 445267.112) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
919 (156 73.14 45036.886) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
920 (136 171.52 22518.443) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
921 (77 222.54 65928.934) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
922 (74 296.72 3034.906) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
923 (70 243.58 9037.513) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
924 (58 119.81 33718.147) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
925 (52 297.17 150.678) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
926 (50 21.02 2281.226) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
927 (45 247.54 29929.562) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
928 (44 325.15 31555.956) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
929 (29 60.93 4443.417) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
930 (18 155.12 67555.328) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
931 (17 288.79 4562.452) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
932 (16 198.04 62894.029) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
933 (14 199.76 31436.921) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
934 (12 95.39 14577.848) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
935 (12 287.11 31931.756) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
936 (12 320.81 34777.259) |
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
937 (9 227.73 1222.114) |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
938 (8 15.45 16859.074)) |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
939 "Data for solar equinox/solstice calculations.") |
52113
e94e668195a2
(displayed-month, displayed-year): Define for compiler.
Glenn Morris <rgm@gnu.org>
parents:
49598
diff
changeset
|
940 |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
941 (defun solar-equinoxes/solstices (k year) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
942 "Date of equinox/solstice K for YEAR. |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
943 K=0, spring equinox; K=1, summer solstice; K=2, fall equinox; |
92665
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
944 K=3, winter solstice. RESULT is a Gregorian local date. |
b01c207d45b2
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92657
diff
changeset
|
945 Accurate to within a minute between 1951 and 2050." |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
946 (let* ((JDE0 (solar-mean-equinoxes/solstices k year)) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
947 (T (/ (- JDE0 2451545.0) 36525)) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
948 (W (- (* 35999.373 T) 2.47)) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
949 (Delta-lambda (+ 1 (* 0.0334 (solar-cosine-degrees W)) |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
950 (* 0.0007 (solar-cosine-degrees (* 2 W))))) |
92598 | 951 (S (apply '+ (mapcar (lambda(x) |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
952 (* (car x) (solar-cosine-degrees |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
953 (+ (* (nth 2 x) T) (cadr x))))) |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
954 solar-seasons-data))) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
955 (JDE (+ JDE0 (/ (* 0.00001 S) Delta-lambda))) |
92657 | 956 ;; Ephemeris time correction. |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48674
diff
changeset
|
957 (correction (+ 102.3 (* 123.5 T) (* 32.5 T T))) |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
958 (JD (- JDE (/ correction 86400))) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
959 (date (calendar-gregorian-from-absolute (floor (- JD 1721424.5)))) |
92822
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
960 (time (- (- JD 0.5) (floor (- JD 0.5))))) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
961 (list (car date) (+ (cadr date) time |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
962 (/ (/ calendar-time-zone 60.0) 24.0)) |
3e5b1792e433
(solar-moment, solar-exact-local-noon)
Glenn Morris <rgm@gnu.org>
parents:
92665
diff
changeset
|
963 (nth 2 date)))) |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
964 |
92657 | 965 ;; From Meeus, 1991, page 166. |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
966 (defun solar-mean-equinoxes/solstices (k year) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48674
diff
changeset
|
967 "Julian day of mean equinox/solstice K for YEAR. |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
968 K=0, spring equinox; K=1, summer solstice; K=2, fall equinox; K=3, winter |
92958
5700422f1364
(solar-n-hemi-seasons, solar-s-hemi-seasons): Make constants.
Glenn Morris <rgm@gnu.org>
parents:
92928
diff
changeset
|
969 solstice. These formulae are only to be used between 1000 BC and 3000 AD." |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
970 (let ((y (/ year 1000.0)) |
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
971 (z (/ (- year 2000) 1000.0))) |
92657 | 972 (if (< year 1000) ; actually between -1000 and 1000 |
93093
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
973 (cond ((= k 0) (+ 1721139.29189 |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
974 (* 365242.13740 y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
975 (* 0.06134 y y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
976 (* 0.00111 y y y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
977 (* -0.00071 y y y y))) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
978 ((= k 1) (+ 1721233.25401 |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
979 (* 365241.72562 y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
980 (* -0.05323 y y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
981 (* 0.00907 y y y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
982 (* 0.00025 y y y y))) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
983 ((= k 2) (+ 1721325.70455 |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
984 (* 365242.49558 y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
985 (* -0.11677 y y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
986 (* -0.00297 y y y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
987 (* 0.00074 y y y y))) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
988 ((= k 3) (+ 1721414.39987 |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
989 (* 365242.88257 y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
990 (* -0.00769 y y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
991 (* -0.00933 y y y) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
992 (* -0.00006 y y y y)))) |
92657 | 993 ; actually between 1000 and 3000 |
93093
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
994 (cond ((= k 0) (+ 2451623.80984 |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
995 (* 365242.37404 z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
996 (* 0.05169 z z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
997 (* -0.00411 z z z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
998 (* -0.00057 z z z z))) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
999 ((= k 1) (+ 2451716.56767 |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1000 (* 365241.62603 z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1001 (* 0.00325 z z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1002 (* 0.00888 z z z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1003 (* -0.00030 z z z z))) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1004 ((= k 2) (+ 2451810.21715 |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1005 (* 365242.01767 z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1006 (* -0.11575 z z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1007 (* 0.00337 z z z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1008 (* 0.00078 z z z z))) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1009 ((= k 3) (+ 2451900.05952 |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1010 (* 365242.74049 z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1011 (* -0.06223 z z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1012 (* -0.00823 z z z) |
fb92abde7664
(calendar-location-name, calendar-latitude)
Glenn Morris <rgm@gnu.org>
parents:
92996
diff
changeset
|
1013 (* 0.00032 z z z z))))))) |
13874
eec68643bcfb
Rewrote completely for better accuracy.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13742
diff
changeset
|
1014 |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93787
diff
changeset
|
1015 (defvar displayed-month) ; from calendar-generate |
92928
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
1016 (defvar displayed-year) |
506b148b25a4
Reorder so that functions are defined before use.
Glenn Morris <rgm@gnu.org>
parents:
92841
diff
changeset
|
1017 |
92841
bde51dafc021
Add calendar-specific autoload cookies.
Glenn Morris <rgm@gnu.org>
parents:
92822
diff
changeset
|
1018 ;;;###holiday-autoload |
3866
c97c63c1a920
* solar.el (calendar-holiday-solar-equinoxes-solstices): Renamed
Jim Blandy <jimb@redhat.com>
parents:
3779
diff
changeset
|
1019 (defun solar-equinoxes-solstices () |
92553
4fcd0c94d0b7
Remove leading `*' from defcustom doc-strings.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
1020 "Local date and time of equinoxes and solstices, if visible in the calendar. |
956 | 1021 Requires floating point." |
93490
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1022 (let* ((m displayed-month) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1023 (y displayed-year) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1024 (calendar-standard-time-zone-name |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1025 (if calendar-time-zone calendar-standard-time-zone-name "UTC")) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1026 (calendar-daylight-savings-starts |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1027 (if calendar-time-zone calendar-daylight-savings-starts)) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1028 (calendar-daylight-savings-ends |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1029 (if calendar-time-zone calendar-daylight-savings-ends)) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1030 (calendar-time-zone (if calendar-time-zone calendar-time-zone 0)) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1031 (k (progn |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93787
diff
changeset
|
1032 (calendar-increment-month m y (cond ((= 1 (% m 3)) -1) |
93490
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1033 ((= 2 (% m 3)) 1) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1034 (t 0))) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1035 (1- (/ m 3)))) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1036 (d0 (solar-equinoxes/solstices k y)) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1037 (d1 (list (car d0) (floor (cadr d0)) (nth 2 d0))) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1038 (h0 (* 24 (- (cadr d0) (floor (cadr d0))))) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1039 (adj (dst-adjust-time d1 h0)) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1040 (d (list (caar adj) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1041 (+ (car (cdar adj)) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1042 (/ (cadr adj) 24.0)) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1043 (cadr (cdar adj)))) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1044 ;; The following is nearly as accurate, but not quite: |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1045 ;; (d0 (solar-date-next-longitude |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1046 ;; (calendar-astro-from-absolute |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1047 ;; (calendar-absolute-from-gregorian |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1048 ;; (list (+ 3 (* k 3)) 15 y))) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1049 ;; 90)) |
93641
8a8d2922328b
Update for cal-julian name changes.
Glenn Morris <rgm@gnu.org>
parents:
93490
diff
changeset
|
1050 ;; (abs-day (calendar-astro-to-absolute d))) |
93490
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1051 (abs-day (calendar-absolute-from-gregorian d))) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1052 (list |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1053 (list (calendar-gregorian-from-absolute (floor abs-day)) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1054 (format "%s %s" |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1055 (nth k (if (and calendar-latitude |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1056 (< (calendar-latitude) 0)) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1057 solar-s-hemi-seasons |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1058 solar-n-hemi-seasons)) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1059 (solar-time-string |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1060 (* 24 (- abs-day (floor abs-day))) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1061 (if (dst-in-effect abs-day) |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1062 calendar-daylight-time-zone-name |
2fd8322cee67
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93230
diff
changeset
|
1063 calendar-standard-time-zone-name))))))) |
13045
2779e3cf6cfa
Added code to support Chinese calendar. Minor fixes as well.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
12908
diff
changeset
|
1064 |
956 | 1065 |
1066 (provide 'solar) | |
1067 | |
92598 | 1068 ;; arch-tag: bc0ff693-df58-4666-bde4-2a7837ccb8fe |
956 | 1069 ;;; solar.el ends here |