Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

How to specify date for what's new

Quote Reply
How to specify date for what's new
Hi there,

in nph-build.cgi the subroutine build_update_newpop has this code:
$new_date = $LINKDB->get_date (time - (86400 * $LINKS{build_new_cutoff}));

Is there anyway to override time so that I can specify my date ranges.
example. today is June 9, 2001 but I want the new date to be evaluated as if it were June 1, 2001. This is an ongoing thing, so I don't want to have to go into the script to change it each time. I can handle passing in my date paramater, I just can get the:

$LINKDB->get_date (time - (86400 * $LINKS{build_new_cutoff})); to evaluate it properly.

I've tried:
$usethisdate="2001-06-01";
$LINKDB->get_date ($usethisdate - (86400 * $LINKS{build_new_cutoff})); to evaluate it properly.

Hope it's clear what I'm trying to accomplish, I'm not sure what else to try.

Anyone have any ideas?

thanks.


Quote Reply
Re: How to specify date for what's new In reply to
Are you even using Links SQL v.1.3????

If not, please re-post your question in the Links SQL Discussion Forum since this forum is strictly for Links SQL v.1.13 questions...

I also don't quite understand what you are attempting to do. If you want to increase the new cutoff check date, simply edit the value in the $LINKS{build_new_cutoff} variable in the Links.pm file.

Or what you could do is use Date comparison codes in MySQL, like TO_DAYS(NOW()) to check the dates appropriately.

More info...http://www.mysql.com

Regards,

Eliot Lee
Quote Reply
Re: How to specify date for what's new In reply to
Hi Again,
Yes I am using LinksSQL1.13. - I posted in the wrong forum once before and almost had my keyboard taken away. You won't ever see me doing that again.

Anyway, the idea is to be able to specify a date and bring up a set of links based on the date I enter which includes links whose add_date or mod_date(not sure yet which) is + a number of days into the future. I'm actually using this in search.cgi. So it's imperative to be able to specify the date + a number of days into the future.

Seems there has to be a way to say something like
$start_date = "2001-06-01"; #this value will become a variable
$range = 10; #number of days in the future to get.
$mytime = $LINKDB->_date_to_unix($start_date);
$new_date = $LINKDB->get_date ($mytime + (86400 * $range));

Unfortunately $mytime keeps coming back as "0".

Here's the info on _date_to_unix. Shouldn't this bring back the unix time value based on the date I enter which in turn could then be substituted for time in the code above?

sub _date_to_unix {
# --------------------------------------------------------
# Private method to translate a date into a unix time value.
#
my $date = shift; my $time = 0;
my ($year, $mon, $day) = split /-/, $date;
$year = $year - 1900; $mon = $mon - 1;

require Time::Local;
eval { $time = &Time::Local::timelocal(0,0,0, $day, $mon, $year); };
carp "DBSQL: Bad date: $date (parsed as '$day', '$mon', '$year'.\n" if ($DEBUG);
return $time;
}

Hope that's more clear.

peace.

Quote Reply
Re: How to specify date for what's new In reply to
Hi,

Don't bother converting dates, just do:

my $num_days = 10;
my $usethisdate = time - (86400 * $num_days);

will give you a unix time for 10 days ago (86400 is number of seconds in a day).

Cheers,

Alex

--
Gossamer Threads Inc.