 extended ls output of the root directory to decide how many
# words should be skipped to get the date.

# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
set x`$ls_command /`

# Find which argument is the month.
month=
command=
until test $month
do
  test $# -gt 0 || error "failed parsing '$ls_command /' output"
  shift
  # Add another shift to the command.
  command="$command shift;"
  mon_to_month $1
done

test -n "$month" || error "failed parsing '$ls_command /' output"

# Get the extended ls output of the file or directory.
set dummy x`eval "$ls_command \"\\\$save_arg1\""`

# Remove all preceding arguments
eval $command

# Because of the dummy argument above, month is in $2.
#
# On a POSIX system, we should have
# $# = 5
# $1 = file size
# $2 = month
# $3 = day
# $4 = year or time
# $5 = filename
#
# On Darwin 7.7.0 and 7.6.0, we have
# $# = 4
# $1 = day
# $2 = month
# $3 = year or time
# $4 = filename

# Get the month.
mon_to_month $2

case $3 in
  ???*) day=$1;;
  *) day=$3; shift;;
esac

# Here we have to deal with the problem that the ls output gives either
# the time of day or the year.
case $3 in
  *:*) set `date`; eval year=\$$#
       case $2 in
	 Jan) nummonthtod=1;;
	 Feb) nummonthtod=2;;
	 Mar) nummonthtod=3;;
	 Apr) nummonthtod=4;;
	 May) nummonthtod=5;;
	 Jun) nummonthtod=6;;
	 Jul) nummonthtod=7;;
	 Aug) nummonthtod=8;;
	 Sep) nummonthtod=9;;
	 Oct) nummonthtod=10;;
	 Nov) nummonthtod=11;;
	 Dec) nummonthtod=12;;
       esac
       # For the first six months of the year the time notation can also
       # be used for files modified in the last year.
       if (expr $nummonth \> $nummonthtod) >/dev/null;
       then
	 year=`expr $year - 1`
       fi;;
  *) year=$3;;
esac

# The result.
echo $day $month $year

# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%Y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
