[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] what function to use to normalize date to org format?
From: |
Bastien |
Subject: |
Re: [O] what function to use to normalize date to org format? |
Date: |
Fri, 11 Apr 2014 11:20:23 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) |
Hi Mirko,
Mirko <address@hidden> writes:
> Is there a public function that can accept a string such as "3/4/5" (US
> Format) and normalize it to [2005-03-04 Fri]?.
Here you go:
(defun mirko-timestamp-conversion (date-string)
(when (string-match "\\([0-9]+\\)/\\([0-9]+\\)/\\([0-9]+\\)" date-string)
(let* ((time
(list 0 0 0
(string-to-number (match-string 2 date-string))
(string-to-number (match-string 1 date-string))
(+ (string-to-number (match-string 3 date-string)) 2000)))
(etime (apply 'encode-time time)))
(format-time-string "[%Y-%m-%d %a]" etime))))
(mirko-timestamp-conversion "3/4/5")
=> [2005-03-04 Fri.]
--
Bastien
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [O] what function to use to normalize date to org format?,
Bastien <=