Gnus development mailing list
 help / color / mirror / Atom feed
* [Code] New date-format for summary-line
@ 2001-10-14 22:03 Frank Schmitt
  2001-10-15 10:55 ` Frank Schmitt
  0 siblings, 1 reply; 9+ messages in thread
From: Frank Schmitt @ 2001-10-14 22:03 UTC (permalink / raw)


Hi all.

The following function gives you the possibility to have different
date-formats in gnus-summary-line depending on if the article is of
today, this week, or older. 

I think the best place for this function would be gnus-util.el (at least
there are the other gnus-date functions. There should be a new item in
gnus-summary-line-format-alist like this:
(?q (gnus-user-date (mail-header-date gnus-tmp-header)) ?s)

It's my first lisp code, so don't hit me to hard if it's bullshit. At
least it does work over here.

;;there should be of course defvars for those three variables
(setq gnus-user-date-format-day "%k:%M")
(setq gnus-user-date-format-week "%a %k:%M")
(setq gnus-user-date-format-old "%d.%m.")

(defun gnus-user-date (messy-date)
  "Format the messy-date acording to gnus-user-date-format-*"
  (condition-case ()
      (progn
	(setq messy-date (safe-date-to-time messy-date))
	(setq now (current-time))
	(setq differenz (+ (lsh (- (car now) (car messy-date)) 16)
			   (- (car (cdr now)) (car (cdr messy-date)))))
	(setq now (decode-time now))
	(setq my-format gnus-user-date-format-old)
	(if (> (- (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)) differenz) -1)
	    ;;today
	    (setq my-format gnus-user-date-format-day)
	  (if (< differenz 604801)
	      ;;this week
	      (setq my-format gnus-user-date-format-week)))
	(format-time-string (eval my-format) messy-date))
    (error "  -   ")))

-- 
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them
In the Land of Mordor where the Shadows lie.
19. Dezember 2001



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2002-01-03 12:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-14 22:03 [Code] New date-format for summary-line Frank Schmitt
2001-10-15 10:55 ` Frank Schmitt
2001-10-15 12:37   ` Kai Großjohann
2001-10-15 13:50     ` Frank Schmitt
2001-10-15 14:54       ` Kai Großjohann
2001-12-30  0:33         ` Lars Magne Ingebrigtsen
2002-01-02 11:23           ` Kai Großjohann
2002-01-02 11:38             ` Lars Magne Ingebrigtsen
2002-01-03 12:44               ` Per Abrahamsen

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).