Gossamer Forum
Home : Products : DBMan : Customization :

JPDeni's date mod

Quote Reply
JPDeni's date mod
Gosh, I am having no server problems using the date to age mod, but DBMan isn't searching alright. No matter what age range I give, the server returns the same dates.
Any ideas?
My script is located at http://www.zidro.com/cgi-bin/dbman2/db.cgi
Quote Reply
Re: JPDeni's date mod In reply to
You have "Age-gt" in both of your age fields. You need to have


<TD VALIGN="TOP"> Entre <INPUT TYPE="TEXT" NAME="Age-gt" VALUE="" SIZE="3" MAXLENGTH="3">
y <INPUT TYPE="TEXT" NAME="Age-lt" VALUE="" SIZE="3" MAXLENGTH="3">

in order to get a range.

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





Quote Reply
Re: JPDeni's date mod In reply to
Gosh, can't believe I made that mistake
I'm such a stupid.
Thanks, now everything works fine
Carol, you should make this mod available, I'm sure everybody will benefit from it.
Quote Reply
Re: JPDeni's date mod In reply to
 Smile It happens.

I probably will go back through a lot of the things here on the forum and create mods for them. First, I need to revamp my website. I'm not happy with it at all. Then I need to finish writing the DBMan tutorial and another script I'm going to have available one of these days. Then I need to revamp the mods I already have -- to make them a little easier for the newer folks to be able to use the mods without so much confusion.

There's also a need to revamp and completely rewrite the databases for the site which I first got DBMan for. And, in the midst of all this, I'm trying to deal with clients. Smile



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





Quote Reply
Re: JPDeni's date mod In reply to
I was soooooo afraid that this could happen.
Well, I've been playing around with dates with the mod. I am getting an error when I do a search. I get errors when I put in Age-lt a number that brings up a date inferior (this is, older) that 31-Dec-1969. This is the date you had warned me about. What should I do now? What is the problem with this age boundary?
Heeeeeeeeelp! Frown
Quote Reply
Re: JPDeni's date mod In reply to
I don't know. The problem is that the date search is based on the "epoch date" of the server, which began on 1 January 1970. I didn't think even the birthdate conversion would work.

One thing that might work would be to completely revamp the date search routines so that it was looking for a number, instead of a date. If the dates were converted to a yyyymmdd format, the search routine could just look at those as numbers.

One thing I haven't looked at a lot is the search routines. Hang on a bit and I'll take a look.

Hmmmmm. Maybe we could do something with the date_to_unix subroutine. Are you willing to try something? I have no idea if it will work, so be sure to save your old script.

Here goes:

Code:
sub date_to_unix {
# --------------------------------------------------------
# This routine must take your date format and return the time a la UNIX time().
# Some things to be careful about..
# int your values just in case to remove spaces, etc.
# catch the fatal error timelocal will generate if you have a bad date..
# don't forget that the month is indexed from 0!
#
my ($date) = $_[0];
my (%months) = ("Jan" => 0, "Feb" => 1, "Mar" => 2, "Apr" => 3, "May" => 4, "Jun" => 5,
"Jul" => 6, "Aug" => 7, "Sep" => 8, "Oct" => 9, "Nov" => 10,"Dec" => 11);
my ($time);
my ($day, $mon, $year) = split(/-/, $_[0]);
unless ($day and $mon and $year) { return undef; }
unless (defined($months{$mon})) { return undef; }

$time = int($year) . ($months{$mon} + 1) . int($day);

return ($time);
}

It should work (famous last words! Smile), but I just don't know for sure.


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





Quote Reply
Re: JPDeni's date mod In reply to
I realized that there was a problem with this modification. You need to add the bolded lines below and change the last line that's listed below:

Code:
unless (defined($months{$mon})) { return undef; }
++$months{$mon};
if ($months{$mon} <10) {
$months{$mon} = "0".$months{$mon};
}
if ($day <10) {
$day = "0". int($day);
}

$time = int($year) . $months{$mon} . $day;

Sorry 'bout that!

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





Quote Reply
Re: JPDeni's date mod In reply to
I have followed your instructions. I have had no server errors with either of the script mods
The problem I am having is that for example when I make a range search between 30 and 40 years, I get people with 12 years and 22 years, really weird. Maybe you can have a look. I have translated the script, but I'm sure you will get around, as I can bet you know dbman structure as well as the palm of your hand.

The script is located at http://www.zidro.com/cgi-bin/dbman2/db.cgi

Thanks for everything, Carol! One more thing, with respect to this new program that lets people comment sites, isn't this similar to Alexa?

[This message has been edited by tachus (edited June 07, 1999).]
Quote Reply
Re: JPDeni's date mod In reply to
I'm not sure, Agustin. I told you this was a guess. Smile I may have to think about it some more and get back to you.

I just looked at information about Alexa. There are two main differences between Alexa and Third Voice. Alexa only tracks the links people use on the site and there are ways that a webmaster can turn it off. Third Voice allows people to add comments to your site (changing the way it looks to other people with Third Voice installed) and there's no way to turn it off.

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







[This message has been edited by JPDeni (edited June 08, 1999).]