#!/bin/bash
#@DOC@ htt - convert hex to time
#
# Copyright (C) 2006  Nathan (Acorn) Pooley
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 2 as published by the Free Software Foundation.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License (gpl.txt) for more details. 
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
# 
# You can contact the author, Nathan (Acorn) Pooley, by writing
# to Nathan (Acorn) Pooley, 949 Buckeye Drive, Sunnyvale, CA  94086, USA
# or through the form at http://www.rawbw.com/~acorn/wand/feedback.html
# 

_conv() {
	a=$1
	(( b = a - 24 ))
	d="sat "
	ap="am"
	if (( b > 12 )) ; then
		(( b = b - 12 ))
		ap="pm"
	fi
	if (( b > 12 )) ; then
		(( b = b - 12 ))
		d="sun "
		ap="am"
	fi
	echo "$d $b $ap"
}

if [[ -z $1 ]] ; then
	while read i
	do
		_conv $i
	done
else
	for i in "$@"
	do
		_conv $i
	done
fi
