yourzip="97205" # set this to your local zip code
request="http://www.almanac.com/astronomy/rise/zipcode"
thedate="$(date +%Y-%m-%d)"
url="$request/$yourzip/$thedate"
raw=$(curl --silent "$url" | grep rise_nextprev | cut -d\< -f35-40)
sunrise=$( echo $raw | cut -d" " -f3)
sunset=$( echo $raw | cut -d" " -f6)
srh=$(echo $sunrise | cut -d: -f1)
srm=$(echo $sunrise | cut -d: -f2)
ssh=$(echo $sunset | cut -d: -f1)
ssh=$(( $(echo $sunset | cut -d: -f1) + 12 ))
ssm=$(echo $sunset | cut -d: -f2)
echo "$sunrise sunrise"
echo "$ssh sunset hour"
## what's the hour now
hour=$(date +%H)
min=$(date +%m)
echo "$hour now"
if [ $hour -eq $srh -a $min -ge $srm ] ; then
echo "sunrise hour"
fi
if [ $hour -gt $srh -a $hour -lt $ssh ] ; then
echo "daytime"
fi
if [ $hour -eq $ssh -a $min -le $ssm ] ; then
echo "sunset hour"
fi
if [ $hour -gt $ssh ] ; then
echo "nighttime"
No comments:
Post a Comment