Gossamer Forum
Quote Reply
Plugin to Check Date
Hi:



My site is a pretty modified Links- I show cartoon production data in a manner like IMDB, rather than Links like Yahoo. In any case, sometimes I have info in the database for FUTURE productions (and Add_Date, for me, is the date of cartoon release). So, what I want to do is have a global check the date, and if it is in the future, return a positive, so I can add a note that this cartoon is currently in production, and information is liable to change. I wrote this:



Quote:


sub {
use GT::Date qw/:all/;
my ($rec) = @_;
my $prod;
my $ad = $rec->{'Add_Date'};
Links::init_date();
my $today = date_get (time + (7 * 86400));
if (date_is_smaller($today,$ad)) {
$prod = 'Yes';
}
return $prod;
}


but it never returns anything. Any ideas?



Thanks!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] Plugin to Check Date In reply to
Try:


Code:
sub {
my $ad = $_[0]->{'Add_Date'};
my $tod;
require GT::Date;
import GT::Date qw/:all/;

Links::init_date();

my $tod = date_get (time + (7 * 86400));
return date_is_smaller($tod, $ad) ? 'Yes' : 'No;
}

If that doesn't work trying printing $ad and $tod to see what they look like

Last edited by:

Paul: Aug 29, 2002, 9:15 AM
Quote Reply
Re: [carfac] Plugin to Check Date In reply to
Nevermind- I got it! Turned out the dates were two different formats. The correct, workable code is:



Quote:


sub {
use GT::Date qw/:all/;
my ($rec) = @_;
my $prod;

Links::init_date();
my $today = date_get (time + (7 * 86400));
my $ad = GT::Date::date_transform ($rec->{Add_Date}, $CFG->{date_user_format}, $CFG->{date_db_format});
if (date_is_smaller($today,$ad)) {
$prod = 'Yes';
}
return $prod;
}
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [Paul] Plugin to Check Date In reply to
Paul:



Whoops- did not see your reply when I replied! Blush Thanks!



Checking the variables on the page is exactly what I did, and that is when I saw the format mis-match!
dave

Big Cartoon DataBase
Big Comic Book DataBase