aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2008-03-14 03:38:38 +0000
committerGlenn Morris2008-03-14 03:38:38 +0000
commit4b8683c7c5bc3bcdf1c976d5f90ecfc1f3103966 (patch)
tree49e6dff9bde55c519fc39a93888adde3b2257243
parentc8ca95dd39937818536c9f3c4906ac718a5e1e0c (diff)
downloademacs-4b8683c7c5bc3bcdf1c976d5f90ecfc1f3103966.tar.gz
emacs-4b8683c7c5bc3bcdf1c976d5f90ecfc1f3103966.zip
(calendar-time-zone-daylight-rules): Simplify.
(calendar-dst-find-data, calendar-daylight-time-offset) (calendar-standard-time-zone-name, calendar-daylight-time-zone-name) (calendar-daylight-savings-starts-time) (calendar-daylight-savings-ends-time): Use cadr, nth.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/calendar/cal-dst.el75
2 files changed, 42 insertions, 39 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 908b04637bc..836bdb42866 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -31,6 +31,12 @@
31 (ethiopic-calendar-month-name-array, ethiopic-name): Add doc strings. 31 (ethiopic-calendar-month-name-array, ethiopic-name): Add doc strings.
32 (coptic-prompt-for-date): Move definition before use. 32 (coptic-prompt-for-date): Move definition before use.
33 33
34 * calendar/cal-dst.el (calendar-time-zone-daylight-rules): Simplify.
35 (calendar-dst-find-data, calendar-daylight-time-offset)
36 (calendar-standard-time-zone-name, calendar-daylight-time-zone-name)
37 (calendar-daylight-savings-starts-time)
38 (calendar-daylight-savings-ends-time): Use cadr, nth.
39
34 * calendar/cal-french.el (french-calendar-epoch) 40 * calendar/cal-french.el (french-calendar-epoch)
35 (calendar-goto-french-date): Doc fix. 41 (calendar-goto-french-date): Doc fix.
36 (french-calendar-month-name-array) 42 (french-calendar-month-name-array)
diff --git a/lisp/calendar/cal-dst.el b/lisp/calendar/cal-dst.el
index 78d8b7f4793..25b4d68f750 100644
--- a/lisp/calendar/cal-dst.el
+++ b/lisp/calendar/cal-dst.el
@@ -154,10 +154,10 @@ Return nil if no such transition can be found."
154 ;; Heuristic: probe the time zone offset in the next three calendar 154 ;; Heuristic: probe the time zone offset in the next three calendar
155 ;; quarters, looking for a time zone offset different from TIME. 155 ;; quarters, looking for a time zone offset different from TIME.
156 (while (and quarters (eq time-utc-diff hi-utc-diff)) 156 (while (and quarters (eq time-utc-diff hi-utc-diff))
157 (setq hi (cons (+ (car time) (* (car quarters) quarter-multiple)) 0)) 157 (setq hi (cons (+ (car time) (* (car quarters) quarter-multiple)) 0)
158 (setq hi-zone (current-time-zone hi)) 158 hi-zone (current-time-zone hi)
159 (setq hi-utc-diff (car hi-zone)) 159 hi-utc-diff (car hi-zone)
160 (setq quarters (cdr quarters))) 160 quarters (cdr quarters)))
161 (and 161 (and
162 time-utc-diff 162 time-utc-diff
163 hi-utc-diff 163 hi-utc-diff
@@ -224,34 +224,31 @@ The result has the proper form for `calendar-daylight-savings-starts'."
224 (prevday-sec (- -1 utc-diff)) ;; last sec of previous local day 224 (prevday-sec (- -1 utc-diff)) ;; last sec of previous local day
225 (year (1+ y))) 225 (year (1+ y)))
226 ;; Scan through the next few years until only one rule remains. 226 ;; Scan through the next few years until only one rule remains.
227 (while 227 (while (let ((rules candidate-rules)
228 (let ((rules candidate-rules) 228 new-rules)
229 new-rules) 229 (dolist (rule rules)
230 (while 230 (let ((date
231 (let* 231 ;; The following is much faster than
232 ((rule (car rules)) 232 ;; (calendar-absolute-from-gregorian (eval rule)).
233 (date 233 (cond ((eq (car rule) 'calendar-nth-named-day)
234 ;; The following is much faster than 234 (eval (cons 'calendar-nth-named-absday
235 ;; (calendar-absolute-from-gregorian (eval rule)). 235 (cdr rule))))
236 (cond ((eq (car rule) 'calendar-nth-named-day) 236 ((eq (car rule) 'calendar-gregorian-from-absolute)
237 (eval (cons 'calendar-nth-named-absday (cdr rule)))) 237 (eval (cadr rule)))
238 ((eq (car rule) 'calendar-gregorian-from-absolute) 238 (t (calendar-absolute-from-gregorian
239 (eval (car (cdr rule)))) 239 (eval rule))))))
240 (t (let ((g (eval rule))) 240 (or (equal
241 (calendar-absolute-from-gregorian g)))))) 241 (current-time-zone
242 (or (equal 242 (calendar-time-from-absolute date prevday-sec))
243 (current-time-zone 243 (current-time-zone
244 (calendar-time-from-absolute date prevday-sec)) 244 (calendar-time-from-absolute (1+ date) prevday-sec)))
245 (current-time-zone 245 (setq new-rules (cons rule new-rules)))))
246 (calendar-time-from-absolute (1+ date) prevday-sec))) 246 ;; If no rules remain, just use the first candidate rule;
247 (setq new-rules (cons rule new-rules))) 247 ;; it's wrong in general, but it's right for at least one year.
248 (setq rules (cdr rules)))) 248 (setq candidate-rules (if new-rules (nreverse new-rules)
249 ;; If no rules remain, just use the first candidate rule; 249 (list (car candidate-rules)))
250 ;; it's wrong in general, but it's right for at least one year. 250 year (1+ year))
251 (setq candidate-rules (if new-rules (nreverse new-rules) 251 (cdr candidate-rules)))
252 (list (car candidate-rules))))
253 (setq year (1+ year))
254 (cdr candidate-rules)))
255 (car candidate-rules))) 252 (car candidate-rules)))
256 253
257;; TODO it might be better to extract this information directly from 254;; TODO it might be better to extract this information directly from
@@ -265,7 +262,7 @@ for `calendar-current-time-zone'."
265 (let* ((t0 (or time (current-time))) 262 (let* ((t0 (or time (current-time)))
266 (t0-zone (current-time-zone t0)) 263 (t0-zone (current-time-zone t0))
267 (t0-utc-diff (car t0-zone)) 264 (t0-utc-diff (car t0-zone))
268 (t0-name (car (cdr t0-zone)))) 265 (t0-name (cadr t0-zone)))
269 (if (not t0-utc-diff) 266 (if (not t0-utc-diff)
270 ;; Little or no time zone information is available. 267 ;; Little or no time zone information is available.
271 (list nil nil t0-name t0-name nil nil nil nil) 268 (list nil nil t0-name t0-name nil nil nil nil)
@@ -277,7 +274,7 @@ for `calendar-current-time-zone'."
277 ;; Use heuristics to find daylight saving parameters. 274 ;; Use heuristics to find daylight saving parameters.
278 (let* ((t1-zone (current-time-zone t1)) 275 (let* ((t1-zone (current-time-zone t1))
279 (t1-utc-diff (car t1-zone)) 276 (t1-utc-diff (car t1-zone))
280 (t1-name (car (cdr t1-zone))) 277 (t1-name (cadr t1-zone))
281 (t1-date-sec (calendar-absolute-from-time t1 t0-utc-diff)) 278 (t1-date-sec (calendar-absolute-from-time t1 t0-utc-diff))
282 (t2-date-sec (calendar-absolute-from-time t2 t1-utc-diff)) 279 (t2-date-sec (calendar-absolute-from-time t2 t1-utc-diff))
283 ;; TODO When calendar-dst-check-each-year-flag is non-nil, 280 ;; TODO When calendar-dst-check-each-year-flag is non-nil,
@@ -374,34 +371,34 @@ For example, -300 for New York City, -480 for Los Angeles."
374 :group 'calendar-dst) 371 :group 'calendar-dst)
375 372
376(defcustom calendar-daylight-time-offset 373(defcustom calendar-daylight-time-offset
377 (or (car (cdr calendar-current-time-zone-cache)) 60) 374 (or (cadr calendar-current-time-zone-cache) 60)
378 "Number of minutes difference between daylight saving and standard time. 375 "Number of minutes difference between daylight saving and standard time.
379If the locale never uses daylight saving time, set this to 0." 376If the locale never uses daylight saving time, set this to 0."
380 :type 'integer 377 :type 'integer
381 :group 'calendar-dst) 378 :group 'calendar-dst)
382 379
383(defcustom calendar-standard-time-zone-name 380(defcustom calendar-standard-time-zone-name
384 (or (car (nthcdr 2 calendar-current-time-zone-cache)) "EST") 381 (or (nth 2 calendar-current-time-zone-cache) "EST")
385 "Abbreviated name of standard time zone at `calendar-location-name'. 382 "Abbreviated name of standard time zone at `calendar-location-name'.
386For example, \"EST\" in New York City, \"PST\" for Los Angeles." 383For example, \"EST\" in New York City, \"PST\" for Los Angeles."
387 :type 'string 384 :type 'string
388 :group 'calendar-dst) 385 :group 'calendar-dst)
389 386
390(defcustom calendar-daylight-time-zone-name 387(defcustom calendar-daylight-time-zone-name
391 (or (car (nthcdr 3 calendar-current-time-zone-cache)) "EDT") 388 (or (nth 3 calendar-current-time-zone-cache) "EDT")
392 "Abbreviated name of daylight saving time zone at `calendar-location-name'. 389 "Abbreviated name of daylight saving time zone at `calendar-location-name'.
393For example, \"EDT\" in New York City, \"PDT\" for Los Angeles." 390For example, \"EDT\" in New York City, \"PDT\" for Los Angeles."
394 :type 'string 391 :type 'string
395 :group 'calendar-dst) 392 :group 'calendar-dst)
396 393
397(defcustom calendar-daylight-savings-starts-time 394(defcustom calendar-daylight-savings-starts-time
398 (or (car (nthcdr 6 calendar-current-time-zone-cache)) 120) 395 (or (nth 6 calendar-current-time-zone-cache) 120)
399 "Number of minutes after midnight that daylight saving time starts." 396 "Number of minutes after midnight that daylight saving time starts."
400 :type 'integer 397 :type 'integer
401 :group 'calendar-dst) 398 :group 'calendar-dst)
402 399
403(defcustom calendar-daylight-savings-ends-time 400(defcustom calendar-daylight-savings-ends-time
404 (or (car (nthcdr 7 calendar-current-time-zone-cache)) 401 (or (nth 7 calendar-current-time-zone-cache)
405 calendar-daylight-savings-starts-time) 402 calendar-daylight-savings-starts-time)
406 "Number of minutes after midnight that daylight saving time ends." 403 "Number of minutes after midnight that daylight saving time ends."
407 :type 'integer 404 :type 'integer