Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#!/bin/ksh
#
# chk_business_day.sh
#
# Returns the number of business day.
#
# Set up in your script as:
#
# if [ chk_business_day.sh -eq 5 ]
# then
# echo "It's the fifth business day of the month!"
# fi
#
# Requires ${LOC}_holidays.dat table as list of holidays:
# YYYYMMDD Holiday reason1
# YYYYMMDD Holiday reason2
# etc...
# Located at: $BASECFG/${LOC}_holidays.dat
# and $LOC = Country code
# ------------------------------------------------------------------------
# 5/16/02 MOrtizM Initial coding
# 8/20/02 MOrtizM Corrected the business-day calculation and
# changed to return the number of business days
# ------------------------------------------------------------------------
# 1 # Country code of holiday file
LOC=$(echo ${1:=US}|tr [:lower:] [:upper:])
#
# ------------------------------------------------------------------------
BASECFG=/oracle/local/tmp
CURDT=$(date +%Y%m%d)
today=$(date +%d)
YYYYMM=$(date +%Y%m)
DOW=$(date +%w)
if [ ! -f $BASECFG/${LOC}_holidays.dat ]
then
echo "# ${LOC}_holidays table as of `date`" > $BASECFG/${LOC}_holidays.dat
fi
# Return if Saturday or Sunday
if [[ $DOW -eq 0 || $DOW -eq 6 ]]
then
return 0
fi
# Return if Holiday
if test $(grep "^${CURDT}" $BASECFG/${LOC}_holidays.dat|wc -l) -gt 0
then
return 0
fi
bus_day=0
for dd in 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01
do
if test $dd -le $today
then
if [[ ! $DOW -eq 0 && ! $DOW -eq 6 ]]
then
if test $(grep "^${YYYYMM}$dd" $BASECFG/${LOC}_holidays.dat|wc -l) -eq 0
then
((bus_day += 1))
fi
fi
((DOW = DOW - 1))
if test $DOW -lt 0
then
DOW=6
fi
fi
done
return $bus_day