From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28592 invoked from network); 22 Oct 2003 15:32:28 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 22 Oct 2003 15:32:28 -0000 Received: (qmail 16309 invoked by alias); 22 Oct 2003 15:31:55 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6730 Received: (qmail 16276 invoked from network); 22 Oct 2003 15:31:54 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 22 Oct 2003 15:31:54 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.3.58.249] by sunsite.dk (MessageWall 1.0.8) with SMTP; 22 Oct 2003 15:31:53 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id h9MFVqI05275 for zsh-users@sunsite.dk; Wed, 22 Oct 2003 08:31:52 -0700 From: Bart Schaefer Message-Id: <1031022153151.ZM5274@candle.brasslantern.com> Date: Wed, 22 Oct 2003 15:31:51 +0000 In-Reply-To: <1031009172754.ZM10491@candle.brasslantern.com> Comments: In reply to Bart Schaefer "Useful zsh/datetime things" (Oct 9, 5:27pm) References: <1031009172754.ZM10491@candle.brasslantern.com> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-users@sunsite.dk Subject: Re: Useful zsh/datetime things MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 9, 5:27pm, Bart Schaefer wrote: } } function rfcdate { } # Like GNU "date -R" } strftime "%a, %e %b %Y %H:%M:%S %z" $EPOCHSECONDS } } As this doesn't work without a version of strftime that supports the nonstandard "%z", here's a replacement: function rfcdate { # As much like GNU "date -R" as possible if [[ ${(%):-"%D{%z}"} == [-+]<-> ]] then strftime "%a, %e %b %Y %H:%M:%S %z" $EPOCHSECONDS else strftime "%a, %e %b %Y %H:%M:%S %Z" $EPOCHSECONDS fi } The quotes around "%D{%z}" are necessary lest zsh interpret the first closing brace as the end of the parameter substitution (leaving a stray second closing brace which becomes part of the comparison). This does not seem to be the behavior of other shells -- e.g., bash balances all nested braces.