Function: article-lapsed-string

article-lapsed-string is a byte-compiled function defined in gnus-art.el.gz.

Signature

(article-lapsed-string TIME &optional MAX-SEGMENTS)

Source Code

;; Defined in /usr/src/emacs/lisp/gnus/gnus-art.el.gz
(defun article-lapsed-string (time &optional max-segments)
  ;; If the date is seriously mangled, the timezone functions are
  ;; liable to bug out, so we ignore all errors.
  (let* ((real-time (time-since time))
	 (real-sec (float-time real-time))
	 (sec (abs real-sec))
	 (segments 0)
	 num prev)
    (unless max-segments
      (setq max-segments (length article-time-units)))
    (cond
     ((< (abs sec) 1)
      "Now")
     (t
      (concat
       ;; 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.
       (mapconcat
	(lambda (unit)
	  (if (or (zerop (setq num (ffloor (/ sec (cdr unit)))))
		  (>= segments max-segments))
	      ;; The (remaining) seconds are too few to
	      ;; be divided into this time unit.
	      ""
	    ;; It's big enough, so we output it.
	    (setq sec (- sec (* num (cdr unit))))
	    (prog1
		(concat (if prev ", " "") (int-to-string
					   (floor num))
			" " (symbol-name (car unit))
			(if (> num 1) "s" ""))
	      (setq prev t
		    segments (1+ segments)))))
	article-time-units "")
       ;; If dates are odd, then it might appear like the
       ;; article was sent in the future.
       (if (> real-sec 0)
	   " ago"
	 " in the future"))))))