From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/45176 Path: main.gmane.org!not-for-mail From: lawrence mitchell <0198183+ding@sms.ed.ac.uk> Newsgroups: gmane.emacs.gnus.general Subject: Re: ISO date in attribution line Date: Sun, 09 Jun 2002 21:22:46 +0100 Organization: me Sender: owner-ding@hpc.uh.edu Message-ID: References: NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1023654289 7687 127.0.0.1 (9 Jun 2002 20:24:49 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 9 Jun 2002 20:24:49 +0000 (UTC) Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 17H9F2-0001zs-00 for ; Sun, 09 Jun 2002 22:24:48 +0200 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 17H9EG-0007mK-00; Sun, 09 Jun 2002 15:24:00 -0500 Original-Received: by sina.hpc.uh.edu (TLB v0.09a (1.20 tibbs 1996/10/09 22:03:07)); Sun, 09 Jun 2002 15:24:17 -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 PAA14699 for ; Sun, 9 Jun 2002 15:24:05 -0500 (CDT) Original-Received: (qmail 20821 invoked by alias); 9 Jun 2002 20:23:43 -0000 Original-Received: (qmail 20816 invoked from network); 9 Jun 2002 20:23:43 -0000 Original-Received: from grassmarket.ucs.ed.ac.uk (129.215.166.64) by gnus.org with SMTP; 9 Jun 2002 20:23:43 -0000 Original-Received: from FURRFU.resnet (19852584.resnet.ed.ac.uk [10.20.0.77]) by grassmarket.ucs.ed.ac.uk (8.11.6/8.11.6) with ESMTP id g59KNZo15593 for ; Sun, 9 Jun 2002 21:23:38 +0100 (BST) Original-To: ding@gnus.org X-No-Yes: No Mail-Copies-To: nobody Mail-Followup-To: ding@gnus.org In-Reply-To: (Kai.Grossjohann@CS.Uni-Dortmund.DE's message of "Sun, 09 Jun 2002 21:40:12 +0200") Original-Lines: 44 User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2 (i386-msvc-nt5.0.2195) Precedence: list X-Majordomo: 1.94.jlt7 Xref: main.gmane.org gmane.emacs.gnus.general:45176 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:45176 Kai Grossjohann wrote: > Andreas Fuchs writes: >> ,---- >> | (defun sc-jk-normalize-date (date) >> | "Extract the date (day month year) from an RFC 822 message >> | and write it as year-month-day (ISO 8601)" >> | (let ((date-list (cdr (cdr (cdr (parse-time-string date)))))) >> | (let ((day (pop date-list))) >> | (let ((month (pop date-list))) >> | (let ((year (car date-list))) >> | (and >> | year month day >> | (format "%d-%02d-%02d" year month day))))))) >> `---- > I get the feeling that doing format-time-string on the result > of parse-time-string would be enough. Anyone want to try this? > (defun sc-jk-normalize-date (date) > "..." > (let ((date (encode-time (parse-time-string date)))) > (format-time-string "..." date))) Elegant though it is, not quite, since encode-time doesn't like a list, it wants each argument separetely, at least it does in 21.2 and 20.4, which is odd, since the doc-string claims that it's the reverse of decode-time, which returns a list. Hmm, I wonder if this is a pseudo-bug. Im any case, you can manage without quite as many let bindings as Andreas used: (defun sc-jk-normalize-date (date) (let ((date-list (cdddr (parse-time-string date))) day month year) (setq day (pop date-list) month (pop date-list) year (car date-list)) (format "%d-%02d-%02d" year month day))) However, I'm not sure if this isn't slower. -- lawrence mitchell <0198183+ding@sms.ed.ac.uk>