From: Brad Howes <bhowes@cssun3.corp.mot.com>
Subject: gnus-demon time problem
Date: 14 Apr 1997 13:29:41 -0700 [thread overview]
Message-ID: <wjyg1wt73gq.fsf@cssun3.corp.mot.com> (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
reply other threads:[~1997-04-14 20:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=wjyg1wt73gq.fsf@cssun3.corp.mot.com \
--to=bhowes@cssun3.corp.mot.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).