You don't have to limit yourself to goofy "%" things in your format, either. HTML works too! I have a bunch of GIFs named after the days of the week. By setting my config line to:
<!--#config timefmt="<img align=center src="/geektalk/96/38/stuff/%A.gif>"-->
And including this line again:
<!--#echo var="DATE_LOCAL"-->
I get:
%% - %
%a - Wed: Day of the week abbreviation
%A - Wednesday: Full name of day of the week
%w - 3: Number of day of the week; Sunday is day 0 (0-6)
%b - Oct: Month abbreviation
%B - October: Full name of month
%d - 29: The day of the month (01-31)
%e - 29: The day of the month (1-31)
%H - 19: Hour of day (00-23)
%I - 07: Hour of day (01-12)
%j - 302: Day in the year (001-366)
%M - 37: Minute (00-59)
%p - PM: AM or PM
%S - 44: Second (00-61); watch your leap seconds
%y - 97: Last two digits of the year (00-99)
%Y - 1997: The year
%Z - PST: The time zone
Here's your CGI script
Which is great, but here's where things can also get frustrating. According to HTML standards, the preceding line should include another set of quotation marks around stuff/%A.gif, like this:
<!--#config timefmt="<img align=center src="stuff/%A.gif">"-->
But this creates a lot of confusion, because it's difficult to tell which quotes are the end quotes. I also don't like having to include both upper and lower-case letters in my URLs, so I wrote a short CGI script in
Perl to take care of the problem:
#!/usr/local/bin/perl -Tw
#
# Does this script not work with your
# Perl? Make sure you're using Perl5:
# http://zen.org/~sven/geek/perl5p.html
use strict;
# First let's find out what time it is.
my @time = localtime(time);
# Then let's pull the day we care about.
my $day = ("Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday",
"Friday", "Saturday")[$time[6]];
# Tell the world we are sending a GIF
# created using at least one
# patented algorithm.
print "Content-type: image/gif\r\n\r\n";
# load the GIF and print it out.
if (open(GIF, "./$day.gif")) {
while (<GIF>) {
print;
}
}
close(GIF);
exit 0;
This script checks the day, finds the right GIF, and sends it down the HTTP wire. All you have to do is use the script as if it's an image. Like this:
<img align=center src="/geektalk/96/38/stuff/day.cgi">
And it will look like this:
The easy way out
And finally, if all of this seems like too much trouble, you can always do the VCR thing.