#!/bin/ksh -p # Shell script to show time in english rather than in computerese #set -x DF=$(dirname $0)/otime2.dat secs='' if [[ $1 == '-s' ]] ; then secs=$(( $( date '+%S' ) )) ; fi hour=$( date '+%H' ) mins=$( date '+%M' ) five=$(( mins % 5 )) tp="past" if (( $mins > 30 )) ; then mins=$(( 60 - mins )) hour=$(( hour + 1 )) tp="to" else mins=$((mins)) fi minsword=$( awk 'NR == '$mins $DF ) minsword=$( echo $minsword | sed 's/fifteen/a quarter/' | sed 's/thirty/half/' ) if (( $five != 0 )) ; then if (( $mins == 1 )) ; then minsword="$minsword minute" else minsword="$minsword minutes" fi fi while (( $hour > 12 )) ; do hour=$(( hour - 12 )) done hour=$( awk 'NR == '$hour $DF ) if (( $mins == 0 )) ; then print -n "It's $hour o'clock" else print -n "It's $minsword $tp $hour" fi if [[ $secs != '' ]] ; then print -n " and $secs second" if (( $secs == 1 )) ; then print "." ; else print "s." ; fi else print "." ; fi