From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/10692 Path: main.gmane.org!not-for-mail From: Brad Howes Newsgroups: gmane.emacs.gnus.general Subject: gnus-demon time problem Date: 14 Apr 1997 13:29:41 -0700 Message-ID: NNTP-Posting-Host: coloc-standby.netfonds.no X-Trace: main.gmane.org 1035150518 25782 80.91.224.250 (20 Oct 2002 21:48:38 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 21:48:38 +0000 (UTC) Return-Path: Original-Received: from ifi.uio.no (0@ifi.uio.no [129.240.64.2]) by deanna.miranova.com (8.8.5/8.8.5) with SMTP id NAA08851 for ; Mon, 14 Apr 1997 13:40:33 -0700 Original-Received: from motgate.mot.com (motgate.mot.com [129.188.136.100]) by ifi.uio.no with ESMTP (8.6.11/ifi2.4) id for ; Mon, 14 Apr 1997 22:29:55 +0200 Original-Received: from pobox.mot.com (pobox.mot.com [129.188.137.100]) by motgate.mot.com (8.7.6/8.6.10/MOT-3.8) with ESMTP id PAA28741 for ; Mon, 14 Apr 1997 15:29:47 -0500 (CDT) Original-Received: from cssun3.corp.mot.com (cssun3.corp.mot.com [129.188.230.120]) by pobox.mot.com (8.7.6/8.6.10/MOT-3.8) with SMTP id PAA25544 for ; Mon, 14 Apr 1997 15:29:45 -0500 (CDT) Original-Received: (qmail 6369 invoked by uid 4465); 14 Apr 1997 20:29:43 -0000 Original-To: ding@ifi.uio.no Xref: main.gmane.org gmane.emacs.gnus.general:10692 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:10692 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