From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: what function to use to normalize date to org format? Date: Fri, 11 Apr 2014 11:20:23 +0200 Message-ID: <87sipk3srz.fsf@bzg.ath.cx> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYbPn-00050C-7H for emacs-orgmode@gnu.org; Fri, 11 Apr 2014 09:22:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYbPZ-0007sm-I3 for emacs-orgmode@gnu.org; Fri, 11 Apr 2014 09:22:43 -0400 Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:46608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYbPZ-0007s8-1U for emacs-orgmode@gnu.org; Fri, 11 Apr 2014 09:22:29 -0400 Received: by mail-wi0-f179.google.com with SMTP id z2so993597wiv.6 for ; Fri, 11 Apr 2014 06:22:27 -0700 (PDT) In-Reply-To: (Mirko's message of "Thu, 27 Mar 2014 13:32:14 +0000 (UTC)") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Mirko Cc: emacs-orgmode@gnu.org Hi Mirko, Mirko 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