Mercurial > emacs
annotate lisp/calendar/cal-dst.el @ 112453:06719a229a46 default tip
* calc/calc.el (calc-default-power-reference-level)
(calc-default-field-reference-level): New variables.
* calc/calc-units.el (math-standard-units): Add dB and Np.
(math-logunits): New variable.
(math-extract-logunits, math-logcombine, calcFunc-luplus)
(calcFunc-luminus, calc-luplus, calc-luminus, math-logunit-level)
(calcFunc-fieldlevel, calcFunc-powerlevel, calc-level): New
functions.
(math-find-base-units-rec): Add entry for ln(10).
* calc/calc-help.el (calc-u-prefix-help): Add logarithmic help.
(calc-ul-prefix-help): New function.
* calc/calc-ext.el (calc-init-extensions): Autoload new units
functions. Add keybindings for new units functions.
author | Jay Belanger <jay.p.belanger@gmail.com> |
---|---|
date | Sun, 23 Jan 2011 23:08:04 -0600 |
parents | ef719132ddfa |
children |
rev | line source |
---|---|
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
1 ;;; cal-dst.el --- calendar functions for daylight saving rules |
3872 | 2 |
68721 | 3 ;; Copyright (C) 1993, 1994, 1995, 1996, 2001, 2002, 2003, 2004, 2005, |
112218
376148b31b5e
Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents:
106815
diff
changeset
|
4 ;; 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
3872 | 5 |
6 ;; Author: Paul Eggert <eggert@twinsun.com> | |
92850 | 7 ;; Edward M. Reingold <reingold@cs.uiuc.edu> |
67465
a55ee709ec8d
Update copyright pending Emacs 22.
Glenn Morris <rgm@gnu.org>
parents:
64085
diff
changeset
|
8 ;; Maintainer: Glenn Morris <rgm@gnu.org> |
3872 | 9 ;; Keywords: calendar |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
10 ;; Human-Keywords: daylight saving time, calendar, diary, holidays |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
106815
diff
changeset
|
11 ;; Package: calendar |
3872 | 12 |
13 ;; This file is part of GNU Emacs. | |
14 | |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93991
diff
changeset
|
15 ;; GNU Emacs is free software: you can redistribute it and/or modify |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6735
diff
changeset
|
16 ;; it under the terms of the GNU General Public License as published by |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93991
diff
changeset
|
17 ;; the Free Software Foundation, either version 3 of the License, or |
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93991
diff
changeset
|
18 ;; (at your option) any later version. |
3872 | 19 |
6736
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6735
diff
changeset
|
20 ;; 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
|
21 ;; 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
|
22 ;; 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
|
23 ;; 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
|
24 |
3e1323443b1a
Fix copying conditions for current GPL version.
Richard M. Stallman <rms@gnu.org>
parents:
6735
diff
changeset
|
25 ;; You should have received a copy of the GNU General Public License |
94653
e49abd957e81
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93991
diff
changeset
|
26 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
3872 | 27 |
28 ;;; Commentary: | |
29 | |
93479
7aed3058864c
(Commentary): Point to calendar.el.
Glenn Morris <rgm@gnu.org>
parents:
93222
diff
changeset
|
30 ;; See calendar.el. |
3872 | 31 |
32 ;;; Code: | |
33 | |
34 (require 'calendar) | |
35 | |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
36 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
37 (defgroup calendar-dst nil |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
38 "Options related to Daylight Saving Time." |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
39 :prefix "calendar-" |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
40 :group 'calendar) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
41 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
42 |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
43 (defcustom calendar-dst-check-each-year-flag t |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
44 "Non-nil means to check each year for DST transitions as needed. |
73894
cfa3c02ad6bf
(calendar-dst-check-each-year-flag): Avoid
Andreas Schwab <schwab@suse.de>
parents:
73875
diff
changeset
|
45 Otherwise assume the next two transitions found after the |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
46 current date apply to all years. This is faster, but not always |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
47 correct, since the dates of daylight saving transitions sometimes |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
48 change." |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
49 :type 'boolean |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
50 :version "22.1" |
93991
09c830b8981d
(calendar-dst-check-each-year-flag): Fix custom group.
Glenn Morris <rgm@gnu.org>
parents:
93809
diff
changeset
|
51 :group 'calendar-dst) |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
52 |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
53 ;;;###autoload |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
54 (put 'calendar-daylight-savings-starts 'risky-local-variable t) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
55 (defcustom calendar-daylight-savings-starts '(calendar-dst-starts year) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
56 "Sexp giving the date on which daylight saving time starts. |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
57 This is an expression in the variable `year' whose value gives the Gregorian |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
58 date in the form (month day year) on which daylight saving time starts. It is |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
59 used to determine the starting date of daylight saving time for the holiday |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
60 list and for correcting times of day in the solar and lunar calculations. |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
61 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
62 For example, if daylight saving time is mandated to start on October 1, |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
63 you would set `calendar-daylight-savings-starts' to |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
64 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
65 '(10 1 year) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
66 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
67 If it starts on the first Sunday in April, you would set it to |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
68 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
69 '(calendar-nth-named-day 1 0 4 year) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
70 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
71 If the locale never uses daylight saving time, set this to nil." |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
72 :type 'sexp |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
73 :group 'calendar-dst) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
74 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
75 ;;;###autoload |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
76 (put 'calendar-daylight-savings-ends 'risky-local-variable t) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
77 (defcustom calendar-daylight-savings-ends '(calendar-dst-ends year) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
78 "Sexp giving the date on which daylight saving time ends. |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
79 This is an expression in the variable `year' whose value gives the Gregorian |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
80 date in the form (month day year) on which daylight saving time ends. It is |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
81 used to determine the starting date of daylight saving time for the holiday |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
82 list and for correcting times of day in the solar and lunar calculations. |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
83 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
84 For example, if daylight saving time ends on the last Sunday in October: |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
85 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
86 '(calendar-nth-named-day -1 0 10 year) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
87 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
88 If the locale never uses daylight saving time, set this to nil." |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
89 :type 'sexp |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
90 :group 'calendar-dst) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
91 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
92 ;;; More defcustoms below. |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
93 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
94 |
3872 | 95 (defvar calendar-current-time-zone-cache nil |
74870
06cc5e77c85a
(calendar-dst-starts): Default to second Sunday in March.
Richard M. Stallman <rms@gnu.org>
parents:
73894
diff
changeset
|
96 "Cache for result of `calendar-current-time-zone'.") |
93991
09c830b8981d
(calendar-dst-check-each-year-flag): Fix custom group.
Glenn Morris <rgm@gnu.org>
parents:
93809
diff
changeset
|
97 ;; It gets eval'd, eg by calendar-dst-starts. |
09c830b8981d
(calendar-dst-check-each-year-flag): Fix custom group.
Glenn Morris <rgm@gnu.org>
parents:
93809
diff
changeset
|
98 ;;;###autoload |
09c830b8981d
(calendar-dst-check-each-year-flag): Fix custom group.
Glenn Morris <rgm@gnu.org>
parents:
93809
diff
changeset
|
99 (put 'calendar-current-time-zone-cache 'risky-local-variable t) |
3872 | 100 |
101 (defvar calendar-system-time-basis | |
102 (calendar-absolute-from-gregorian '(1 1 1970)) | |
103 "Absolute date of starting date of system clock.") | |
104 | |
105 (defun calendar-absolute-from-time (x utc-diff) | |
106 "Absolute local date of time X; local time is UTC-DIFF seconds from UTC. | |
107 | |
108 X is (HIGH . LOW) or (HIGH LOW . IGNORED) where HIGH and LOW are the | |
109 high and low 16 bits, respectively, of the number of seconds since | |
110 1970-01-01 00:00:00 UTC, ignoring leap seconds. | |
111 | |
112 Returns the pair (ABS-DATE . SECONDS) where SECONDS after local midnight on | |
113 absolute date ABS-DATE is the equivalent moment to X." | |
114 (let* ((h (car x)) | |
92850 | 115 (xtail (cdr x)) |
3872 | 116 (l (+ utc-diff (if (numberp xtail) xtail (car xtail)))) |
4535 | 117 (u (+ (* 512 (mod h 675)) (floor l 128)))) |
3872 | 118 ;; Overflow is a terrible thing! |
119 (cons (+ calendar-system-time-basis | |
92850 | 120 ;; floor((2^16 h +l) / (60*60*24)) |
121 (* 512 (floor h 675)) (floor u 675)) | |
122 ;; (2^16 h +l) mod (60*60*24) | |
123 (+ (* (mod u 675) 128) (mod l 128))))) | |
3872 | 124 |
125 (defun calendar-time-from-absolute (abs-date s) | |
126 "Time of absolute date ABS-DATE, S seconds after midnight. | |
127 | |
56425
5572efece9a6
(calendar-time-from-absolute): Return a list of two integers, instead
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
128 Returns the list (HIGH LOW) where HIGH and LOW are the high and low |
3872 | 129 16 bits, respectively, of the number of seconds 1970-01-01 00:00:00 UTC, |
130 ignoring leap seconds, that is the equivalent moment to S seconds after | |
131 midnight UTC on absolute date ABS-DATE." | |
132 (let* ((a (- abs-date calendar-system-time-basis)) | |
4535 | 133 (u (+ (* 163 (mod a 512)) (floor s 128)))) |
3872 | 134 ;; Overflow is a terrible thing! |
56425
5572efece9a6
(calendar-time-from-absolute): Return a list of two integers, instead
Luc Teirlinck <teirllm@auburn.edu>
parents:
52401
diff
changeset
|
135 (list |
5001
f3a55af8f584
(calendar-absolute-from-time): Undo Sep 14 patch.
Richard M. Stallman <rms@gnu.org>
parents:
4756
diff
changeset
|
136 ;; floor((60*60*24*a + s) / 2^16) |
4535 | 137 (+ 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
|
138 ;; (60*60*24*a + s) mod 2^16 |
4535 | 139 (+ (* 128 (mod u 512)) (mod s 128))))) |
3872 | 140 |
141 (defun calendar-next-time-zone-transition (time) | |
142 "Return the time of the next time zone transition after TIME. | |
92640
21bbfdf10ce1
(calendar-next-time-zone-transition, calendar-time-zone): Doc fixes.
Glenn Morris <rgm@gnu.org>
parents:
92581
diff
changeset
|
143 Both TIME and the result are acceptable arguments to `current-time-zone'. |
3872 | 144 Return nil if no such transition can be found." |
92965 | 145 (let* ((base 65536) ; 2^16 = base of current-time output |
146 (quarter-multiple 120) ; approx = (seconds per quarter year) / base | |
92850 | 147 (time-zone (current-time-zone time)) |
148 (time-utc-diff (car time-zone)) | |
3872 | 149 hi |
92850 | 150 hi-zone |
3872 | 151 (hi-utc-diff time-utc-diff) |
152 (quarters '(2 1 3))) | |
153 ;; Heuristic: probe the time zone offset in the next three calendar | |
154 ;; quarters, looking for a time zone offset different from TIME. | |
155 (while (and quarters (eq time-utc-diff hi-utc-diff)) | |
92914
83321455f486
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92850
diff
changeset
|
156 (setq hi (cons (+ (car time) (* (car quarters) quarter-multiple)) 0) |
83321455f486
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92850
diff
changeset
|
157 hi-zone (current-time-zone hi) |
83321455f486
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92850
diff
changeset
|
158 hi-utc-diff (car hi-zone) |
83321455f486
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92850
diff
changeset
|
159 quarters (cdr quarters))) |
3872 | 160 (and |
161 time-utc-diff | |
162 hi-utc-diff | |
163 (not (eq time-utc-diff hi-utc-diff)) | |
164 ;; Now HI is after the next time zone transition. | |
165 ;; Set LO to TIME, and then binary search to increase LO and decrease HI | |
166 ;; until LO is just before and HI is just after the time zone transition. | |
167 (let* ((tail (cdr time)) | |
92850 | 168 (lo (cons (car time) (if (numberp tail) tail (car tail)))) |
169 probe) | |
3872 | 170 (while |
92850 | 171 ;; Set PROBE to halfway between LO and HI, rounding down. |
172 ;; If PROBE equals LO, we are done. | |
173 (let* ((lsum (+ (cdr lo) (cdr hi))) | |
174 (hsum (+ (car lo) (car hi) (/ lsum base))) | |
175 (hsumodd (logand 1 hsum))) | |
176 (setq probe (cons (/ (- hsum hsumodd) 2) | |
177 (/ (+ (* hsumodd base) (% lsum base)) 2))) | |
178 (not (equal lo probe))) | |
179 ;; Set either LO or HI to PROBE, depending on probe results. | |
180 (if (eq (car (current-time-zone probe)) hi-utc-diff) | |
181 (setq hi probe) | |
182 (setq lo probe))) | |
3872 | 183 hi)))) |
184 | |
93650
e13ec6b5b482
Update for cal-persia name changes.
Glenn Morris <rgm@gnu.org>
parents:
93526
diff
changeset
|
185 (autoload 'calendar-persian-to-absolute "cal-persia") |
93222 | 186 |
3872 | 187 (defun calendar-time-zone-daylight-rules (abs-date utc-diff) |
188 "Return daylight transition rule for ABS-DATE, UTC-DIFF sec offset from UTC. | |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
189 ABS-DATE must specify a day that contains a daylight saving transition. |
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
190 The result has the proper form for `calendar-daylight-savings-starts'." |
3872 | 191 (let* ((date (calendar-gregorian-from-absolute abs-date)) |
92850 | 192 (weekday (% abs-date 7)) |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93737
diff
changeset
|
193 (m (calendar-extract-month date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93737
diff
changeset
|
194 (d (calendar-extract-day date)) |
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93737
diff
changeset
|
195 (y (calendar-extract-year date)) |
3872 | 196 (last (calendar-last-day-of-month m y)) |
93526
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
197 j rlist |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
198 (candidate-rules ; these return Gregorian dates |
92850 | 199 (append |
200 ;; Day D of month M. | |
93526
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
201 `((list ,m ,d year)) |
92850 | 202 ;; The first WEEKDAY of month M. |
3872 | 203 (if (< d 8) |
93526
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
204 `((calendar-nth-named-day 1 ,weekday ,m year))) |
92850 | 205 ;; The last WEEKDAY of month M. |
3872 | 206 (if (> d (- last 7)) |
93526
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
207 `((calendar-nth-named-day -1 ,weekday ,m year))) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
208 (progn |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
209 ;; The first WEEKDAY after day J of month M, for D-6 < J <= D. |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
210 (setq j (1- (max 2 (- d 6)))) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
211 (while (<= (setq j (1+ j)) (min d (- last 8))) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
212 (push `(calendar-nth-named-day 1 ,weekday ,m year ,j) rlist)) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
213 rlist) |
92850 | 214 ;; 01-01 and 07-01 for this year's Persian calendar. |
93526
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
215 ;; FIXME what does the Persian calendar have to do with this? |
103562
decf5e666b9e
(calendar-time-zone-daylight-rules): Simplify Persian conditionals.
Glenn Morris <rgm@gnu.org>
parents:
103371
diff
changeset
|
216 (and (= m 3) (memq d '(20 21)) |
decf5e666b9e
(calendar-time-zone-daylight-rules): Simplify Persian conditionals.
Glenn Morris <rgm@gnu.org>
parents:
103371
diff
changeset
|
217 '((calendar-gregorian-from-absolute |
decf5e666b9e
(calendar-time-zone-daylight-rules): Simplify Persian conditionals.
Glenn Morris <rgm@gnu.org>
parents:
103371
diff
changeset
|
218 (calendar-persian-to-absolute `(1 1 ,(- year 621)))))) |
decf5e666b9e
(calendar-time-zone-daylight-rules): Simplify Persian conditionals.
Glenn Morris <rgm@gnu.org>
parents:
103371
diff
changeset
|
219 (and (= m 9) (memq d '(22 23)) |
decf5e666b9e
(calendar-time-zone-daylight-rules): Simplify Persian conditionals.
Glenn Morris <rgm@gnu.org>
parents:
103371
diff
changeset
|
220 '((calendar-gregorian-from-absolute |
decf5e666b9e
(calendar-time-zone-daylight-rules): Simplify Persian conditionals.
Glenn Morris <rgm@gnu.org>
parents:
103371
diff
changeset
|
221 (calendar-persian-to-absolute `(7 1 ,(- year 621)))))))) |
92965 | 222 (prevday-sec (- -1 utc-diff)) ; last sec of previous local day |
93526
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
223 (year (1+ y)) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
224 new-rules) |
4659
031aaf217dc3
(calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents:
4535
diff
changeset
|
225 ;; Scan through the next few years until only one rule remains. |
93526
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
226 (while (cdr candidate-rules) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
227 (dolist (rule candidate-rules) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
228 ;; The rule we return should give a Gregorian date, but here |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
229 ;; we require an absolute date. The following is for efficiency. |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
230 (setq date (cond ((eq (car rule) 'calendar-nth-named-day) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
231 (eval (cons 'calendar-nth-named-absday (cdr rule)))) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
232 ((eq (car rule) 'calendar-gregorian-from-absolute) |
103371
261b17f9df8e
(calendar-time-zone-daylight-rules): Fix typo in 2008-04-02 change.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
233 (eval (cadr rule))) |
93526
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
234 (t (calendar-absolute-from-gregorian (eval rule))))) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
235 (or (equal (current-time-zone |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
236 (calendar-time-from-absolute date prevday-sec)) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
237 (current-time-zone |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
238 (calendar-time-from-absolute (1+ date) prevday-sec))) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
239 (setq new-rules (cons rule new-rules)))) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
240 ;; If no rules remain, just use the first candidate rule; |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
241 ;; it's wrong in general, but it's right for at least one year. |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
242 (setq candidate-rules (if new-rules (nreverse new-rules) |
90118d6d9050
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
93479
diff
changeset
|
243 (list (car candidate-rules))) |
93737 | 244 new-rules nil |
245 year (1+ year))) | |
4659
031aaf217dc3
(calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents:
4535
diff
changeset
|
246 (car candidate-rules))) |
3872 | 247 |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
248 ;; TODO it might be better to extract this information directly from |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
249 ;; the system timezone database. But cross-platform...? |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
250 ;; See thread |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
251 ;; http://lists.gnu.org/archive/html/emacs-pretest-bug/2006-11/msg00060.html |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
252 (defun calendar-dst-find-data (&optional time) |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
253 "Find data on the first daylight saving time transitions after TIME. |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
254 TIME defaults to `current-time'. Return value is as described |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
255 for `calendar-current-time-zone'." |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
256 (let* ((t0 (or time (current-time))) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
257 (t0-zone (current-time-zone t0)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
258 (t0-utc-diff (car t0-zone)) |
92914
83321455f486
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92850
diff
changeset
|
259 (t0-name (cadr t0-zone))) |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
260 (if (not t0-utc-diff) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
261 ;; Little or no time zone information is available. |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
262 (list nil nil t0-name t0-name nil nil nil nil) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
263 (let* ((t1 (calendar-next-time-zone-transition t0)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
264 (t2 (and t1 (calendar-next-time-zone-transition t1)))) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
265 (if (not t2) |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
266 ;; This locale does not have daylight saving time. |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
267 (list (/ t0-utc-diff 60) 0 t0-name t0-name nil nil 0 0) |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
268 ;; Use heuristics to find daylight saving parameters. |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
269 (let* ((t1-zone (current-time-zone t1)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
270 (t1-utc-diff (car t1-zone)) |
92914
83321455f486
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92850
diff
changeset
|
271 (t1-name (cadr t1-zone)) |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
272 (t1-date-sec (calendar-absolute-from-time t1 t0-utc-diff)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
273 (t2-date-sec (calendar-absolute-from-time t2 t1-utc-diff)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
274 ;; TODO When calendar-dst-check-each-year-flag is non-nil, |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
275 ;; the rules can be simpler than they currently are. |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
276 (t1-rules (calendar-time-zone-daylight-rules |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
277 (car t1-date-sec) t0-utc-diff)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
278 (t2-rules (calendar-time-zone-daylight-rules |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
279 (car t2-date-sec) t1-utc-diff)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
280 (t1-time (/ (cdr t1-date-sec) 60)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
281 (t2-time (/ (cdr t2-date-sec) 60))) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
282 (cons |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
283 (/ (min t0-utc-diff t1-utc-diff) 60) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
284 (cons |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
285 (/ (abs (- t0-utc-diff t1-utc-diff)) 60) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
286 (if (< t0-utc-diff t1-utc-diff) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
287 (list t0-name t1-name t1-rules t2-rules t1-time t2-time) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
288 (list t1-name t0-name t2-rules t1-rules t2-time t1-time) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
289 ))))))))) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
290 |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
291 (defvar calendar-dst-transition-cache nil |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
292 "Internal cal-dst variable storing date of daylight saving time transitions. |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
293 Value is a list with elements of the form (YEAR START END), where |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
294 START and END are expressions that when evaluated return the |
92640
21bbfdf10ce1
(calendar-next-time-zone-transition, calendar-time-zone): Doc fixes.
Glenn Morris <rgm@gnu.org>
parents:
92581
diff
changeset
|
295 start and end dates (respectively) for DST in YEAR. Used by the |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
296 function `calendar-dst-find-startend'.") |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
297 |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
298 (defun calendar-dst-find-startend (year) |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
299 "Find the dates in YEAR on which daylight saving time starts and ends. |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
300 Returns a list (YEAR START END), where START and END are |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
301 expressions that when evaluated return the start and end dates, |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
302 respectively. This function first attempts to use pre-calculated |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
303 data from `calendar-dst-transition-cache', otherwise it calls |
77277
c56fcbc72ab0
(calendar-dst-find-startend): If YEAR cannot be encoded, fall back to
Glenn Morris <rgm@gnu.org>
parents:
76476
diff
changeset
|
304 `calendar-dst-find-data' (and adds the results to the cache). |
c56fcbc72ab0
(calendar-dst-find-startend): If YEAR cannot be encoded, fall back to
Glenn Morris <rgm@gnu.org>
parents:
76476
diff
changeset
|
305 If dates in YEAR cannot be handled by `encode-time' (e.g. if they |
c56fcbc72ab0
(calendar-dst-find-startend): If YEAR cannot be encoded, fall back to
Glenn Morris <rgm@gnu.org>
parents:
76476
diff
changeset
|
306 are too large to be represented as a lisp integer), then rather |
c56fcbc72ab0
(calendar-dst-find-startend): If YEAR cannot be encoded, fall back to
Glenn Morris <rgm@gnu.org>
parents:
76476
diff
changeset
|
307 than an error this function returns the result appropriate for |
c56fcbc72ab0
(calendar-dst-find-startend): If YEAR cannot be encoded, fall back to
Glenn Morris <rgm@gnu.org>
parents:
76476
diff
changeset
|
308 the current year." |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
309 (let ((e (assoc year calendar-dst-transition-cache)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
310 f) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
311 (or e |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
312 (progn |
77277
c56fcbc72ab0
(calendar-dst-find-startend): If YEAR cannot be encoded, fall back to
Glenn Morris <rgm@gnu.org>
parents:
76476
diff
changeset
|
313 (setq e (calendar-dst-find-data |
c56fcbc72ab0
(calendar-dst-find-startend): If YEAR cannot be encoded, fall back to
Glenn Morris <rgm@gnu.org>
parents:
76476
diff
changeset
|
314 (condition-case nil |
c56fcbc72ab0
(calendar-dst-find-startend): If YEAR cannot be encoded, fall back to
Glenn Morris <rgm@gnu.org>
parents:
76476
diff
changeset
|
315 (encode-time 1 0 0 1 1 year) |
c56fcbc72ab0
(calendar-dst-find-startend): If YEAR cannot be encoded, fall back to
Glenn Morris <rgm@gnu.org>
parents:
76476
diff
changeset
|
316 (error |
c56fcbc72ab0
(calendar-dst-find-startend): If YEAR cannot be encoded, fall back to
Glenn Morris <rgm@gnu.org>
parents:
76476
diff
changeset
|
317 (encode-time 1 0 0 1 1 (nth 5 (decode-time)))))) |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
318 f (nth 4 e) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
319 e (list year f (nth 5 e)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
320 calendar-dst-transition-cache |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
321 (append calendar-dst-transition-cache (list e))) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
322 e)))) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
323 |
3872 | 324 (defun calendar-current-time-zone () |
325 "Return UTC difference, dst offset, names and rules for current time zone. | |
326 | |
4659
031aaf217dc3
(calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents:
4535
diff
changeset
|
327 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
|
328 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
|
329 system knows: |
3872 | 330 |
331 UTC-DIFF is an integer specifying the number of minutes difference between | |
332 standard time in the current time zone and Coordinated Universal Time | |
333 (Greenwich Mean Time). A negative value means west of Greenwich. | |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
334 DST-OFFSET is an integer giving the daylight saving time offset in minutes. |
3872 | 335 STD-ZONE is a string giving the name of the time zone when no seasonal time |
336 adjustment is in effect. | |
337 DST-ZONE is a string giving the name of the time zone when there is a seasonal | |
338 time adjustment in effect. | |
339 DST-STARTS and DST-ENDS are sexps in the variable `year' giving the daylight | |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
340 saving time start and end rules, in the form expected by |
3872 | 341 `calendar-daylight-savings-starts'. |
4659
031aaf217dc3
(calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents:
4535
diff
changeset
|
342 DST-STARTS-TIME and DST-ENDS-TIME are integers giving the number of minutes |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
343 after midnight that daylight saving time starts and ends. |
3872 | 344 |
4659
031aaf217dc3
(calendar-time-zone-daylight-rules): Scan through the
Paul Eggert <eggert@twinsun.com>
parents:
4535
diff
changeset
|
345 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
|
346 DST-ZONE are equal, and all the DST-* integer variables are 0. |
3872 | 347 |
348 Some operating systems cannot provide all this information to Emacs; in this | |
349 case, `calendar-current-time-zone' returns a list containing nil for the data | |
350 it can't find." | |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
351 (unless calendar-current-time-zone-cache |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
352 (setq calendar-current-time-zone-cache (calendar-dst-find-data)))) |
3872 | 353 |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
354 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
355 ;; Following options should be set based on conditions when the code |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
356 ;; is invoked, so are not suitable for dumping into loaddefs.el. They |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
357 ;; default to US Eastern time if time zone info is not available. |
3872 | 358 |
359 (calendar-current-time-zone) | |
360 | |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
361 (defcustom calendar-time-zone (or (car calendar-current-time-zone-cache) -300) |
92640
21bbfdf10ce1
(calendar-next-time-zone-transition, calendar-time-zone): Doc fixes.
Glenn Morris <rgm@gnu.org>
parents:
92581
diff
changeset
|
362 "Number of minutes difference between local standard time and UTC. |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
363 For example, -300 for New York City, -480 for Los Angeles." |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
364 :type 'integer |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
365 :group 'calendar-dst) |
3872 | 366 |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
367 (defcustom calendar-daylight-time-offset |
92914
83321455f486
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92850
diff
changeset
|
368 (or (cadr calendar-current-time-zone-cache) 60) |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
369 "Number of minutes difference between daylight saving and standard time. |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
370 If the locale never uses daylight saving time, set this to 0." |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
371 :type 'integer |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
372 :group 'calendar-dst) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
373 |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
374 (defcustom calendar-standard-time-zone-name |
92914
83321455f486
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92850
diff
changeset
|
375 (or (nth 2 calendar-current-time-zone-cache) "EST") |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
376 "Abbreviated name of standard time zone at `calendar-location-name'. |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
377 For example, \"EST\" in New York City, \"PST\" for Los Angeles." |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
378 :type 'string |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
379 :group 'calendar-dst) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
380 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
381 (defcustom calendar-daylight-time-zone-name |
92914
83321455f486
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92850
diff
changeset
|
382 (or (nth 3 calendar-current-time-zone-cache) "EDT") |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
383 "Abbreviated name of daylight saving time zone at `calendar-location-name'. |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
384 For example, \"EDT\" in New York City, \"PDT\" for Los Angeles." |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
385 :type 'string |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
386 :group 'calendar-dst) |
3872 | 387 |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
388 (defcustom calendar-daylight-savings-starts-time |
92914
83321455f486
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92850
diff
changeset
|
389 (or (nth 6 calendar-current-time-zone-cache) 120) |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
390 "Number of minutes after midnight that daylight saving time starts." |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
391 :type 'integer |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
392 :group 'calendar-dst) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
393 |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
394 (defcustom calendar-daylight-savings-ends-time |
92914
83321455f486
(calendar-time-zone-daylight-rules): Simplify.
Glenn Morris <rgm@gnu.org>
parents:
92850
diff
changeset
|
395 (or (nth 7 calendar-current-time-zone-cache) |
92552
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
396 calendar-daylight-savings-starts-time) |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
397 "Number of minutes after midnight that daylight saving time ends." |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
398 :type 'integer |
19c69f1fd028
(calendar-dst): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
79703
diff
changeset
|
399 :group 'calendar-dst) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
38422
diff
changeset
|
400 |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
401 |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
402 (defun calendar-dst-starts (year) |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
403 "Return the date of YEAR on which daylight saving time starts. |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
404 This function respects the value of `calendar-dst-check-each-year-flag'." |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
405 (or (let ((expr (if calendar-dst-check-each-year-flag |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
406 (cadr (calendar-dst-find-startend year)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
407 (nth 4 calendar-current-time-zone-cache)))) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
408 (if expr (eval expr))) |
92850 | 409 ;; New US rules commencing 2007. ftp://elsie.nci.nih.gov/pub/. |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
410 (and (not (zerop calendar-daylight-time-offset)) |
74870
06cc5e77c85a
(calendar-dst-starts): Default to second Sunday in March.
Richard M. Stallman <rms@gnu.org>
parents:
73894
diff
changeset
|
411 (calendar-nth-named-day 2 0 3 year)))) |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
412 |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
413 (defun calendar-dst-ends (year) |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
414 "Return the date of YEAR on which daylight saving time ends. |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
415 This function respects the value of `calendar-dst-check-each-year-flag'." |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
416 (or (let ((expr (if calendar-dst-check-each-year-flag |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
417 (nth 2 (calendar-dst-find-startend year)) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
418 (nth 5 calendar-current-time-zone-cache)))) |
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
419 (if expr (eval expr))) |
92850 | 420 ;; New US rules commencing 2007. ftp://elsie.nci.nih.gov/pub/. |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
421 (and (not (zerop calendar-daylight-time-offset)) |
74870
06cc5e77c85a
(calendar-dst-starts): Default to second Sunday in March.
Richard M. Stallman <rms@gnu.org>
parents:
73894
diff
changeset
|
422 (calendar-nth-named-day 1 0 11 year)))) |
73875
be323d585de0
Do not assume DST starts/ends on the same date in every year.
Glenn Morris <rgm@gnu.org>
parents:
68721
diff
changeset
|
423 |
93991
09c830b8981d
(calendar-dst-check-each-year-flag): Fix custom group.
Glenn Morris <rgm@gnu.org>
parents:
93809
diff
changeset
|
424 ;; used by calc, solar. |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
425 (defun dst-in-effect (date) |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
426 "True if on absolute DATE daylight saving time is in effect. |
13686
6e3b9c9595eb
Fixed dst-in-effect for southern hemisphere. Also made doc string clearer.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13049
diff
changeset
|
427 Fractional part of DATE is local standard time of day." |
93809
3ff2b47de8f2
Update for calendar.el name changes.
Glenn Morris <rgm@gnu.org>
parents:
93737
diff
changeset
|
428 (let* ((year (calendar-extract-year |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
429 (calendar-gregorian-from-absolute (floor date)))) |
13686
6e3b9c9595eb
Fixed dst-in-effect for southern hemisphere. Also made doc string clearer.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13049
diff
changeset
|
430 (dst-starts-gregorian (eval calendar-daylight-savings-starts)) |
6e3b9c9595eb
Fixed dst-in-effect for southern hemisphere. Also made doc string clearer.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13049
diff
changeset
|
431 (dst-ends-gregorian (eval calendar-daylight-savings-ends)) |
6e3b9c9595eb
Fixed dst-in-effect for southern hemisphere. Also made doc string clearer.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13049
diff
changeset
|
432 (dst-starts (and dst-starts-gregorian |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
433 (+ (calendar-absolute-from-gregorian |
13686
6e3b9c9595eb
Fixed dst-in-effect for southern hemisphere. Also made doc string clearer.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13049
diff
changeset
|
434 dst-starts-gregorian) |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
435 (/ calendar-daylight-savings-starts-time |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
436 60.0 24.0)))) |
13686
6e3b9c9595eb
Fixed dst-in-effect for southern hemisphere. Also made doc string clearer.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13049
diff
changeset
|
437 (dst-ends (and dst-ends-gregorian |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
438 (+ (calendar-absolute-from-gregorian |
13686
6e3b9c9595eb
Fixed dst-in-effect for southern hemisphere. Also made doc string clearer.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13049
diff
changeset
|
439 dst-ends-gregorian) |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
440 (/ (- calendar-daylight-savings-ends-time |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
441 calendar-daylight-time-offset) |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
442 60.0 24.0))))) |
13686
6e3b9c9595eb
Fixed dst-in-effect for southern hemisphere. Also made doc string clearer.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13049
diff
changeset
|
443 (and dst-starts dst-ends |
6e3b9c9595eb
Fixed dst-in-effect for southern hemisphere. Also made doc string clearer.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13049
diff
changeset
|
444 (if (< dst-starts dst-ends) |
6e3b9c9595eb
Fixed dst-in-effect for southern hemisphere. Also made doc string clearer.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13049
diff
changeset
|
445 (and (<= dst-starts date) (< date dst-ends)) |
6e3b9c9595eb
Fixed dst-in-effect for southern hemisphere. Also made doc string clearer.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
13049
diff
changeset
|
446 (or (<= dst-starts date) (< date dst-ends)))))) |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
447 |
93991
09c830b8981d
(calendar-dst-check-each-year-flag): Fix custom group.
Glenn Morris <rgm@gnu.org>
parents:
93809
diff
changeset
|
448 ;; used by calc, lunar, solar. |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
449 (defun dst-adjust-time (date time &optional style) |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
450 "Adjust, to account for dst on DATE, decimal fraction standard TIME. |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
451 Returns a list (date adj-time zone) where `date' and `adj-time' are the values |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
452 adjusted for `zone'; here `date' is a list (month day year), `adj-time' is a |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
453 decimal fraction time, and `zone' is a string. |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
454 |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
455 Optional parameter STYLE forces the result time to be standard time when its |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
456 value is 'standard and daylight saving time (if available) when its value is |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
457 'daylight. |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
458 |
76476
3878691bdbb7
Change "daylight savings time" -> "daylight saving time" throughout.
Chong Yidong <cyd@stupidchicken.com>
parents:
75346
diff
changeset
|
459 Conversion to daylight saving time is done according to |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
460 `calendar-daylight-savings-starts', `calendar-daylight-savings-ends', |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
461 `calendar-daylight-savings-starts-time', |
93222 | 462 `calendar-daylight-savings-ends-time', and `calendar-daylight-time-offset'." |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
463 (let* ((rounded-abs-date (+ (calendar-absolute-from-gregorian date) |
92850 | 464 (/ (round (* 60 time)) 60.0 24.0))) |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
465 (dst (dst-in-effect rounded-abs-date)) |
92850 | 466 (time-zone (if dst |
467 calendar-daylight-time-zone-name | |
468 calendar-standard-time-zone-name)) | |
469 (time (+ rounded-abs-date | |
13049
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
470 (if dst (/ calendar-daylight-time-offset 24.0 60.0) 0)))) |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
471 (list (calendar-gregorian-from-absolute (truncate time)) |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
472 (* 24.0 (- time (truncate time))) |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
473 time-zone))) |
fac816f95bd8
Minor fixes; moved some code here from other calendar files.
Edward M. Reingold <reingold@emr.cs.iit.edu>
parents:
7749
diff
changeset
|
474 |
3872 | 475 (provide 'cal-dst) |
476 | |
477 ;;; cal-dst.el ends here |