#
# perl/status.pl
#
# Maintain time, date, saint status file and GUI feedback.
#

require 'perllib/ctime.pl';
require $SAINT_CF;

#
# Convert to time of day.
#
sub hhmmss {
	local($time) = @_;
	local($sec, $min, $hour, $day, $month, $year);
	
	($sec, $min, $hour, $day, $month, $year) = localtime($time);
	$year = $year % 100;
	$month = $month + 1;
	return sprintf "%02d/%02d/%02d-%02d:%02d:%02d",
		"$month", "$day", "$year", "$hour", "$min", "$sec";
}

sub update_status {
	local($text) = @_;

	$now = &hhmmss(time());

	# GUI feedback.
	print CLIENT "$now $text<br>\n" if $running_from_html;

	# Status file.
	die "Can't open status file $status_file\n" 
		unless open(STATUS, ">>$status_file");
	print STATUS "$now $text\n";
	close STATUS;
}
