From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "WJ" Newsgroups: gmane.emacs.help Subject: Re: parsing a date Date: 2 Dec 2012 07:25:28 GMT Organization: NewsGuy - Unlimited Usenet $19.95 Message-ID: References: NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1354433417 4921 80.91.229.3 (2 Dec 2012 07:30:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Dec 2012 07:30:17 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Dec 02 08:30:30 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tf40P-0007z9-Vo for geh-help-gnu-emacs@m.gmane.org; Sun, 02 Dec 2012 08:30:26 +0100 Original-Received: from localhost ([::1]:43290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tf40E-00020Q-1a for geh-help-gnu-emacs@m.gmane.org; Sun, 02 Dec 2012 02:30:14 -0500 Original-Path: usenet.stanford.edu!news.glorb.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!spln!extra.newsguy.com!newsp.newsguy.com!enews4 Original-Newsgroups: gnu.emacs.help Original-Lines: 24 Original-NNTP-Posting-Host: p12b43bd503e1dc4aae1d15532e4f7e8061c402209274aa78fe0ccf3b27edc165.newsdawg.com User-Agent: XanaNews/1.18.1.6 X-Antivirus: avast! (VPS 121201-0, 12/01/2012), Outbound message X-Antivirus-Status: Clean X-Received-Bytes: 1468 Original-Xref: usenet.stanford.edu gnu.emacs.help:195695 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:88016 Archived-At: Eric Abrahamsen wrote: > I'm reading in files with dates in this format: "2011-11-25". I need to > write them out as "2011/11/25". Instead of just manhandling the strings > (I'll likely need this date information in other places) I wanted to > parse the strings into proper date objects, then format them back into > strings. `date-to-time' doesn't work because (parse-time-string > "2011-11-15") gives me: > > (nil nil nil 15 11 2011 nil nil nil) > > Which is not acceptable to `encode-time', because it requires integers, > not nil. I can't believe this is quite this complicated: do I really > have to replace all the nils with 0 myself? > > Any pointers gratefully accepted, > > Eric (format-time-string "%Y/%m/%d" (apply 'encode-time 0 0 0 (nthcdr 3 (parse-time-string "2011-11-15")))) ==> "2011/11/15"