diff options
| author | Jim Blandy | 1993-06-16 23:12:21 +0000 |
|---|---|---|
| committer | Jim Blandy | 1993-06-16 23:12:21 +0000 |
| commit | e2fe2f5238d9619254fb3335156cef5b0704b1f5 (patch) | |
| tree | 5ca66028e40694524d8eaf2a5cb95623052d6056 | |
| parent | 23195d9408256b6a9cef2158d042e0859d24b004 (diff) | |
| download | emacs-e2fe2f5238d9619254fb3335156cef5b0704b1f5.tar.gz emacs-e2fe2f5238d9619254fb3335156cef5b0704b1f5.zip | |
*solar.el (solar-setup, solar-ephemeris-time, sunrise-sunset): Change
Universal Time (UT) to Coordinated Universal Time (UTC).
(solar-time-string): Use calendar-daylight-time-offset instead of
1 hr, and use calendar-daylight-savings-switchover-time instead of
midnight. Add an optional parameter to allow forcing the use of
standard or daylight savings time. Fix code so it works in
southern hemisphere (start of dst precedes end of dst in a
calendar year) and when dst either starts or ends in a calendar
year, but not both.
| -rw-r--r-- | lisp/calendar/solar.el | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/lisp/calendar/solar.el b/lisp/calendar/solar.el index f9f582b9a46..24681df7b4f 100644 --- a/lisp/calendar/solar.el +++ b/lisp/calendar/solar.el | |||
| @@ -72,7 +72,7 @@ | |||
| 72 | (if (not calendar-time-zone) | 72 | (if (not calendar-time-zone) |
| 73 | (setq calendar-time-zone | 73 | (setq calendar-time-zone |
| 74 | (solar-get-number | 74 | (solar-get-number |
| 75 | "Enter difference from Universal Time (in minutes): ")))) | 75 | "Enter difference from Coordinated Universal Time (in minutes): ")))) |
| 76 | 76 | ||
| 77 | (defun solar-get-number (prompt) | 77 | (defun solar-get-number (prompt) |
| 78 | "Return a number from the minibuffer, prompting with PROMPT. | 78 | "Return a number from the minibuffer, prompting with PROMPT. |
| @@ -226,22 +226,46 @@ of hours. Returns nil if the sun does not set at that location on that day." | |||
| 226 | (+ (- local-mean-sunset (solar-degrees-to-hours calendar-longitude)) | 226 | (+ (- local-mean-sunset (solar-degrees-to-hours calendar-longitude)) |
| 227 | (/ calendar-time-zone 60.0)))))) | 227 | (/ calendar-time-zone 60.0)))))) |
| 228 | 228 | ||
| 229 | (defun solar-time-string (time date) | 229 | (defun solar-time-string (time date &optional style) |
| 230 | "Printable form for decimal fraction standard TIME on DATE. | 230 | "Printable form for decimal fraction *standard* TIME on DATE. |
| 231 | Optional parameter STYLE forces the time to be standard time when its value | ||
| 232 | is 'standard and daylight savings time (if available) when its value is | ||
| 233 | 'daylight. | ||
| 234 | |||
| 231 | Format used is given by `calendar-time-display-form'. Converted to daylight | 235 | Format used is given by `calendar-time-display-form'. Converted to daylight |
| 232 | savings time according to `calendar-daylight-savings-starts' and | 236 | savings time according to `calendar-daylight-savings-starts', |
| 233 | `calendar-daylight-savings-ends', if those variables are not nil." | 237 | `calendar-daylight-savings-ends', `calendar-daylight-switchover-time', and |
| 238 | `calendar-daylight-savings-offset'." | ||
| 234 | (let* ((year (extract-calendar-year date)) | 239 | (let* ((year (extract-calendar-year date)) |
| 235 | (abs-date (calendar-absolute-from-gregorian date)) | 240 | (abs-date-and-time (+ (calendar-absolute-from-gregorian date) |
| 236 | (dst (and calendar-daylight-savings-starts | 241 | (/ time 24.0))) |
| 237 | calendar-daylight-savings-ends | 242 | (rounded-abs-date (+ abs-date-and-time (/ 1.0 60 24 2)));; half min |
| 238 | (<= (calendar-absolute-from-gregorian | 243 | (dst-change-over |
| 239 | (eval calendar-daylight-savings-starts)) | 244 | (/ (eval calendar-daylight-savings-switchover-time) 60.0 24.0)) |
| 240 | abs-date) | 245 | (dst-starts (and calendar-daylight-savings-starts |
| 241 | (< abs-date | 246 | (+ (calendar-absolute-from-gregorian |
| 242 | (calendar-absolute-from-gregorian | 247 | (eval calendar-daylight-savings-starts)) |
| 243 | (eval calendar-daylight-savings-ends))))) | 248 | dst-change-over))) |
| 244 | (time (if dst (1+ time) time)) | 249 | (dst-ends (and calendar-daylight-savings-ends |
| 250 | (+ (calendar-absolute-from-gregorian | ||
| 251 | (eval calendar-daylight-savings-ends)) | ||
| 252 | dst-change-over))) | ||
| 253 | (dst (and (not (eq style 'standard)) | ||
| 254 | (or (eq style 'daylight) | ||
| 255 | (and dst-starts dst-ends | ||
| 256 | (or (and (< dst-starts dst-ends);; northern hemi. | ||
| 257 | (<= dst-starts rounded-abs-date) | ||
| 258 | (< rounded-abs-date dst-ends)) | ||
| 259 | (and (< dst-ends dst-starts);; southern hemi. | ||
| 260 | (or (< rounded-abs-date dst-ends) | ||
| 261 | (<= dst-starts rounded-abs-date))))) | ||
| 262 | (and dst-starts (not dst-ends) | ||
| 263 | (<= dst-starts rounded-abs-date)) | ||
| 264 | (and dst-ends (not dst-starts) | ||
| 265 | (< rounded-abs-date dst-ends))))) | ||
| 266 | (time (if dst | ||
| 267 | (+ time (/ (eval calendar-daylight-time-offset) 60.0)) | ||
| 268 | time)) | ||
| 245 | (time-zone (if dst | 269 | (time-zone (if dst |
| 246 | calendar-daylight-time-zone-name | 270 | calendar-daylight-time-zone-name |
| 247 | calendar-standard-time-zone-name)) | 271 | calendar-standard-time-zone-name)) |
| @@ -301,7 +325,7 @@ savings time according to `calendar-daylight-savings-starts' and | |||
| 301 | app)) | 325 | app)) |
| 302 | 326 | ||
| 303 | (defun solar-ephemeris-correction (year) | 327 | (defun solar-ephemeris-correction (year) |
| 304 | "Difference in minutes between Ephemeris time an Universal time in YEAR. | 328 | "Difference in minutes between Ephemeris time and UTC in YEAR. |
| 305 | Value is only an approximation." | 329 | Value is only an approximation." |
| 306 | (let ((T (/ (- year 1900) 100.0))) | 330 | (let ((T (/ (- year 1900) 100.0))) |
| 307 | (+ 0.41 (* 1.2053 T) (* 0.4992 T T)))) | 331 | (+ 0.41 (* 1.2053 T) (* 0.4992 T T)))) |
| @@ -347,7 +371,7 @@ This function is suitable for execution in a .emacs file." | |||
| 347 | (calendar-time-zone | 371 | (calendar-time-zone |
| 348 | (if (< arg 16) calendar-time-zone | 372 | (if (< arg 16) calendar-time-zone |
| 349 | (solar-get-number | 373 | (solar-get-number |
| 350 | "Enter difference from Universal Time (in minutes): "))) | 374 | "Enter difference from Coordinated Universal Time (in minutes): "))) |
| 351 | (calendar-location-name | 375 | (calendar-location-name |
| 352 | (if (< arg 16) calendar-location-name | 376 | (if (< arg 16) calendar-location-name |
| 353 | (let ((float-output-format "%.1f")) | 377 | (let ((float-output-format "%.1f")) |