From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/39316 Path: main.gmane.org!not-for-mail From: Frank Schmitt Newsgroups: gmane.emacs.gnus.general Subject: [patch] age depending date-format Date: Tue, 16 Oct 2001 21:42:57 +0200 Organization: Hamme net, kren mer och nimmi Sender: owner-ding@hpc.uh.edu Message-ID: Reply-To: NNTP-Posting-Host: coloc-standby.netfonds.no Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: main.gmane.org 1035175042 27237 80.91.224.250 (21 Oct 2002 04:37:22 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 21 Oct 2002 04:37:22 +0000 (UTC) Return-Path: Original-Received: (qmail 20252 invoked from network); 16 Oct 2001 19:43:30 -0000 Original-Received: from malifon.math.uh.edu (mail@129.7.128.13) by mastaler.com with SMTP; 16 Oct 2001 19:43:30 -0000 Original-Received: from sina.hpc.uh.edu ([129.7.128.10] ident=lists) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 15ta64-0002Ag-00; Tue, 16 Oct 2001 14:41:52 -0500 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Tue, 16 Oct 2001 14:41:30 -0500 (CDT) Original-Received: from sclp3.sclp.com (qmailr@sclp3.sclp.com [209.196.61.66]) by sina.hpc.uh.edu (8.9.3/8.9.3) with SMTP id OAA28269 for ; Tue, 16 Oct 2001 14:41:12 -0500 (CDT) Original-Received: (qmail 20196 invoked by alias); 16 Oct 2001 19:41:27 -0000 Original-Received: (qmail 20191 invoked from network); 16 Oct 2001 19:41:27 -0000 Original-Received: from quimby.gnus.org (195.204.10.139) by gnus.org with SMTP; 16 Oct 2001 19:41:27 -0000 Original-Received: (from news@localhost) by quimby.gnus.org (8.9.3/8.9.3) id VAA27435 for ding@gnus.org; Tue, 16 Oct 2001 21:41:24 +0200 (CEST) Original-To: ding@gnus.org Original-Path: not-for-mail Original-Newsgroups: gnus.ding Original-Lines: 106 Original-NNTP-Posting-Host: pppin103.max-hochsimmer.rz-online.net Original-X-Trace: quimby.gnus.org 1003261284 21237 212.7.169.103 (16 Oct 2001 19:41:24 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: 16 Oct 2001 19:41:24 GMT User-Agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.4 (Academic Rigor) Hamster/1.3.23.0 X-Face: "?Hv7MyYveeGDm66,O\f[l6!L*,`Q)c&3'8{9UGIM`EO8<3ASfX`8}W+u;F},&V%/y+cz(z&spQ(`CkKzCJY/@0R]aM#[W7*$(,QA-oO0f}Z2S0Y0~b5}|XDhQds[9}=t$Hf%G2c;zR%;$"~eI+dw3Gy!xKw=oduK(-, Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:39316 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:39316 --=-=-= Hi I did some more testing and error handling on my code I posted in . 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: --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=gnus-sum.diff Content-Description: Patch against gnus-sum.el --- 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) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=gnus-util.diff Content-Description: Patch against gnus-util.el --- 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 () --=-=-= -- 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 --=-=-=--