Gossamer Forum
Home : Products : DBMan : Customization :

Calendar / Dates

Quote Reply
Calendar / Dates
Using DBMan for a water quality education site. To make it brief, their water data requires date entry in MM/DD/YY format. Works fine.

The problem: When using a 2nd db for their scheduling info, I'm trying to make it so users can select a month and get all entries WITHOUT making "05" return "06/05/99" date.

Any ideas? I am including my get_date routines:

sub get_date {
# --------------------------------------------------------


my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
my (@months) = qw!01 02 03 04 05 06 07 08 09 10 11 12!;
($day < 10) and ($day = "0$day");
$year = $year + 1900;

return "$months[$mon]\/$day\/$year";
}

sub date_to_unix {
# --------------------------------------------------------

my ($date) = $_[0];
my (%months) = ("01" => 0, "02" => 1, "03" => 2, "04" => 3, "05" => 4, "06" => 5,
"07" => 6, "08" => 7, "09" => 8, "10" => 9, "11" => 10,"12" => 11);
my ($time);
my ($mon, $day, $year) = split(/\//, $_[0]);
unless ($mon and $day and $year) { return undef; }
unless (defined($months{$mon})) { return undef; }

use Time::Local;
eval {
$day = int($day); $year = int($year) - 1900;
$time = timelocal(0,0,0,$day, $months{$mon}, $year);
};
if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}

------------------
farlane aka andrew mcfarlane
www.leelanau.com/pages/
Quote Reply
Re: Calendar / Dates In reply to
PS: Alex, this is a great program. Thanks.
And thanks as well for using the supremely easy to use and navigate UBB!

------------------
farlane aka andrew mcfarlane
www.leelanau.com/pages/farlane/

Quote Reply
Re: Calendar / Dates In reply to
Sorry I didn't answer this before. I didn't have an answer. Smile

I'm pretty sure it would be possible to have different get_date and date_to_unix subroutines for your different databases. All you would need do is cut the routines out of db.cgi and paste them into either the html.pl script or the .cfg file.

Does this help?


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


Quote Reply
Re: Calendar / Dates In reply to
i'm wanting to do the same thing.

does this program work for calanders?

l. spooner
Quote Reply
Re: Calendar / Dates In reply to
Thanks,

It does help. I think I have it licked by changing the "date" field to three seperate fields for month, day and year.

A 2nd question JP (by the way, I've seen your helpful posts -- are you somehow connected w/ Gossamer Threads?):
I plan to write an addition to have the script purge dated dates. My initial idea was to have it do so when opening the database to add, but of course it would be cooler to have it do this daily. Any thoughts on where the best spot to insert a routine to check date and erase events that have already happened??

Thanks, and I'll post what I come up with...

------------------
farlane aka andrew mcfarlane
www.leelanau.com/pages/farlane/

Quote Reply
Re: Calendar / Dates In reply to
 
Code:
print qq|<TABLE BORDER=0><TR><TD><INPUT TYPE=CHECKBOX NAME="$tmp{$db_key}" VALUE="delete"|;
if ($in{'variable'}) {
print " CHECKED";
}
print qq|></TD><TD>|;

That way, you don't have to go down the list and check all the records you want to delete, but you would still have control if you didn't want to delete some of the records.

To get even trickier, you could put the "Submit" and "Reset" buttons at the top of the form.

So in order to delete the old records, you would click on a link and then click on a button.

Still, cron is cooler! Smile



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