Changeset 18323


Ignore:
Timestamp:
08/31/15 01:42:26 (9 years ago)
Author:
Daniela Dorner
Message:
added check of certaindate-variable to getdate()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataCheck/Sourcefile.sh

    r18210 r18323  
    481481         ;;
    482482      # certain date
    483       [0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9])
    484          printprocesslog "DEBUG getdates case certain date: "$1
    485          dates=( $1 )
     483      [0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]|[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]-[0-9][0-9][0-9])
     484         d=`echo $1 | grep -o [0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]`
     485         range=`echo $1 | grep -o '[0-9][0-9][0-9]$'`
     486         range=`echo $range | sed -e 's/^0//' -e 's/^0//'`
     487         printprocesslog "DEBUG getdates - certain date "$d"."
     488         dates=( $d )
     489         if [ "$range" != "" ]
     490         then
     491            printprocesslog "DEBUG getdates - add the last "$range" days."
     492            yy=`echo $d | cut -c 1-4`
     493            mm=`echo $d | cut -c 6-7`
     494            dd=`echo $d | cut -c 9-10`
     495            for (( numdates=1 ; numdates <= $range ; numdates++ ))
     496            do
     497               numhours=`echo " 12 + ( $numdates - 1 ) * 24 " | bc -l`
     498               dates=( ${dates[@]} `date +%Y/%m/%d --date=$yy/$mm/$dd"-"$numhours"hour"` )
     499            done
     500         fi
    486501         ;;
    487       # certain number of dates (between 0 and 99 )
    488       [0-9][0-9]|[0-9]|[0-9][0-9][0-9])
     502      # certain number of dates (between 0 and 9999)
     503      [1-9][0-9][0-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9]|[1-9])
    489504         # get last n nights
     505         printprocesslog "DEBUG getdates - get the last "$1" days."
    490506         for (( numdates=1 ; numdates <= $1 ; numdates++ ))
    491507         do
     
    500516            if [ $hour -le $2 ] || [ $hour -ge $3 ]
    501517            then
     518               printprocesslog "DEBUG getdates - get the current night."
    502519               dates=( `date +%Y/%m/%d --date="-12hour"` )
    503520            fi
     
    505522         ;;
    506523      *) # nothing valid given
    507          echo "Please give valid options for the function 'getdates()'"
     524         echo "Please give valid option (YYYY/MM/DD[-RRR] or 1-9999)"
    508525         finish
    509526         ;;
Note: See TracChangeset for help on using the changeset viewer.