annotate lisp/calendar/cal-dst.el @ 4390:faf739d1d572

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