|
#!/usr/bin/perl
|
|
|
|
use CGI;
|
|
|
|
$q = new CGI;
|
|
if ($q->param) {
|
|
if ($q->param('time')) {
|
|
$format = ($q->param('type') eq '12-hour') ? '%r ' : '%T ';
|
|
}
|
|
$format .= '%A ' if $q->param('day');
|
|
$format .= '%B ' if $q->param('month');
|
|
$format .= '%d ' if $q->param('day-of-month');
|
|
$format .= '%Y ' if $q->param('year');
|
|
} else { $format = '%r %A %B %d %Y' }
|
|
|
|
chomp($time = `date '+$format'`);
|
|
|
|
# print the HTTP header and the HTML document
|
|
print $q->header;
|
|
print $q->start_html('Virtual Clock');
|
|
|
|
print "<H1>Virtual Clock</H1>At the tone, the time will be\
|
|
<STRONG>$time</STRONG>.";
|
|
print "<HR><H2>Set Clock Format</H2>";
|
|
|
|
# create the clock settings form
|
|
print $q->start_form, "Show: ";
|
|
print $q->checkbox(-name=>'time', -checked=>1), $q->checkb\
|
|
ox(-name=>'day',-checked=>1);
|
|
print $q->checkbox(-name=>'month',-checked=>1), $q->checkb\
|
|
ox(-name=>'day-of-month',-checked=>1);
|
|
print $q->checkbox(-name=>'year', -checked=>1), "<P>";
|
|
print "Time style: ", $q->radio_group(-name=>'type',-values=>\
|
|
['12-hour','24-hour']),"<P>";
|
|
|
|
print $q->reset(-name => 'Reset'), $q->submit(-name => 'Se\
|
|
t');
|
|
print $q->end_form;
|
|
print $q->end_html;
|