Gnus development mailing list
 help / color / mirror / Atom feed
* [patch] age depending date-format
@ 2001-10-16 19:42 Frank Schmitt
  2001-10-16 20:52 ` ShengHuo ZHU
                   ` (2 more replies)
  0 siblings, 3 replies; 36+ messages in thread
From: Frank Schmitt @ 2001-10-16 19:42 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

Hi

I did some more testing and error handling on my code I posted in  
<archive.pu7pc20r.fsf@hschmi22.userfqdn.rz-online.de>.

It should work without problems. What it does is the following:
Add a new item (%q) to gnus-summary-line-format-alist which calls
gnus-user-date(date-header).

gnus-user-date formats the date accordingly to 
gnus-user-date-day
gnus-user-date-week
gnus-user-date-old

That means that if the message is of today you get e.g. 10:24
if not older than 7 days you Mon 12:35
and if it's older you Okt 16

gnus-user-* can hold any valid value for format-time-string.

here are the patches:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch against gnus-sum.el --]
[-- Type: text/x-patch, Size: 553 bytes --]

--- gnus-sum.el	Fri Oct  5 19:44:50 2001
+++ gnus-sum2.el	Tue Oct 16 19:23:34 2001
@@ -1055,6 +1055,7 @@
     (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
     (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
     (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
+    (?q (gnus-user-date (mail-header-date gnus-tmp-header)) ?s)
     (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
     (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
     (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Patch against gnus-util.el --]
[-- Type: text/x-patch, Size: 1985 bytes --]

--- 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 <ich@Frank-Schmitt.net>. 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 ()


[-- Attachment #4: Type: text/plain, Size: 0 bytes --]



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

end of thread, other threads:[~2001-10-19 17:11 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-16 19:42 [patch] age depending date-format Frank Schmitt
2001-10-16 20:52 ` ShengHuo ZHU
2001-10-17  7:16   ` Frank Schmitt
2001-10-17 16:09     ` ShengHuo ZHU
2001-10-17 16:34       ` Frank Schmitt
2001-10-17 11:50   ` Kai Großjohann
2001-10-17 13:59     ` ShengHuo ZHU
2001-10-17 14:08       ` Didier Verna
2001-10-17 14:11         ` Colin Marquardt
2001-10-17 14:36           ` Didier Verna
2001-10-17 15:05         ` Kai Großjohann
2001-10-17 15:33           ` Didier Verna
2001-10-17 15:30         ` Paul Jarc
2001-10-17 15:41           ` Didier Verna
2001-10-17 16:14           ` Per Abrahamsen
2001-10-17 16:19             ` Paul Jarc
2001-10-17 16:37               ` Simon Josefsson
2001-10-17 16:52               ` Kai Großjohann
2001-10-17 17:03                 ` Paul Jarc
2001-10-17 18:11                   ` Per Abrahamsen
2001-10-17 18:08               ` Per Abrahamsen
2001-10-17 16:20           ` Amos Gouaux
2001-10-17 16:51           ` Kai Großjohann
2001-10-18  6:44             ` Yair Friedman (Jerusalem)
2001-10-17 15:09       ` Per Abrahamsen
2001-10-17 15:15       ` Per Abrahamsen
2001-10-17 15:19         ` Kai Großjohann
2001-10-17 16:04           ` ShengHuo ZHU
2001-10-17 20:35   ` Update of gnus-user-date (was: [patch] age depending date-format) Frank Schmitt
2001-10-17 21:34     ` ShengHuo ZHU
2001-10-18  7:53       ` Update of gnus-user-date Frank Schmitt
2001-10-18 10:08         ` Kai Großjohann
2001-10-19 17:11     ` Update of gnus-user-date (was: [patch] age depending date-format) Wes Hardaker
2001-10-17 10:51 ` [patch] age depending date-format Frank Schmitt
2001-10-17 15:05 ` Yair Friedman (Jerusalem)
2001-10-17 16:09   ` Frank Schmitt

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