I'm having troubles with the What's New mod. When I try the link, I get this message:
Invalid date format: '$new'
I read through a thread addressing this that mentioned having -'s and spaces
in the date format, but I *think* I'm being consistent. I'm not very good
at Perl, and it's been 7 months since I originally customized this script,
so I'm having trouble getting back into it. It seems to log the date just
fine, but I can't get it to pull up the new items. Help? Posting parts
of my code below:
Sample data records:
2186|SBP12-5838|Pink Roses|acid free, lignin free, 12 x 12|Paper_12x12|Small_Craft_Punches|.30|sbp12-5838.gif|sbp12-5838t.gif| || || || || || ||31-Mar-2000
2187|SBP12-5839|Blue Stars|acid free, lignin free, 12 x 12|Paper_12x12|SonBurn|.30|sbp12-5839.gif|sbp12-5839t.gif| || || || || || ||31-Mar-2000
=================================
This is the structure of the Date field:
Date => [21, 'date', -1, 15, 1, &get_date, ''],
=================================
sub get_date {
$time1 = @_[0];
($time1) or ($time1 = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1);
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}
=================================
sub date_to_unix {
my ($date) = $_[0];
my (%months) = ("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4, "Jun" => 5,
"Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9, "Nov" => 10,"Dec" => 11);
my ($time);
my ($day, $mon, $year) = split(/-/, $_[0]);
unless ($day and $mon and $year) { return undef; }
unless (defined($months{$mon})) { return undef; }
use Time::Local;
eval {
$day = int($day); $year = int($year) - 1900;
$time = timelocal(0,0,0,$day, $months{$mon}, $year);
};
if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}
===============================
##########################################################
## What's New Mod ##
##########################################################
# Put any globals you like in here for your html pages.
$days = 15; # set this one day more than you want records to be considered "new."
# If you want to include records from the previous 7 days, set the number
# to 8.
$new = &get_date(time() - ($days * 86400));
$new = "$day-$months[$mon]-$year";
...thanks in advance!
-Joyce