* what function to use to normalize date to org format?
@ 2014-03-27 13:32 Mirko
2014-04-11 9:20 ` Bastien
0 siblings, 1 reply; 2+ messages in thread
From: Mirko @ 2014-03-27 13:32 UTC (permalink / raw)
To: emacs-orgmode
Hello,
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]?.
I need it for a bit of helper code.
Thanks,
Mirko
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: what function to use to normalize date to org format?
2014-03-27 13:32 what function to use to normalize date to org format? Mirko
@ 2014-04-11 9:20 ` Bastien
0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2014-04-11 9:20 UTC (permalink / raw)
To: Mirko; +Cc: emacs-orgmode
Hi Mirko,
Mirko <mirko.vukovic@gmail.com> 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-04-11 13:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-27 13:32 what function to use to normalize date to org format? Mirko
2014-04-11 9:20 ` Bastien
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).