stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r620043 - /stdcxx/trunk/bin/duration
Date Fri, 08 Feb 2008 23:51:37 GMT
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  <sebor@roguewave.com>

	* 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
 
 



Mime
View raw message