help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parsing a date


From: Eric Abrahamsen
Subject: Re: parsing a date
Date: Mon, 24 Dec 2012 11:02:12 +0800
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2 (gnu/linux)

ken <gebser@mousecar.com> writes:

> On 12/23/2012 12:55 AM Eric Abrahamsen wrote:
>> (format-time-string "%Y/%m/%d"
>>>     (apply 'encode-time 0 0 0
>>>       (nthcdr 3 (parse-time-string "2011-11-15"))))
>
> Nice.  I was wanting to do something very close to this awhile back.
> Of course the above code is more useful in the context of a function,
> something like the below-- which has something missing.  What?
>
> (setq ddd "2013-02-11.tail")  ;Want to remove tail on string also
>
> (defun ddd
> (format-time-string "%A, %B %d, %Y"
>    (apply 'encode-time 0 0 0
>         (nthcdr 3 (parse-time-string ddd)))))

I suppose this?

--8<---------------cut here---------------start------------->8---
(defun ddd (s)
  (format-time-string "%Y/%m/%d"
    (apply 'encode-time 0 0 0
      (nthcdr 3 (parse-time-string
                 (replace-regexp-in-string "\.tail" "" s))))))
--8<---------------cut here---------------end--------------->8---




reply via email to

[Prev in Thread] Current Thread [Next in Thread]