#!/bin/ksh -p # Shell script to show time in english rather than in computerese #set -x secs='' if [[ $1 == '-s' ]] ; then secs=$(( $( date '+%S' ) )) ; fi typeset -i hour mins five 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=$( echo $mins | sed 's/15/a quarter/' | sed 's/30/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 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