#-*-Perl-*-

#Tack on the names of the subroutines to the list of functions
$hof{"goats"} = 0;

#Goats http://www.goats.com/
# ex : http://www.goats.com/comix/9804/goats980401.gif
sub goats {
    my $time = shift;
    return undef if $time < mktime(0,0,0,1,3,97); #1st comic: Apr 1, 1997
    my @ltime = localtime($time);
    my @rtime = localtime(time);
    my $rec = {
        'name' => strftime("Goats-${date_fmt}.gif",@ltime),
        'base' => "http://www.goats.com",
        'page' => "/archive",
	'func' => sub {
	    #because Goats sometimes doesn't follow the rule of always
	    #releasing comics on Sun-Thur, this function will return undef
	    #only for those days not in the archive.
	    $_ = shift;
	    my $y = strftime("%y",@ltime);
	    my $m = strftime("%m",@ltime);
	    my $d = strftime("%d",@ltime);
	    if (/IMG SRC="(\/comix\/$y$m\/goats$y$m$d\.gif)"/i) {
		return $1;
	    }
	    if (/A HREF="\/archive\/index.html\?$y$m$d"/i) {
		return "/comix/$y$m/goats$y$m$d.gif";
	    }
	    return ();
	}
    };

    #if the month we're getting is the same as the current month,
    #don't include the extra step of getting the archive list for
    #the month because it's already done for us.
    unless ($ltime[4] == $rtime[4] && $ltime[5] == $rtime[5]) {
	$rec->{'exprs'} = 
	    [strftime("HREF=\"(\\/archive\\/index.html\\?%y%m\\d\\d)\"",
		      @ltime)];
    }

    return $rec;
}

1;


