2a46f8c53b9891692305f70adfcdb6f8c3b7297c kuhn Thu Sep 9 08:29:37 2010 -0700 fixed a small bug diff --git src/utils/qa/getLastMonth.csh src/utils/qa/getLastMonth.csh index 7526c99..108894f 100755 --- src/utils/qa/getLastMonth.csh +++ src/utils/qa/getLastMonth.csh @@ -1,63 +1,67 @@ #!/bin/tcsh source `which qaConfig.csh` ####################### # # 10-08-07 # gets year and month of last month # # Robert Kuhn # ####################### set year="" set month="" set yearMonth="" set lastMonth="" if ( $#argv != 1 ) then echo - echo " gets year and month of last month." + echo " gets year and month of last/prev month." echo echo " usage: go | YYYY-MM" echo exit 1 else if ( $argv[1] == "go" ) then set year=`date +%Y` set month=`date +%m` set yearMonth=`date +%Y-%m` else set yearMonth=$argv[1] set year=`echo $yearMonth | awk -F- '{print $1}'` set month=`echo $yearMonth | awk -F- '{print $2}'` endif endif -if ( $month > 12 ) then +# for some reason, 08 and 09 make the if statement barf, so drop zero +set month=`echo $month | sed "s/^0//"` +# echo "month = $month" + +if ( $month > 12 || $month < 1 ) then echo "\n error. month out of range.\n" exit 1 endif # echo "year = $year" # echo "month = $month" # echo "yearMonth = $yearMonth" # find last month set lastMonth=`echo $month | awk '{print $1-1}'` if ( $lastMonth == 0 ) then set lastMonth=12 set year=`echo $year | awk '{print $1-1}'` endif if ( $lastMonth < 10 ) then set lastMonth='0'$lastMonth endif # echo "year = $year" # echo "lastMonth = $lastMonth" echo $year-$lastMonth exit