[ic] problems using a date widget

Mike Heins interchange-users@interchange.redhat.com
Thu Nov 15 17:02:00 2001


Quoting Scott Andreas---Learning Services, Inc (sandreas@learningservicesinc.com):
> I need to search for material based on date. So thusly I want to use the
> date widget to search for material within a date range.
> 
> On the search page I have...
> 
> <TR>
> 		<TD><B>Beginning<BR>
> 		[widget type=date NAME=ui_begin_date]</TD>
> 		<TD><B>Ending</B><BR>
> 		[widget type=date NAME=ui_end_date]</TD>
> </TR>
> 
> 
> on the result page I have...

With a problem like this, it is usually helpful to see what you get from
the input.

> 
> [calc]

## I bet the error log will show values like
## begin=11^@/^@15^@/^@2001 end=11^@/^@16^@/^@2001
Log("begin=$CGI->{ui_begin_date end=$CGI->{ui_end_date}");

## So you ask, what good is date_widget? Do this:
	
	for('ui_begin_date', 'ui_end_date') {
		$CGI->{$_} = $Tag->filter('date_change', $CGI->{$_};
	}

## Print then again
## begin=20011115 end=20011116
Log("begin=$CGI->{ui_begin_date end=$CGI->{ui_end_date}");

> 	if ($Session->{arg}) {
> 		$Scratch ->{date_limit} = "AND created like '$Session->{arg}%'";
> 	}
> 	elsif ($CGI->{ui_begin_date}) {
> 		for (qw/ ui_begin_date ui_end_date/) {
> 			$CGI -> {$_} = $Tag->filter ( {
> 				op => 'date_change',
> 				body => $CGI -> {$_}
> 				} );
> 		}
> 		$Scratch->{date_limit} = <<EOF
> AND created >= '$CGI->{ui_begin_date}'
> AND created <= '$CGI->{ui_end_date}Z'
> EOF
> 	}
> 	else {
> 		$Scratch -> {date_limit}= "";
> 	}
> 	return;
> [/calc]


-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

Fast, reliable, cheap.  Pick two and we'll talk.  -- unknown