My problem is that i want to calculate the day of the week, i want to change result given as a number for the day.
I mean, the program now do that if the day is Monday is represented by 0, Tuesday by 1.. but i want the word "Monday" as a result. I thought in a bucle if but there is always a mistake and i dont know why.
Thank you
#!/bin/sh
# ja fe ma ap ma ju ju ag se oc no de
set -A lasts 0 31 28 31 30 31 30 31 31 30 31 30 31
day=$1
month=$2
year=$3
#
# Get Day of Week of Jan 1
dow1=$(cal 1 $year | sed -n '3s/. //gp')
((dow1=7-dow1))
#
# It is a Leap Year?
leap=0
if ((!(year%100))); then
((!(year%400))) && leap=1
else
((!(year%4))) && leap=1
fi
#
# Set number of days of Februray
lasts[2]=28
((leap)) && lasts[2]=29
#
# calculate day of year
i=0
previous=0
while ((i < mes)) ; do
((previous=previous+lasts))
((i=i+1))
done
((doy=previous+dia))
#
# Calculate day of week
((dow = (doy+dow1-1)%7 ))
#echo dow = $dow
echo diadelasemana=$dow
if [$dow -eq 0] then
echo -"Monday"
else
echo "..the same but with Tuesday...etc"
fi
exit 0