From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14659 invoked from network); 9 Oct 2003 17:28:39 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 9 Oct 2003 17:28:39 -0000 Received: (qmail 25779 invoked by alias); 9 Oct 2003 17:27:58 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6673 Received: (qmail 25734 invoked from network); 9 Oct 2003 17:27:56 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 9 Oct 2003 17:27:56 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [4.3.58.249] by sunsite.dk (MessageWall 1.0.8) with SMTP; 9 Oct 2003 17:27:56 -0000 Received: (from schaefer@localhost) by candle.brasslantern.com (8.11.6/8.11.6) id h99HRsW10492 for zsh-users@sunsite.dk; Thu, 9 Oct 2003 10:27:54 -0700 From: Bart Schaefer Message-Id: <1031009172754.ZM10491@candle.brasslantern.com> Date: Thu, 9 Oct 2003 17:27:54 +0000 X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-users@sunsite.dk Subject: Useful zsh/datetime things MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In the latest 4.1.1 dev version from CVS, we have the zsh/datetime module, which defines a strftime builtin and the EPOCHSECONDS variable. Here are a couple of simple helper functions that make use of these: function ctime { # Print the current or argument time in standard format local time=${1:-$EPOCHSECONDS} strftime "%a %b %e %H:%M:%S %Y" $time } function starttime { # Print the time this shell was started # (doesn't work if SECONDS has been reset) typeset -i SECONDS=$SECONDS # No floating point ctime $((EPOCHSECONDS - SECONDS)) } function rfcdate { # Like GNU "date -R" strftime "%a, %e %b %Y %H:%M:%S %z" $EPOCHSECONDS } A useful addition to strftime would be an option to assign the result to a parameter, similar to the -A and -H options of "stat" (from zsh/stat). -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net