From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: parsing a date Date: Sun, 23 Dec 2012 13:55:12 +0800 Message-ID: <87fw2xjosf.fsf@ericabrahamsen.net> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1356241874 2137 80.91.229.3 (23 Dec 2012 05:51:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 23 Dec 2012 05:51:14 +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 23 06:51: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 1TmeTA-000228-AE for geh-help-gnu-emacs@m.gmane.org; Sun, 23 Dec 2012 06:51:28 +0100 Original-Received: from localhost ([::1]:47922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TmeSw-0006gB-CH for geh-help-gnu-emacs@m.gmane.org; Sun, 23 Dec 2012 00:51:14 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TmeSl-0006fu-Ou for help-gnu-emacs@gnu.org; Sun, 23 Dec 2012 00:51:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TmeSf-0004iD-Hu for help-gnu-emacs@gnu.org; Sun, 23 Dec 2012 00:51:03 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:46041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TmeSf-0004hw-Bi for help-gnu-emacs@gnu.org; Sun, 23 Dec 2012 00:50:57 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TmeSp-0001g9-55 for help-gnu-emacs@gnu.org; Sun, 23 Dec 2012 06:51:07 +0100 Original-Received: from 114.252.250.200 ([114.252.250.200]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 23 Dec 2012 06:51:07 +0100 Original-Received: from eric by 114.252.250.200 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 23 Dec 2012 06:51:07 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 28 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 114.252.250.200 User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:+u3mThnMvRIe3Jy4AN9kzaSe8LQ= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:88297 Archived-At: "WJ" writes: > 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" Only just saw this -- thanks very much!