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