#!/bin/ksh # I think that Liam Crilly wrote this, also a Uni of Herts student # and ICL staffer at the same time as I was. We were both writing # scripts to give the rough time of day, same as a human would. # Being in ksh, I guess it's more likely Liam's. mins=`date +%M` hours=`date +%H` echo -n "Hours : " read hours echo -n "Mins. : " read mins TheDiv=`expr $mins / 5` TheRem=`expr $mins % 5` case $TheRem in 1|2) roughly='It has just gone ' ;; 3|4) roughly='It is nearly ' TheDiv=`expr $TheDiv + 1` ;; *) roughly='It is exactly ' ;; esac mins=`expr 5 \* $TheDiv` if [ $mins -eq 60 ] then mins=0 fi if [ $mins -ge 31 ] then mins=`expr 60 - $mins` hours=`expr $hours + 1` nearest=' to ' elif [ $mins -ne 0 ] then nearest=' past ' fi if [ $hours -ge 13 ] then hours=`expr $hours - 12` ampm='in the afternoon' elif [ $hours -eq 12 ] then ampm='midday' else ampm='in the morning' fi case "$mins" in "0") mins='' ;; "5") mins='five minutes' ;; "10") mins='ten minutes' ;; "15") mins='a quarter' ;; "20") mins='twenty minutes' ;; "25") mins='twenty five minutes' ;; "30") mins=half ;; esac case $hours in 1) hours='one' ;; 2) hours='two' ;; 3) hours='three' ;; 4) hours='four' ;; 5) hours='five' ;; 6) hours='six' ;; 7) hours='seven' ;; 8) hours='eight' ;; 9) hours='nine' ;; 10) hours='ten' ;; 11) hours='eleven' ;; 12) hours='twelve' ;; esac if [ "$mins" -eq "" ] then hours=`echo "$hours o'clock"` fi echo "$roughly$mins$nearest$hours $ampm"