#
#  A couple of date/time functions - get_date, which pretty prints the
# date, and time_stamp, which puts the current time into a file (used
# for marking all the output routines and when they were run).
#


#
# figure out the date, put it in a decent format... typically day_mon_year.
#
 
require "conf/paths.pl";

sub get_date {

print "going into date - $DATE...\n" if $debug;

print "Determining date (in &get_date())\n" if $verbose;

if (!defined($pretty_date)) {
	if (-x $DATE) {
		# $tmp =  `$DATE`;

		chop($tmp = &command_to_string($DATE));

		($x, $mon, $day, $time, $tz, $year) = split(/\s/, $tmp);
		$pretty_date = "$day\_$mon\_$year\_$time\_$tz";
		}
	else {
		print "going into def...\n" if $debug;
		$pretty_date = "date_unknown";
		}
	}

return $pretty_date;

}

#
#  Put the current date into a file - truncates file, so be careful!
#
sub date_stamp {
local($file) = @_;

print "Stamping file $file with date (in &date_stamp())\n" if $verbose;

die "Can't determine the date!\n" unless -x $DATE;

&redirect_command($DATE, ">$file");

}

1;
