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.
Quote Reply
Re: [EZFrag] Days Ago global In reply to
Hi,

You not considered GT::Date::date_add($date,$num_days) ? Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [EZFrag] Days Ago global In reply to
Hi,

Sorry, just realised I got confused as to what this global is doing =)

GT::Date::date_diff() should do what you want.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Days Ago global In reply to
KK, Thanks Andy . ^_^


Sacrifice is not about what you lose,
it is about what you gain in the process.