Function: gnus-user-format-function-d

gnus-user-format-function-d is an autoloaded and byte-compiled function defined in gnus-diary.el.gz.

Signature

(gnus-user-format-function-d HEADER)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-diary.el.gz
;; #### NOTE: Gnus sometimes gives me a HEADER not corresponding to any
;; message, with all fields set to nil here. I don't know what it is for, and
;; I just ignore it.
;;;###autoload
(defun gnus-user-format-function-d (header)
  ;; Return an approximate delay string for the next occurrence of this
  ;; message. The delay is given only in the first non zero unit.
  ;; Code partly stolen from article-make-date-line
  (let* ((extras (mail-header-extra header))
	 (sched (gnus-diary-header-schedule extras))
	 (now (current-time))
	 (occur (nndiary-next-occurrence sched now))
	 (real-time (time-subtract occur now)))
    (let* ((sec (time-convert real-time 'integer))
	   (past (< sec 0))
	   delay)
      (and past (setq sec (- sec)))
      (unless (zerop sec)
	;; This is a bit convoluted, but basically we go through the time
	;; units for years, weeks, etc, and divide things to see whether
	;; that results in positive answers.
	(let ((units `((year . ,(round (* 365.25 24 3600)))
		       (month . ,(* 31 24 3600))
		       (week . ,(* 7 24 3600))
		       (day . ,(* 24 3600))
		       (hour . 3600)
		       (minute . 60)))
	      unit num)
	  (while (setq unit (pop units))
	    (unless (zerop (setq num (floor sec (cdr unit))))
	      (setq delay (append delay `((,num . ,(car unit))))))
	    (setq sec (mod sec (cdr unit))))))
      (funcall gnus-diary-delay-format-function past delay))))