From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.user Subject: Re: Help formatting a UTC Timestamp Date: Tue, 14 Feb 2017 13:11:07 +0000 Message-ID: <20170214131107.7cd4c42b@bother.homenet> References: <20170214122716.GA2454@debian> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: blaine.gmane.org 1487077902 12898 195.159.176.226 (14 Feb 2017 13:11:42 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 14 Feb 2017 13:11:42 +0000 (UTC) Cc: guile-user@gnu.org To: Guy Baumann Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Feb 14 14:11:38 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cdctL-0002vm-2k for guile-user@m.gmane.org; Tue, 14 Feb 2017 14:11:35 +0100 Original-Received: from localhost ([::1]:34774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdctQ-0008NA-Q8 for guile-user@m.gmane.org; Tue, 14 Feb 2017 08:11:40 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdct4-0008N2-1A for guile-user@gnu.org; Tue, 14 Feb 2017 08:11:19 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdct0-0002Il-QL for guile-user@gnu.org; Tue, 14 Feb 2017 08:11:17 -0500 Original-Received: from smtpout2.wanadoo.co.uk ([80.12.242.42]:20803 helo=smtpout.wanadoo.co.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdct0-0002Ga-Ef for guile-user@gnu.org; Tue, 14 Feb 2017 08:11:14 -0500 Original-Received: from bother.homenet ([2.27.184.146]) by mwinf5d18 with ME id kdB71u00L39w0rE03dB7rh; Tue, 14 Feb 2017 14:11:11 +0100 X-ME-Helo: bother.homenet X-ME-Date: Tue, 14 Feb 2017 14:11:11 +0100 X-ME-IP: 2.27.184.146 Original-Received: from bother.homenet (localhost [IPv6:::1]) by bother.homenet (Postfix) with ESMTP id 61CC2120CE7; Tue, 14 Feb 2017 13:11:07 +0000 (GMT) In-Reply-To: <20170214122716.GA2454@debian> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 80.12.242.42 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:13195 Archived-At: On Tue, 14 Feb 2017 12:27:16 +0000 Guy Baumann wrote: > I am trying to format a timestamp from an api. It is sent in the > format "2011-03-24T20:30:47Z" > > what I want to output is something like this > (strftime "%d %b %g " (localtime (current-time)) ) > > However I am unable to work out how to do this, have tried using > string->date with results below > > Enter `,help' for help. > scheme@(guile-user)> (define date "2011-03-24T20:30:47Z") > scheme@(guile-user)> (use-modules (srfi srfi-19)) > scheme@(guile-user)> (string->date "~Y-m-dT~H:~M:SZ" date) > srfi/srfi-19.scm:1415:18: In procedure priv:string->date: > srfi/srfi-19.scm:1415:18: In procedure string->date: TIME-ERROR type > bad-date-format-string: "2011-03-24T20:30:47Z" > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > scheme@(guile-user) [1]> (string->date date "~Y-m-dT~H:~M:SZ") > srfi/srfi-19.scm:1415:18: In procedure priv:string->date: > srfi/srfi-19.scm:1415:18: In procedure string->date: TIME-ERROR type > bad-date-format-string: "~Y-m-dT~H:~M:SZ" > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > scheme@(guile-user) [2]> (string->date date "~Y-m-dT~H:~M:SZ") > srfi/srfi-19.scm:1415:18: In procedure priv:string->date: > srfi/srfi-19.scm:1415:18: In procedure string->date: TIME-ERROR type > bad-date-format-string: "~Y-m-dT~H:~M:SZ" > > Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue. > scheme@(guile-user) [3]> (string->date "2000" "~Y") > srfi/srfi-19.scm:571:22: In procedure encode-julian-day-number: > srfi/srfi-19.scm:571:22: In procedure -: Wrong type: #f You haven't got the escapes quite right. This will work: (string->date date "~Y-~m-~dT~H:~M:~SZ") As will this with skipping, given that your example uses numeric values: (string->date date "~Y~m~dT~H~M~SZ") Chris