function weekof()
{
local week=$1 year=$2
local week_num_of_Mon_1 week_day_of_Mon_1
local first_Mon
local date_fmt="+%a %b %d %Y"
local mon sun
week_num_of_Mon_1=$(date -d $year-01-01 +%W)
week_day_of_Mon_1=$(date -d $year-01-01 +%u)
if ((week_num_of_Mon_1)); then
first_Mon=$year-01-01
else
first_Mon=$year-01-$((01 + (7 - week_day_of_Mon_1 + 1) ))
fi
mon=$(date -d "$first_Mon +$((week - 1)) week" "$date_fmt")
sun=$(date -d "$first_Mon +$((week - 1)) week + 6 day" "$date_fmt")
# echo "\"$mon\" - \"$sun\""
echo -e "\n\nFor week no: ${week}"
echo -e "\t""\"$mon\" - \"$sun\""
echo -e "\n\n"
}
weekof $1 $2
#
# Run as bash sed_dt_test.bsh 32 2013
#
No comments:
Post a Comment