* gnus-demon time problem
@ 1997-04-14 20:29 Brad Howes
0 siblings, 0 replies; only message in thread
From: Brad Howes @ 1997-04-14 20:29 UTC (permalink / raw)
I've been unable to successfully get a handler to run at the proper time
using gnus-demon-add-handler and a string time (eg. "01:00").
Invariably, the handler runs at odd times -- seen when I put
`(message (current-time-string))' at the end of my handler.
Sniffing around, I noticed that gnus-demon-handler-state had bogus
values for the time. Further, I found that `gnus-demon-time-to-step'
would translate the given time "01:00" into the value GMT! Definitely
not what I had in mind (this on Solaris 2.4/Emacs 19.34) since I'm MST.
Anyway, I looked and looked and did not think gnus-demon-time-to-step
was doing the right thing, so here's my version that seems to work just
fine for me:
;;
;; Replacement for gnus-demon-time-to-step found in gnus-demon.el
;;
(defun gnus-demon-time-to-step (time)
"Find out how many seconds to TIME, which is on the form \"17:43\"."
(if (not (stringp time))
time
(let* ((now (current-time))
;; obtain NOW as discrete components -- make a vector for speed
(nowParts (apply 'vector (decode-time now)))
;; obtain THEN as discrete components
(thenParts (timezone-parse-time time))
(thenHour (string-to-int (elt thenParts 0)))
(thenMin (string-to-int (elt thenParts 1)))
;; convert time as elements into number of seconds since EPOCH.
(then (encode-time 0
thenMin
thenHour
;; If THEN is earlier than NOW, make it
;; same time tomorrow. Doc for encode-time
;; says that this is OK.
(+ (elt nowParts 3)
(if (or (< thenHour (elt nowParts 2))
(and (= thenHour (elt nowParts 2))
(<= thenMin (elt nowParts 1))))
1 0))
(elt nowParts 4)
(elt nowParts 5)
(elt nowParts 6)
(elt nowParts 7)
(elt nowParts 8)))
;; calculate number of seconds between NOW and THEN
(diff (+ (* 65536 (- (car then) (car now)))
(- (cadr then) (cadr now)))))
;; return number of timesteps in the number of seconds
(round (/ diff gnus-demon-timestep)))))
--
Brad Howes Motorola E-Mail ID: XBH001
EMT Development SMTP E-Mail: bhowes@cssun3.corp.mot.com
Motorola Corporate - MD H1780 Voice: 602 441 1522 Fax: 602 441 5455
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1997-04-14 20:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-04-14 20:29 gnus-demon time problem Brad Howes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).