annotate lisp/calendar/cal-dst.el @ 5058:fb8f2a3f2178

(comint-scroll-show-maximum-output): Make default nil.
author Richard M. Stallman <rms@gnu.org>
date Wed, 17 Nov 1993 14:20:31 +0000
parents f3a55af8f584
children 4930c18bb456
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 ;;; cal-dst.el --- calendar functions for daylight savings rules.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3 ;; Copyright (C) 1993 Free Software Foundation, Inc.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 ;; Author: Paul Eggert <eggert@twinsun.com>
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 ;; Edward M. Reingold <reingold@cs.uiuc.edu>
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 ;; Keywords: calendar
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;; Human-Keywords: daylight savings time, calendar, diary, holidays
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;; GNU Emacs is distributed in the hope that it will be useful,
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;; but WITHOUT ANY WARRANTY. No author or distributor
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;; accepts responsibility to anyone for the consequences of using it
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; or for whether it serves any particular purpose or works at all,
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;; unless he says so in writing. Refer to the GNU Emacs General Public
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; License for full details.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; Everyone is granted permission to copy, modify and redistribute
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; GNU Emacs, but only under the conditions described in the
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 ;; GNU Emacs General Public License. A copy of this license is
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; supposed to have been given to you along with GNU Emacs so you
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 ;; can know your rights and responsibilities. It should be in a
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 ;; file named COPYING. Among other things, the copyright notice
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 ;; and this notice must be preserved on all copies.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 ;;; Commentary:
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 ;; This collection of functions implements the features of calendar.el and
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 ;; holiday.el that deal with daylight savings time.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 ;; Comments, corrections, and improvements should be sent to
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 ;; Edward M. Reingold Department of Computer Science
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 ;; (217) 333-6733 University of Illinois at Urbana-Champaign
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 ;; reingold@cs.uiuc.edu 1304 West Springfield Avenue
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 ;; Urbana, Illinois 61801
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 ;;; Code:
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40 (require 'calendar)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 (defvar calendar-current-time-zone-cache nil
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 "Cache for result of calendar-current-time-zone.")
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 (defvar calendar-system-time-basis
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 (calendar-absolute-from-gregorian '(1 1 1970))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 "Absolute date of starting date of system clock.")
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 (defun calendar-absolute-from-time (x utc-diff)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 "Absolute local date of time X; local time is UTC-DIFF seconds from UTC.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 X is (HIGH . LOW) or (HIGH LOW . IGNORED) where HIGH and LOW are the
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 high and low 16 bits, respectively, of the number of seconds since
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 1970-01-01 00:00:00 UTC, ignoring leap seconds.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 Returns the pair (ABS-DATE . SECONDS) where SECONDS after local midnight on
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 absolute date ABS-DATE is the equivalent moment to X."
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 (let* ((h (car x))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (xtail (cdr x))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (l (+ utc-diff (if (numberp xtail) xtail (car xtail))))
4535
cf77def3abe2 Undo last change.
Roland McGrath <roland@gnu.org>
parents: 4534
diff changeset
61 (u (+ (* 512 (mod h 675)) (floor l 128))))
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62 ;; Overflow is a terrible thing!
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 (cons (+ calendar-system-time-basis
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 ;; floor((2^16 h +l) / (60*60*24))
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
65 (* 512 (floor h 675)) (floor u 675))
5001
f3a55af8f584 (calendar-absolute-from-time): Undo Sep 14 patch.
Richard M. Stallman <rms@gnu.org>
parents: 4756
diff changeset
66 ;; (2^16 h +l) mod (60*60*24)
f3a55af8f584 (calendar-absolute-from-time): Undo Sep 14 patch.
Richard M. Stallman <rms@gnu.org>
parents: 4756
diff changeset
67 (+ (* (mod u 675) 128) (mod l 128)))))
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 (defun calendar-time-from-absolute (abs-date s)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 "Time of absolute date ABS-DATE, S seconds after midnight.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 Returns the pair (HIGH . LOW) where HIGH and LOW are the high and low
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 16 bits, respectively, of the number of seconds 1970-01-01 00:00:00 UTC,
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 ignoring leap seconds, that is the equivalent moment to S seconds after
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 midnight UTC on absolute date ABS-DATE."
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 (let* ((a (- abs-date calendar-system-time-basis))
4535
cf77def3abe2 Undo last change.
Roland McGrath <roland@gnu.org>
parents: 4534
diff changeset
77 (u (+ (* 163 (mod a 512)) (floor s 128))))
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 ;; Overflow is a terrible thing!
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 (cons
5001
f3a55af8f584 (calendar-absolute-from-time): Undo Sep 14 patch.
Richard M. Stallman <rms@gnu.org>
parents: 4756
diff changeset
80 ;; floor((60*60*24*a + s) / 2^16)
4535
cf77def3abe2 Undo last change.
Roland McGrath <roland@gnu.org>
parents: 4534
diff changeset
81 (+ a (* 163 (floor a 512)) (floor u 512))
5001
f3a55af8f584 (calendar-absolute-from-time): Undo Sep 14 patch.
Richard M. Stallman <rms@gnu.org>
parents: 4756
diff changeset
82 ;; (60*60*24*a + s) mod 2^16
4535
cf77def3abe2 Undo last change.
Roland McGrath <roland@gnu.org>
parents: 4534
diff changeset
83 (+ (* 128 (mod u 512)) (mod s 128)))))
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 (defun calendar-next-time-zone-transition (time)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 "Return the time of the next time zone transition after TIME.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 Both TIME and the result are acceptable arguments to current-time-zone.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 Return nil if no such transition can be found."
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 (let* ((base 65536);; 2^16 = base of current-time output
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 (quarter-multiple 120);; approx = (seconds per quarter year) / base
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 (time-zone (current-time-zone time))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 (time-utc-diff (car time-zone))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 hi
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 hi-zone
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 (hi-utc-diff time-utc-diff)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 (quarters '(2 1 3)))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 ;; Heuristic: probe the time zone offset in the next three calendar
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 ;; quarters, looking for a time zone offset different from TIME.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 (while (and quarters (eq time-utc-diff hi-utc-diff))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 (setq hi (cons (+ (car time) (* (car quarters) quarter-multiple)) 0))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 (setq hi-zone (current-time-zone hi))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 (setq hi-utc-diff (car hi-zone))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 (setq quarters (cdr quarters)))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 (and
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 time-utc-diff
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 hi-utc-diff
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 (not (eq time-utc-diff hi-utc-diff))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 ;; Now HI is after the next time zone transition.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 ;; Set LO to TIME, and then binary search to increase LO and decrease HI
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 ;; until LO is just before and HI is just after the time zone transition.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (let* ((tail (cdr time))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 (lo (cons (car time) (if (numberp tail) tail (car tail))))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 probe)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 (while
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 ;; Set PROBE to halfway between LO and HI, rounding down.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 ;; If PROBE equals LO, we are done.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 (let* ((lsum (+ (cdr lo) (cdr hi)))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 (hsum (+ (car lo) (car hi) (/ lsum base)))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 (hsumodd (logand 1 hsum)))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 (setq probe (cons (/ (- hsum hsumodd) 2)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 (/ (+ (* hsumodd base) (% lsum base)) 2)))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 (not (equal lo probe)))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 ;; Set either LO or HI to PROBE, depending on probe results.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 (if (eq (car (current-time-zone probe)) hi-utc-diff)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 (setq hi probe)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 (setq lo probe)))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 hi))))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 (defun calendar-time-zone-daylight-rules (abs-date utc-diff)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 "Return daylight transition rule for ABS-DATE, UTC-DIFF sec offset from UTC.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 ABS-DIFF must specify a day that contains a daylight savings transition.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 The result has the proper form for calendar-daylight-savings-starts'."
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 (let* ((date (calendar-gregorian-from-absolute abs-date))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 (weekday (% abs-date 7))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 (m (extract-calendar-month date))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 (d (extract-calendar-day date))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 (y (extract-calendar-year date))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 (last (calendar-last-day-of-month m y))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 (candidate-rules
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (append
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 ;; Day D of month M.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 (list (list 'list m d 'year))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 ;; The first WEEKDAY of month M.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 (if (< d 8)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 (list (list 'calendar-nth-named-day 1 weekday m 'year)))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 ;; The last WEEKDAY of month M.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (if (> d (- last 7))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 (list (list 'calendar-nth-named-day -1 weekday m 'year)))
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 ;; The first WEEKDAY after day J of month M, for D-6 < J <= D.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 (let (l)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (calendar-for-loop j from (max 2 (- d 6)) to (min d (- last 8)) do
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 (setq l
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (cons
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 (list 'calendar-nth-named-day 1 weekday m 'year j)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 l)))
4667
dbe2da5db2f7 (calendar-time-zone-daylight-rules): Remove special case for Israel.
Paul Eggert <eggert@twinsun.com>
parents: 4659
diff changeset
156 l)))
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 (prevday-sec (- -1 utc-diff)) ;; last sec of previous local day
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
158 (year (1+ y)))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
159 ;; Scan through the next few years until only one rule remains.
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
160 (while
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
161 (let ((rules candidate-rules)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
162 new-rules)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
163 (while
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
164 (let*
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
165 ((rule (car rules))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
166 (date
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
167 ;; The following is much faster than
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
168 ;; (calendar-absolute-from-gregorian (eval rule)).
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
169 (cond ((eq (car rule) 'calendar-nth-named-day)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
170 (eval (cons 'calendar-nth-named-absday (cdr rule))))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
171 ((eq (car rule) 'calendar-gregorian-from-absolute)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
172 (eval (car (cdr rule))))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
173 (t (let ((g (eval rule)))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
174 (calendar-absolute-from-gregorian g))))))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
175 (or (equal
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
176 (current-time-zone
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
177 (calendar-time-from-absolute date prevday-sec))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
178 (current-time-zone
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
179 (calendar-time-from-absolute (1+ date) prevday-sec)))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
180 (setq new-rules (cons rule new-rules)))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
181 (setq rules (cdr rules))))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
182 ;; If no rules remain, just use the first candidate rule;
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
183 ;; it's wrong in general, but it's right for at least one year.
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
184 (setq candidate-rules (if new-rules (nreverse new-rules)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
185 (list (car candidate-rules))))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
186 (setq year (1+ year))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
187 (cdr candidate-rules)))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
188 (car candidate-rules)))
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (defun calendar-current-time-zone ()
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 "Return UTC difference, dst offset, names and rules for current time zone.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
193 Returns (UTC-DIFF DST-OFFSET STD-ZONE DST-ZONE DST-STARTS DST-ENDS
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
194 DST-STARTS-TIME DST-ENDS-TIME), based on a heuristic probing of what the
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
195 system knows:
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 UTC-DIFF is an integer specifying the number of minutes difference between
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 standard time in the current time zone and Coordinated Universal Time
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 (Greenwich Mean Time). A negative value means west of Greenwich.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 DST-OFFSET is an integer giving the daylight savings time offset in minutes.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 STD-ZONE is a string giving the name of the time zone when no seasonal time
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 adjustment is in effect.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 DST-ZONE is a string giving the name of the time zone when there is a seasonal
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 time adjustment in effect.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 DST-STARTS and DST-ENDS are sexps in the variable `year' giving the daylight
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
206 savings time start and end rules, in the form expected by
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 `calendar-daylight-savings-starts'.
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
208 DST-STARTS-TIME and DST-ENDS-TIME are integers giving the number of minutes
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
209 after midnight that daylight savings time starts and ends.
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
211 If the local area does not use a seasonal time adjustment, STD-ZONE and
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
212 DST-ZONE are equal, and all the DST-* integer variables are 0.
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 Some operating systems cannot provide all this information to Emacs; in this
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 case, `calendar-current-time-zone' returns a list containing nil for the data
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 it can't find."
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (or
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 calendar-current-time-zone-cache
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
219 (setq
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
220 calendar-current-time-zone-cache
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
221 (let* ((t0 (current-time))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
222 (t0-zone (current-time-zone t0))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
223 (t0-utc-diff (car t0-zone))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
224 (t0-name (car (cdr t0-zone))))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
225 (if (not t0-utc-diff)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
226 ;; Little or no time zone information is available.
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
227 (list nil nil t0-name t0-name nil nil nil nil)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
228 (let* ((t1 (calendar-next-time-zone-transition t0))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
229 (t2 (and t1 (calendar-next-time-zone-transition t1))))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
230 (if (not t2)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
231 ;; This locale does not have daylight savings time.
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
232 (list (/ t0-utc-diff 60) 0 t0-name t0-name nil nil 0 0)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
233 ;; Use heuristics to find daylight savings parameters.
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
234 (let* ((t1-zone (current-time-zone t1))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
235 (t1-utc-diff (car t1-zone))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
236 (t1-name (car (cdr t1-zone)))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
237 (t1-date-sec (calendar-absolute-from-time t1 t0-utc-diff))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
238 (t2-date-sec (calendar-absolute-from-time t2 t1-utc-diff))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
239 (t1-rules (calendar-time-zone-daylight-rules
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
240 (car t1-date-sec) t0-utc-diff))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
241 (t2-rules (calendar-time-zone-daylight-rules
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
242 (car t2-date-sec) t1-utc-diff))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
243 (t1-time (/ (cdr t1-date-sec) 60))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
244 (t2-time (/ (cdr t2-date-sec) 60)))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
245 (cons
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
246 (/ (min t0-utc-diff t1-utc-diff) 60)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
247 (cons
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
248 (/ (abs (- t0-utc-diff t1-utc-diff)) 60)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
249 (if (< t0-utc-diff t1-utc-diff)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
250 (list t0-name t1-name t1-rules t2-rules t2-time t1-time)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
251 (list t1-name t0-name t2-rules t1-rules t1-time t2-time)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
252 )))))))))))
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 ;;; The following six defvars relating to daylight savings time should NOT be
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 ;;; marked to go into loaddefs.el where they would be evaluated when Emacs is
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 ;;; dumped. These variables' appropriate values depend on the conditions under
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 ;;; which the code is INVOKED; so it's inappropriate to initialize them when
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 ;;; Emacs is dumped---they should be initialized when calendar.el is loaded.
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
259 ;;; They default to US Eastern time if time zone info is not available.
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (calendar-current-time-zone)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
263 (defvar calendar-time-zone (or (car calendar-current-time-zone-cache) -300)
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 "*Number of minutes difference between local standard time at
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 `calendar-location-name' and Coordinated Universal (Greenwich) Time. For
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 example, -300 for New York City, -480 for Los Angeles.")
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (defvar calendar-daylight-time-offset
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
269 (or (car (cdr calendar-current-time-zone-cache)) 60)
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 "*Number of minutes difference between daylight savings and standard time.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 If the locale never uses daylight savings time, set this to 0.")
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (defvar calendar-standard-time-zone-name
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
275 (or (car (nthcdr 2 calendar-current-time-zone-cache)) "EST")
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 "*Abbreviated name of standard time zone at `calendar-location-name'.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 For example, \"EST\" in New York City, \"PST\" for Los Angeles.")
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 (defvar calendar-daylight-time-zone-name
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
280 (or (car (nthcdr 3 calendar-current-time-zone-cache)) "EDT")
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 "*Abbreviated name of daylight-savings time zone at `calendar-location-name'.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 For example, \"EDT\" in New York City, \"PDT\" for Los Angeles.")
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 (defvar calendar-daylight-savings-starts
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
285 (or (car (nthcdr 4 calendar-current-time-zone-cache))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
286 (and (not (zerop calendar-daylight-time-offset))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
287 '(calendar-nth-named-day 1 0 4 year)))
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 "*Sexp giving the date on which daylight savings time starts.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 This is an expression in the variable `year' whose value gives the Gregorian
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 date in the form (month day year) on which daylight savings time starts. It is
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 used to determine the starting date of daylight savings time for the holiday
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 list and for correcting times of day in the solar and lunar calculations.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 For example, if daylight savings time is mandated to start on October 1,
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 you would set `calendar-daylight-savings-starts' to
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 '(10 1 year)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298
4667
dbe2da5db2f7 (calendar-time-zone-daylight-rules): Remove special case for Israel.
Paul Eggert <eggert@twinsun.com>
parents: 4659
diff changeset
299 If it starts on the first Sunday in April, you would set it to
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300
4667
dbe2da5db2f7 (calendar-time-zone-daylight-rules): Remove special case for Israel.
Paul Eggert <eggert@twinsun.com>
parents: 4659
diff changeset
301 '(calendar-nth-named-day 1 0 4 year)
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 If the locale never uses daylight savings time, set this to nil.")
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 (defvar calendar-daylight-savings-ends
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
306 (or (car (nthcdr 5 calendar-current-time-zone-cache))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
307 (and (not (zerop calendar-daylight-time-offset))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
308 '(calendar-nth-named-day -1 0 10 year)))
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 "*Sexp giving the date on which daylight savings time ends.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 This is an expression in the variable `year' whose value gives the Gregorian
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 date in the form (month day year) on which daylight savings time ends. It is
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 used to determine the starting date of daylight savings time for the holiday
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 list and for correcting times of day in the solar and lunar calculations.
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314
4667
dbe2da5db2f7 (calendar-time-zone-daylight-rules): Remove special case for Israel.
Paul Eggert <eggert@twinsun.com>
parents: 4659
diff changeset
315 For example, if daylight savings time ends on the last Sunday in October:
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316
4667
dbe2da5db2f7 (calendar-time-zone-daylight-rules): Remove special case for Israel.
Paul Eggert <eggert@twinsun.com>
parents: 4659
diff changeset
317 '(calendar-nth-named-day -1 0 10 year)
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 If the locale never uses daylight savings time, set this to nil.")
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320
4659
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
321 (defvar calendar-daylight-savings-starts-time
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
322 (or (car (nthcdr 6 calendar-current-time-zone-cache)) 120)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
323 "*Number of minutes after midnight that daylight savings time starts.")
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
324
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
325 (defvar calendar-daylight-savings-ends-time
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
326 (or (car (nthcdr 7 calendar-current-time-zone-cache))
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
327 calendar-daylight-savings-starts-time)
031aaf217dc3 (calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents: 4535
diff changeset
328 "*Number of minutes after midnight that daylight savings time ends.")
3872
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 (provide 'cal-dst)
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331
923a207e7967 * cal-dst.el: New file.
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 ;;; cal-dst.el ends here