i would need some help in setting the value of a variable (TIME_NOW) depending on the time of the day ...e.g.
if today's date is 12th April 2009 and if the current time is between midnight [00:00:00] and 16:59:59 hrs then the TIME_NOW should be yesterday's date i.e. TIME_NOW=11
else if the current time between 17:00:00 [hh mm ss] hrs and midnight [00:00:00] .... then the TIME_NOW should be set to today's date i.e. TIME_NOW=12
i tried the following logic
calculate_time_now ()
{
typeset -i Date=$(date +%H)
if (( $Date >= 17 ))
then
time_now=$(date +%d)
else
time_now=$(TZ=PST+24 date +%d)
fi
echo $time_now
}
but at some time around midgnight ... it is not working [at 0038 hrs on 11th april 2009 ... it calculated time_now as 10 {instead of 11}].
Please advise.