1 |
;;; gnus-demon.el --- daemonic Gnus behaviour |
;;; gnus-demon.el --- daemonic Gnus behaviour |
2 |
;; Copyright (C) 1995,96,97,98,99 Free Software Foundation, Inc. |
|
3 |
|
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003 |
4 |
|
;; Free Software Foundation, Inc. |
5 |
|
|
6 |
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
7 |
;; Keywords: news |
;; Keywords: news |
150 |
(if (not (stringp time)) |
(if (not (stringp time)) |
151 |
time |
time |
152 |
(let* ((now (current-time)) |
(let* ((now (current-time)) |
153 |
;; obtain NOW as discrete components -- make a vector for speed |
;; obtain NOW as discrete components -- make a vector for speed |
154 |
(nowParts (decode-time now)) |
(nowParts (decode-time now)) |
155 |
;; obtain THEN as discrete components |
;; obtain THEN as discrete components |
156 |
(thenParts (parse-time-string time)) |
(thenParts (parse-time-string time)) |
157 |
(thenHour (elt thenParts 2)) |
(thenHour (elt thenParts 2)) |
158 |
(thenMin (elt thenParts 1)) |
(thenMin (elt thenParts 1)) |
159 |
;; convert time as elements into number of seconds since EPOCH. |
;; convert time as elements into number of seconds since EPOCH. |
160 |
(then (encode-time 0 |
(then (encode-time 0 |
161 |
thenMin |
thenMin |
162 |
thenHour |
thenHour |
163 |
;; If THEN is earlier than NOW, make it |
;; If THEN is earlier than NOW, make it |
164 |
;; same time tomorrow. Doc for encode-time |
;; same time tomorrow. Doc for encode-time |
165 |
;; says that this is OK. |
;; says that this is OK. |
166 |
(+ (elt nowParts 3) |
(+ (elt nowParts 3) |
167 |
(if (or (< thenHour (elt nowParts 2)) |
(if (or (< thenHour (elt nowParts 2)) |
168 |
(and (= thenHour (elt nowParts 2)) |
(and (= thenHour (elt nowParts 2)) |
169 |
(<= thenMin (elt nowParts 1)))) |
(<= thenMin (elt nowParts 1)))) |
170 |
1 0)) |
1 0)) |
171 |
(elt nowParts 4) |
(elt nowParts 4) |
172 |
(elt nowParts 5) |
(elt nowParts 5) |
173 |
(elt nowParts 6) |
(elt nowParts 6) |
174 |
(elt nowParts 7) |
(elt nowParts 7) |
175 |
(elt nowParts 8))) |
(elt nowParts 8))) |
176 |
;; calculate number of seconds between NOW and THEN |
;; calculate number of seconds between NOW and THEN |
177 |
(diff (+ (* 65536 (- (car then) (car now))) |
(diff (+ (* 65536 (- (car then) (car now))) |
178 |
(- (cadr then) (cadr now))))) |
(- (cadr then) (cadr now))))) |
179 |
;; return number of timesteps in the number of seconds |
;; return number of timesteps in the number of seconds |
180 |
(round (/ diff gnus-demon-timestep))))) |
(round (/ diff gnus-demon-timestep))))) |
181 |
|
|