From commits-return-2402-apmail-stdcxx-commits-archive=stdcxx.apache.org@stdcxx.apache.org Fri Feb 08 23:51:59 2008 Return-Path: Delivered-To: apmail-stdcxx-commits-archive@www.apache.org Received: (qmail 19186 invoked from network); 8 Feb 2008 23:51:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Feb 2008 23:51:59 -0000 Received: (qmail 44370 invoked by uid 500); 8 Feb 2008 23:51:52 -0000 Delivered-To: apmail-stdcxx-commits-archive@stdcxx.apache.org Received: (qmail 44359 invoked by uid 500); 8 Feb 2008 23:51:52 -0000 Mailing-List: contact commits-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list commits@stdcxx.apache.org Received: (qmail 44350 invoked by uid 99); 8 Feb 2008 23:51:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2008 15:51:52 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2008 23:51:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id EE30A1A9832; Fri, 8 Feb 2008 15:51:37 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r620043 - /stdcxx/trunk/bin/duration Date: Fri, 08 Feb 2008 23:51:37 -0000 To: commits@stdcxx.apache.org From: sebor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080208235137.EE30A1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sebor Date: Fri Feb 8 15:51:33 2008 New Revision: 620043 URL: http://svn.apache.org/viewvc?rev=620043&view=rev Log: 2008-02-08 Martin Sebor * bin/duration (get): Unset a local variable before testing it so as to prevent the value set in first call to affect the subsequent calls. Added the special value "now" as a shortcut for the current date and time. Modified: stdcxx/trunk/bin/duration Modified: stdcxx/trunk/bin/duration URL: http://svn.apache.org/viewvc/stdcxx/trunk/bin/duration?rev=620043&r1=620042&r2=620043&view=diff ============================================================================== --- stdcxx/trunk/bin/duration (original) +++ stdcxx/trunk/bin/duration Fri Feb 8 15:51:33 2008 @@ -20,7 +20,7 @@ # implied. See the License for the specific language governing # permissions and limitations under the License. # -# Copyright 2007 Rogue Wave Software, Inc. +# Copyright 2007-2008 Rogue Wave Software, Inc. # ######################################################################## # @@ -28,7 +28,7 @@ # duration - Write the amount of time between two dates. # # SYNOPSIS -# duration [ option(s)... ] [ date-1 [ date-2 ]] +# duration [ option(s)... ] [ from-date [ to-date ]] # # DESCRIPTION # The duration utility computes the amount of time elapsed between @@ -105,6 +105,7 @@ # compute the one-based month number n=0 + unset date_nummon for m in Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec; do if [ -z $date_nummon ]; then n=$((n+1)) @@ -401,10 +402,15 @@ # remove command line options and their arguments from the command line shift $(($OPTIND - 1)) + +#use below +current_date="`LC_ALL=C date`" + + if [ $# -ge 1 ]; then start=$1 else - start="`LC_ALL=C date`" + start=$current_date fi if [ $# -ge 2 ]; then @@ -414,6 +420,14 @@ # by default display the offset from the Epoch start="Thu Jan 1 00:00:00 UTC 1970" +fi + +if [ "$start" = "now" ]; then + start=$current_date +fi + +if [ "$end" = "now" ]; then + end=$current_date fi