#	Extract a timestamp from a file or directory in the format
#	needed by touch.

#	Copyright (c) 1994-1995 by Hamilton Laboratories.  All rights reserved.

proc timestmp( file )
	local j, t, month, year
	set t = `ls -L $file`:1-4:gs/:/ /
	@ month = 1
	foreach j (Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
		if (j == t[0]) break
		@ month++
	end
	set year = $t[5]:s/19//
	#	Watch out for 2-digit numbers with leading zeros that might be
	#	confused as octal in the printf.
	for j = 1 to 4 do
		if (t[j] =~ "0?") set t[j] = $t[j]:s/0//
	end
	return $printf("%02d%02d%02d%02d%02d%02d", ^
		month, t[1], t[2], t[3], t[4], year)
end

timestmp $argv
