--- gnus-util.el Sun Oct 7 13:49:04 2001 +++ gnus-util2.el Tue Oct 16 18:57:50 2001 @@ -299,6 +299,43 @@ (yes-or-no-p prompt) (message ""))) +;; By Frank Schmitt . Allows to have age-depending +;; date representations. (e.g. just the time when it's from today, the day +;; of the week if it's within the last 7 days and the full date if it's older) +(defvar gnus-user-date-format-day "%k:%M" + "Format used to display todays dates. +See documentation of format-time-string for valid values") +(defvar gnus-user-date-format-week "%a %k:%M" + "Format used to display dates not older than one week. +See documentation of format-time-string for valid values") +(defvar gnus-user-date-format-old "%d.%m." + "Format used to display dates older than one week. +See documentation of format-time-string for valid values") + +(defun gnus-user-date (messy-date) + "Format the messy-date acording to gnus-user-date-format-*. +Returns \" ? \" if there's bad input or if an other error occurs. +Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"." + (condition-case () + (progn + (setq messy-date (safe-date-to-time messy-date)) + (setq now (current-time)) + (setq my-format gnus-user-date-format-old) + (setq high (lsh (- (car now) (car messy-date)) 16)) + (if (= (logand high 65535) 0) ;;if nil then we've got an overflow + (progn + (setq difference (+ high (- (car (cdr now)) (car (cdr messy-date))))) + (setq now (decode-time now)) + (if (> (- (+ (car now) (* (car (cdr now)) 60) (* (car (nthcdr 2 now)) 3600)) differenz) -1) + ;;today + (setq my-format gnus-user-date-format-day) + (if (< difference 604801) + ;;this week + (setq my-format gnus-user-date-format-week))))) + (format-time-string (eval my-format) messy-date)) + (error " ? "))) +;;end of Frank's code + (defun gnus-dd-mmm (messy-date) "Return a string like DD-MMM from a big messy string." (condition-case ()