#!/bin/ksh
#
# $Revision: 1.2 $ $Date: 2009/07/20 22:35:23 $
# $UUID: 22921313-0e77-3c99-af58-c93169869a45 $
#
#< updated: print last local update time for a file.

PATH=/usr/local/bin:/bin:/usr/bin
export PATH

# Argument check.
case "$#" in
    0) exit 1 ;;
    *) file=$1 ;;
esac
test -f "$file" || exit 2

# Try for an RCS or last-modified date on the file.
set X `rlog -zLT $file 2> /dev/null | grep '^date:' | head -1`

case "$#" in
    1) set X `ls -l $file`
       chg=`date -R -d "$7 $8 $9"`
       ;;

    *) args="$*"
       set X `echo $args | awk '{ print $3, substr($4,0,8) }'`
       chg=`date -R -d "$2 $3"`
       ;;
esac

# if @DATE@ string present, replace it.
if grep @DATE@ $file > /dev/null
then
    sed -e "s/@DATE@/$chg/" $file
else
    echo $chg $file
fi

exit 0
