annotate lisp/calendar/solar.el @ 64:a01e7a40045c r19-16-pre7

Import from CVS: tag r19-16-pre7
author cvs
date Mon, 13 Aug 2007 08:59:30 +0200
parents 0293115a14e9
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; solar.el --- calendar functions for solar events.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: Edward M. Reingold <reingold@cs.uiuc.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: calendar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Human-Keywords: sunrise, sunset, equinox, solstice, calendar, diary,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; holidays
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
25 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; This collection of functions implements the features of calendar.el,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; diary.el, and holiday.el that deal with times of day, sunrise/sunset, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; eqinoxes/solstices.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; Based on the ``Almanac for Computers 1984,'' prepared by the Nautical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; Almanac Office, United States Naval Observatory, Washington, 1984 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; on ``Astronomical Formulae for Calculators,'' 3rd ed., by Jean Meeus,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; Willmann-Bell, Inc., 1985.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; WARNINGS:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; 1. SUNRISE/SUNSET calculations will be accurate only to +/- 2 minutes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; Locations should be between +/- 65 degrees of latitude.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; Dates should be in the latter half of the 20th century.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; 2. Equinox/solstice times will be accurate only to +/- 15 minutes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; The author would be delighted to have an astronomically more sophisticated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; person rewrite the code for the solar calculations in this file!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; Comments, corrections, and improvements should be sent to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; Edward M. Reingold Department of Computer Science
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; Urbana, Illinois 61801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (if (fboundp 'atan)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 (require 'lisp-float-type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (error "Solar/lunar calculations impossible since floating point is unavailable."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (require 'cal-dst)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defvar calendar-time-display-form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 '(12-hours ":" minutes am-pm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (if time-zone " (") time-zone (if time-zone ")"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 "*The pseudo-pattern that governs the way a time of day is formatted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 A pseudo-pattern is a list of expressions that can involve the keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 `12-hours', `24-hours', and `minutes', all numbers in string form,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 and `am-pm' and `time-zone', both alphabetic strings.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 For example, the form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 '(24-hours \":\" minutes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (if time-zone \" (\") time-zone (if time-zone \")\"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 would give military-style times like `21:07 (UTC)'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (defvar calendar-latitude nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 "*Latitude of `calendar-location-name' in degrees.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 The value can be either a decimal fraction (one place of accuracy is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 sufficient), + north, - south, such as 40.7 for New York City, or the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 can be a vector [degrees minutes north/south] such as [40 50 north] for New
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 York City.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 This variable should be set in site-local.el.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (defvar calendar-longitude nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 "*Longitude of `calendar-location-name' in degrees.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 The value can be either a decimal fraction (one place of accuracy is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 sufficient), + east, - west, such as -73.9 for New York City, or the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 can be a vector [degrees minutes east/west] such as [73 55 west] for New
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 York City.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 This variable should be set in site-local.el.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (defsubst calendar-latitude ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 "Convert calendar-latitude to a signed decimal fraction, if needed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (if (numberp calendar-latitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 calendar-latitude
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (let ((lat (+ (aref calendar-latitude 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (/ (aref calendar-latitude 1) 60.0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (if (equal (aref calendar-latitude 2) 'north)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 lat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (- lat)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (defsubst calendar-longitude ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 "Convert calendar-longitude to a signed decimal fraction, if needed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (if (numberp calendar-longitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 calendar-longitude
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (let ((long (+ (aref calendar-longitude 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (/ (aref calendar-longitude 1) 60.0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (if (equal (aref calendar-longitude 2) 'east)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (- long)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defvar calendar-location-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 '(let ((float-output-format "%.1f"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (format "%s%s, %s%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (if (numberp calendar-latitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (abs calendar-latitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (+ (aref calendar-latitude 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (/ (aref calendar-latitude 1) 60.0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (if (numberp calendar-latitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (if (> calendar-latitude 0) "N" "S")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (if (equal (aref calendar-latitude 2) 'north) "N" "S"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (if (numberp calendar-longitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (abs calendar-longitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (+ (aref calendar-longitude 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (/ (aref calendar-longitude 1) 60.0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (if (numberp calendar-longitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (if (> calendar-longitude 0) "E" "W")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (if (equal (aref calendar-latitude 2) 'east) "E" "W"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 "*Expression evaluating to name of `calendar-longitude', calendar-latitude'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 For example, \"New York City\". Default value is just the latitude, longitude
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 pair.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 This variable should be set in site-local.el.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defvar solar-n-hemi-seasons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 '("Vernal Equinox" "Summer Solstice" "Autumnal Equinox" "Winter Solstice")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 "List of season changes for the northern hemisphere.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (defvar solar-s-hemi-seasons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 '("Autumnal Equinox" "Winter Solstice" "Vernal Equinox" "Summer Solstice")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 "List of season changes for the southern hemisphere.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defun solar-setup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 "Prompt user for latitude, longitude, and time zone."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (beep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (if (not calendar-longitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq calendar-longitude
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (solar-get-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 "Enter longitude (decimal fraction; + east, - west): ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (if (not calendar-latitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (setq calendar-latitude
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (solar-get-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 "Enter latitude (decimal fraction; + north, - south): ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (if (not calendar-time-zone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (setq calendar-time-zone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (solar-get-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 "Enter difference from Coordinated Universal Time (in minutes): "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (defun solar-get-number (prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 "Return a number from the minibuffer, prompting with PROMPT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 Returns nil if nothing was entered."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (let ((x (read-string prompt "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (if (not (string-equal x ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (string-to-int x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (defsubst solar-sin-degrees (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (sin (degrees-to-radians x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (defsubst solar-cosine-degrees (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (cos (degrees-to-radians x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (defun solar-tangent-degrees (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (tan (degrees-to-radians x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (defun solar-xy-to-quadrant (x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 "Determines the quadrant of the point X, Y."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (if (> x 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (if (> y 0) 1 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (if (> y 0) 2 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (defun solar-degrees-to-quadrant (angle)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 "Determines the quadrant of ANGLE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (1+ (floor (mod angle 360) 90)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (defun solar-arctan (x quad)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 "Arctangent of X in quadrant QUAD."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (let ((deg (radians-to-degrees (atan x))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (cond ((equal quad 2) (+ deg 180))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ((equal quad 3) (+ deg 180))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ((equal quad 4) (+ deg 360))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (t deg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (defun solar-arccos (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (let ((y (sqrt (- 1 (* x x)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (solar-arctan (/ y x) (solar-xy-to-quadrant x y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (defun solar-arcsin (y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (let ((x (sqrt (- 1 (* y y)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (solar-arctan (/ y x) (solar-xy-to-quadrant x y))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (defconst solar-earth-inclination 23.441884
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 "Inclination of earth's equator to its solar orbit in degrees.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (defconst solar-cos-inclination (solar-cosine-degrees solar-earth-inclination)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 "Cosine of earth's inclination.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defconst solar-sin-inclination (solar-sin-degrees solar-earth-inclination)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "Sine of earth's inclination.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (defconst solar-earth-orbit-eccentricity 0.016718
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 "Eccentricity of orbit of the earth around the sun.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (defsubst solar-degrees-to-hours (deg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (/ deg 15.0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (defsubst solar-hours-to-days (hour)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (/ hour 24.0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (defun solar-longitude-of-sun (day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 "Longitude of the sun at DAY in the year."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (let ((mean-anomaly (- (* 0.9856 day) 3.289)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (mod (+ mean-anomaly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (* 1.916 (solar-sin-degrees mean-anomaly))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (* 0.020 (solar-sin-degrees (* 2 mean-anomaly)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 282.634)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 360)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (defun solar-right-ascension (longitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 "Right ascension of the sun, given its LONGITUDE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (solar-degrees-to-hours
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (solar-arctan
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (* solar-cos-inclination (solar-tangent-degrees longitude))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (solar-degrees-to-quadrant longitude))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (defun solar-declination (longitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 "Declination of the sun, given its LONGITUDE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (solar-arcsin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (* solar-sin-inclination
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (solar-sin-degrees longitude))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defun solar-sunrise (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 "Calculates the *standard* time of sunrise for Gregorian DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 Calculation is for location given by `calendar-latitude' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 `calendar-longitude'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 Returns a decimal fraction of hours. Returns nil if the sun does not rise at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 that location on that day."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (let* ((day-of-year (calendar-day-number date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (approx-sunrise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (+ day-of-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (solar-hours-to-days
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (- 6 (solar-degrees-to-hours (calendar-longitude))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (solar-longitude-of-sun-at-sunrise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (solar-longitude-of-sun approx-sunrise))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (solar-right-ascension-at-sunrise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (solar-right-ascension solar-longitude-of-sun-at-sunrise))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (solar-declination-at-sunrise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (solar-declination solar-longitude-of-sun-at-sunrise))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (cos-local-sunrise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (/ (- (solar-cosine-degrees (+ 90 (/ 50.0 60.0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (* (solar-sin-degrees solar-declination-at-sunrise)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (solar-sin-degrees (calendar-latitude))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (* (solar-cosine-degrees solar-declination-at-sunrise)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (solar-cosine-degrees (calendar-latitude))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (if (<= (abs cos-local-sunrise) 1);; otherwise, no sunrise that day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (let* ((local-sunrise (solar-degrees-to-hours
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (- 360 (solar-arccos cos-local-sunrise))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (local-mean-sunrise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (mod (- (+ local-sunrise solar-right-ascension-at-sunrise)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (+ (* 0.065710 approx-sunrise)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 6.622))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 24)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (+ (- local-mean-sunrise (solar-degrees-to-hours (calendar-longitude)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (/ calendar-time-zone 60.0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defun solar-sunset (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 "Calculates the *standard* time of sunset for Gregorian DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 Calculation is for location given by `calendar-latitude' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 `calendar-longitude'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 Returns a decimal fractions of hours. Returns nil if the sun does not set at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 that location on that day."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (let* ((day-of-year (calendar-day-number date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (approx-sunset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (+ day-of-year
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (solar-hours-to-days
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (- 18 (solar-degrees-to-hours (calendar-longitude))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (solar-longitude-of-sun-at-sunset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (solar-longitude-of-sun approx-sunset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (solar-right-ascension-at-sunset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (solar-right-ascension solar-longitude-of-sun-at-sunset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (solar-declination-at-sunset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (solar-declination solar-longitude-of-sun-at-sunset))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (cos-local-sunset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (/ (- (solar-cosine-degrees (+ 90 (/ 50.0 60.0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (* (solar-sin-degrees solar-declination-at-sunset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (solar-sin-degrees (calendar-latitude))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (* (solar-cosine-degrees solar-declination-at-sunset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (solar-cosine-degrees (calendar-latitude))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (if (<= (abs cos-local-sunset) 1);; otherwise, no sunset that day
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (let* ((local-sunset (solar-degrees-to-hours
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (solar-arccos cos-local-sunset)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (local-mean-sunset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (mod (- (+ local-sunset solar-right-ascension-at-sunset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (+ (* 0.065710 approx-sunset) 6.622))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 24)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (+ (- local-mean-sunset (solar-degrees-to-hours (calendar-longitude)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (/ calendar-time-zone 60.0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (defun solar-adj-time-for-dst (date time &optional style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 "Adjust decimal fraction standard TIME on DATE to account for dst.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 Returns a list (date adj-time zone) where `date' and `time' are the values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 adjusted for `zone'; here `date' is a list (month day year), `time' is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 decimal fraction time, and `zone' is a string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 Optional parameter STYLE forces the result time to be standard time when its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 value is 'standard and daylight savings time (if available) when its value is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 'daylight.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 Conversion to daylight savings time is done according to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 `calendar-daylight-savings-starts', `calendar-daylight-savings-ends',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 `calendar-daylight-savings-starts-time',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 `calendar-daylight-savings-ends-time', and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 `calendar-daylight-savings-offset'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (let* ((year (extract-calendar-year date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (rounded-abs-date (+ (calendar-absolute-from-gregorian date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (/ (round (* 60 time)) 60.0 24.0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (dst-starts (and calendar-daylight-savings-starts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (+ (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (eval calendar-daylight-savings-starts))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (/ calendar-daylight-savings-starts-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 60.0 24.0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (dst-ends (and calendar-daylight-savings-ends
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (+ (calendar-absolute-from-gregorian
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (eval calendar-daylight-savings-ends))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (/ (- calendar-daylight-savings-ends-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 calendar-daylight-time-offset)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 60.0 24.0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (dst (and (not (eq style 'standard))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (or (eq style 'daylight)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (and dst-starts dst-ends
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (or (and (< dst-starts dst-ends);; northern hemi.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (<= dst-starts rounded-abs-date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (< rounded-abs-date dst-ends))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (and (< dst-ends dst-starts);; southern hemi.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (or (< rounded-abs-date dst-ends)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (<= dst-starts rounded-abs-date)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (and dst-starts (not dst-ends)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (<= dst-starts rounded-abs-date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (and dst-ends (not dst-starts)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (< rounded-abs-date dst-ends)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (time-zone (if dst
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 calendar-daylight-time-zone-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 calendar-standard-time-zone-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (time (+ rounded-abs-date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (if dst (/ calendar-daylight-time-offset 24.0 60.0) 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (list (calendar-gregorian-from-absolute (truncate time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (* 24.0 (- time (truncate time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 time-zone)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defun solar-time-string (time time-zone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 "Printable form for decimal fraction TIME on DATE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 Format used is given by `calendar-time-display-form'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (let* ((time (round (* 60 time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (24-hours (/ time 60))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (minutes (format "%02d" (% time 60)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (12-hours (format "%d" (1+ (% (+ 24-hours 11) 12))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (am-pm (if (>= 24-hours 12) "pm" "am"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (24-hours (format "%02d" 24-hours)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (mapconcat 'eval calendar-time-display-form "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defun solar-sunrise-sunset (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 "String giving local times of sunrise and sunset on Gregorian DATE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (let* ((rise (solar-sunrise date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (adj-rise (if rise (solar-adj-time-for-dst date rise)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (set (solar-sunset date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (adj-set (if set (solar-adj-time-for-dst date set))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (format "%s, %s at %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (if (and rise (calendar-date-equal date (car adj-rise)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (concat "Sunrise " (apply 'solar-time-string (cdr adj-rise)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "No sunrise")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (if (and set (calendar-date-equal date (car adj-set)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (concat "sunset " (apply 'solar-time-string (cdr adj-set)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "no sunset")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (eval calendar-location-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (defun solar-apparent-longitude-of-sun (date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 "Apparent longitude of the sun on Gregorian DATE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (let* ((time (/ (- (calendar-absolute-from-gregorian date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (calendar-absolute-from-gregorian '(1 0.5 1900)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 36525))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (l (+ 279.69668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (* 36000.76892 time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (* 0.0003025 time time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (m (+ 358.47583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (* 35999.04975 time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (* -0.000150 time time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (* -0.0000033 time time time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (c (+ (* (+ 1.919460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (* -0.004789 time)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (* -0.000014 time time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (solar-sin-degrees m))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (* (+ 0.020094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (* -0.000100 time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (solar-sin-degrees (* 2 m)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (* 0.000293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (solar-sin-degrees (* 3 m)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (L (+ l c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (omega (+ 259.18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (* -1934.142 time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (app (+ L
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 -0.00569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (* -0.00479
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (solar-sin-degrees omega)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 app))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (defun solar-ephemeris-correction (year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 "Difference in minutes between Ephemeris time and UTC in YEAR.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 Value is only an approximation."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (let ((T (/ (- year 1900) 100.0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (+ 0.41 (* 1.2053 T) (* 0.4992 T T))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (defun solar-equinoxes/solstices (k year)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 "Date of equinox/solstice K for YEAR. K=0, spring equinox; K=1, summer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 solstice; K=2, fall equinox; K=3, winter solstice. Accurate to within
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 several minutes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (let ((date (list (+ 3 (* k 3)) 21 year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 app
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (correction 1000))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (while (> correction 0.00001)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (setq app (mod (solar-apparent-longitude-of-sun date) 360))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (setq correction (* 58 (solar-sin-degrees (- (* k 90) app))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (setq date (list (extract-calendar-month date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (+ (extract-calendar-day date) correction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (list (extract-calendar-month date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (+ (extract-calendar-day date) (/ calendar-time-zone 60.0 24.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (- (/ (solar-ephemeris-correction year) 60.0 24.0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 year)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (defun sunrise-sunset (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 "Local time of sunrise and sunset for today. Accurate to +/- 2 minutes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 If called with an optional prefix argument, prompt for date.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 If called with an optional double prefix argument, prompt for longitude,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 latitude, time zone, and date, and always use standard time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 This function is suitable for execution in a .emacs file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (or arg (setq arg 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (if (and (< arg 16)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (not (and calendar-latitude calendar-longitude calendar-time-zone)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (solar-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (let* ((calendar-longitude
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (if (< arg 16) calendar-longitude
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (solar-get-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 "Enter longitude (decimal fraction; + east, - west): ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (calendar-latitude
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (if (< arg 16) calendar-latitude
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (solar-get-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 "Enter latitude (decimal fraction; + north, - south): ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (calendar-time-zone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (if (< arg 16) calendar-time-zone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (solar-get-number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 "Enter difference from Coordinated Universal Time (in minutes): ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (calendar-location-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (if (< arg 16) calendar-location-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (let ((float-output-format "%.1f"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (format "%s%s, %s%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (if (numberp calendar-latitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (abs calendar-latitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (+ (aref calendar-latitude 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (/ (aref calendar-latitude 1) 60.0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (if (numberp calendar-latitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (if (> calendar-latitude 0) "N" "S")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (if (equal (aref calendar-latitude 2) 'north) "N" "S"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (if (numberp calendar-longitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (abs calendar-longitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (+ (aref calendar-longitude 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (/ (aref calendar-longitude 1) 60.0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (if (numberp calendar-longitude)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (if (> calendar-longitude 0) "E" "W")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (if (equal (aref calendar-latitude 2) 'east)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 "E" "W"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (calendar-standard-time-zone-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (if (< arg 16) calendar-standard-time-zone-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (cond ((= calendar-time-zone 0) "UTC")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ((< calendar-time-zone 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (format "UTC%dmin" calendar-time-zone))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (t (format "UTC+%dmin" calendar-time-zone)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (calendar-daylight-savings-starts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (if (< arg 16) calendar-daylight-savings-starts))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (calendar-daylight-savings-ends
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (if (< arg 16) calendar-daylight-savings-ends))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (date (if (< arg 4) (calendar-current-date) (calendar-read-date)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (date-string (calendar-date-string date t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (time-string (solar-sunrise-sunset date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (msg (format "%s: %s" date-string time-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (one-window (one-window-p t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (if (<= (length msg) (frame-width))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (message msg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (with-output-to-temp-buffer "*temp*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (princ (concat date-string "\n" time-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (message (substitute-command-keys
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (if one-window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (if pop-up-windows
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 "Type \\[delete-other-windows] to remove temp window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 "Type \\[switch-to-buffer] RET to remove temp window.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 "Type \\[switch-to-buffer-other-window] RET to restore old contents of temp window."))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (defun calendar-sunrise-sunset ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 "Local time of sunrise and sunset for date under cursor.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 Accurate to +/- 2 minutes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (if (not (and calendar-latitude calendar-longitude calendar-time-zone))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (solar-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (let ((date (calendar-cursor-to-date t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (message "%s: %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (calendar-date-string date t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (solar-sunrise-sunset date))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (defun diary-sunrise-sunset ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 "Local time of sunrise and sunset as a diary entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 Accurate to +/- 2 minutes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (if (not (and calendar-latitude calendar-longitude calendar-time-zone))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (solar-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (solar-sunrise-sunset date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (defun diary-sabbath-candles ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 "Local time of candle lighting diary entry--applies if date is a Friday.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 No diary entry if there is no sunset on that date."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (if (not (and calendar-latitude calendar-longitude calendar-time-zone))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (solar-setup))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (if (= (% (calendar-absolute-from-gregorian date) 7) 5);; Friday
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (let* ((sunset (solar-sunset date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (light (if sunset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (solar-adj-time-for-dst
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (- sunset (/ 18.0 60.0))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (if (and light (calendar-date-equal date (car light)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (format "%s Sabbath candle lighting"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (apply 'solar-time-string (cdr light)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (defun solar-equinoxes-solstices ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 "Date and time of equinoxes and solstices, if visible in the calendar window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 Requires floating point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (let ((m displayed-month)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (y displayed-year))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (increment-calendar-month m y (cond ((= 1 (% m 3)) -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 ((= 2 (% m 3)) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (t 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (let* ((calendar-standard-time-zone-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (if calendar-time-zone calendar-standard-time-zone-name "UTC"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (calendar-daylight-savings-starts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (if calendar-time-zone calendar-daylight-savings-starts))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (calendar-daylight-savings-ends
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (if calendar-time-zone calendar-daylight-savings-ends))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (calendar-time-zone (if calendar-time-zone calendar-time-zone 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (k (1- (/ m 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (date (solar-equinoxes/solstices k y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (s-hemi (and calendar-latitude (< (calendar-latitude) 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (day (extract-calendar-day date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (adj (solar-adj-time-for-dst
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (list (extract-calendar-month date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (truncate day)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (extract-calendar-year date))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (* 24 (- day (truncate day))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (list (list (car adj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (format "%s %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (nth k (if s-hemi solar-s-hemi-seasons
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 solar-n-hemi-seasons))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (apply 'solar-time-string (cdr adj))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (provide 'solar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 ;;; solar.el ends here