Gossamer Forum
Quote Reply
Days Ago global
Hi there ^_^ (!?Where is the old smileys?!)

I have a interresting situation here. Observe the global below...
Now here is the Interresting part. It works very well, whole year round, except for 7 days
of the year...

01-31-2008
03-31-2008
05-31-2008
07-31-2008
08-31-2008
10-31-2008
12-31-2008

I have this feeling it might be something to do with the days being the 31st
of the month.

The tests I ran on the global revealed that on the first eval line:
Code:
$time = &Time::Local::timelocal(0,0,0, $day, $mon, $year);

$time will not change. as if the line is not executed at all.
Is there a specific reason for this... anomaly?

Code:
sub {
my $date = shift;
my ($oyear,$omon,$oday) = split(/-/, $date);
GT::Date::date_set_format('%yyyy%-%mm%-%dd%');
my ($year,$mon,$day) = split(/-/,GT::Date::date_get());
$day = int($day); $mon = int($mon); $year = int($year);
$oday = int($oday); $omon = int($omon); $oyear = int($oyear);
require Time::Local;
my $time = 0;
my $otime = 0;

eval {
$time = &Time::Local::timelocal(0,0,0, $day, $mon, $year);
};

eval {
$otime = &Time::Local::timelocal(0,0,0, $oday, $omon, $oyear);
};

my $result = ($time - $otime)/86400;

if($result > 5)
{
return "$result Days ago";
}
if($result == 0)
{
return "<label style='color:#F00'>Today</label>";
}
if($result == 1)
{
return "<label style='color:#F00'>Yesterday</label>";
}
return "$result Days ago";
}


Sacrifice is not about what you lose,
it is about what you gain in the process.
Subject Author Views Date
Thread Days Ago global EZFrag 6172 Oct 31, 2008, 2:40 AM
Post Re: [EZFrag] Days Ago global
Andy 5993 Oct 31, 2008, 2:43 AM
Thread Re: [EZFrag] Days Ago global
Andy 6005 Oct 31, 2008, 2:45 AM
Post Re: [Andy] Days Ago global
EZFrag 5970 Oct 31, 2008, 4:14 AM