Gossamer Forum
Home : Products : DBMan : Customization :

2nd New topic re: Whats_new_days

Quote Reply
2nd New topic re: Whats_new_days
In a different database, I'm using dbman to track lectures offered at a local department.

I've faked this db into using whats_new_days to include the future. Wink

In other words, the field "Date" in the database actually refers to the date of the seminar, which is most often in the future.

If I call whats_new_days=10, for example, I will get all the seminars in the last 11 days and any scheduled to come.

This is all good, except that I can't call
whats_new_days=0
which would list just seminars in the future.

If I call whats_new_days=1
that still lists records dated yesterday!

I guess another way to ask the question is, is it possible to list just records modified TODAY? not including yesterday?

Is it possible to call something like:
&view_records=1&date-gt=today?

Or, to make whats_new_days=1 generate todays date, not yesterdays?
Quote Reply
Re: 2nd New topic re: Whats_new_days In reply to
OK, I think I figured this out.

I've created a new subroutine in db.cgi:

sub get_yesterday {
#------------------------------------------------------------
# Returns yesterdays date in proper format
#

my ($time) = $_[0];
($time) or ($time = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
my (@months) = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
$day=$day-1;
($day < 10) and ($day = "0$day");
$year = $year + 1900;

return "$day-$months[$mon]-$year";
}

Then, I've altered the sub query,
from:


if ($in{'whats_new_days'}) {
$in{'modified-gt'} = &get_date(time() - (($in{'whats_new_days'}+1) * 86400));
}

to:

if ($in{'whats_new_days'}) {
$in{'modified-gt'} = &get_yesterday(time() - (($in{'whats_new_days'}+1) * 86400));
}

-----

So, the question is, will this work? It works for the moment- when I call with whats_new_days=1, I get all records where the date field is greater than or equal to today, which is what I wanted.

But, will my &get_yesterday function work on days like the 1st of a new month? after y2k?

John
Quote Reply
Re: 2nd New topic re: Whats_new_days In reply to
Your

$day-1

won't work. Your other get_yesterday will work.

No need to worry about Y2K. That's all taken care of in the line

$year = $year + 1900;



------------------
JPD