Gnus development mailing list
 help / color / mirror / Atom feed
From: lawrence mitchell <0198183+ding@sms.ed.ac.uk>
Subject: Re: ISO date in attribution line
Date: Sun, 09 Jun 2002 21:22:46 +0100	[thread overview]
Message-ID: <uadq46w2x.fsf@ID-97657.usr.dfncis.de> (raw)
In-Reply-To: <vafk7p8nsv7.fsf@INBOX.auto.gnus.tok.lucy.cs.uni-dortmund.de> (Kai.Grossjohann@CS.Uni-Dortmund.DE's message of "Sun, 09 Jun 2002 21:40:12 +0200")

Kai Grossjohann wrote:
> Andreas Fuchs <asf@void.at> 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>




  reply	other threads:[~2002-06-09 20:22 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-24 15:59 The followup will show the bug Kai Großjohann
2002-05-24 21:45 ` Reiner Steib
2002-05-25 17:22   ` Kai Großjohann
2002-05-25 17:49     ` Oystein Viggen
2002-05-27 13:47       ` Christopher Splinter
2002-05-27 14:40         ` Kai Großjohann
2002-05-27 15:32           ` Oystein Viggen
2002-05-27 19:07             ` Paul Jarc
2002-05-28 11:06               ` Christopher Splinter
2002-05-28  6:30           ` Niklas Morberg
2002-05-28  7:30             ` he " Marco Lonsing
2002-05-28  7:38             ` The " David Kågedal
2002-05-28  7:38             ` David Kågedal
2002-05-28  9:21             ` Kai Großjohann
2002-05-29  9:33               ` Niklas Morberg
     [not found]             ` <u5tptzg90xj.fsf@leeloo.hq.vtech>
2002-05-28  8:12               ` Ronan Waide
2002-05-28 22:24               ` Alex Schroeder
2002-05-28 11:03           ` Christopher Splinter
2002-05-27 17:59     ` Jesper Harder
2002-05-28 13:01       ` Kai Großjohann
2002-05-28 13:31       ` Kai Großjohann
2002-05-28 13:31         ` Kai Großjohann
2002-05-28 16:36           ` Jesper Harder
2002-05-29  7:38             ` Kai Großjohann
2002-05-29 18:26               ` Johann Gambolputty de von ausfern schplenden schlitter...von Hautkopft of Ulm
2002-05-29 20:11                 ` Jesper Harder
2002-05-30  9:57                   ` Kai Großjohann
2002-05-30 10:01                     ` Kai Großjohann
2002-05-30  9:56                 ` Kai Großjohann
2002-05-28 17:36         ` Christopher Splinter
2002-05-25 20:28 ` Andreas Fuchs
2002-06-09 18:04   ` ISO date in attribution line (Was: Re: The followup will show the bug.) Svend Tollak Munkejord
2002-06-09 18:35     ` ISO date in attribution line Andreas Fuchs
2002-06-09 19:40       ` Kai Großjohann
2002-06-09 20:22         ` lawrence mitchell [this message]
2002-06-10  9:36           ` Kai Großjohann
2002-06-10 17:16             ` Andreas Fuchs
2002-06-11 10:51               ` Kai Großjohann
2002-06-09 20:40         ` Andreas Fuchs
2002-06-09 20:59       ` Svend Tollak Munkejord

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=uadq46w2x.fsf@ID-97657.usr.dfncis.de \
    --to=0198183+ding@sms.ed.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).