--- lib/TWiki/Search.pm.orig 2006-03-31 13:53:54.000000000 +0200 +++ lib/TWiki/Search.pm 2006-03-31 17:27:15.000000000 +0200 @@ -401,6 +401,7 @@ my $type = $params{type} || ''; my $webName = $params{web} || ''; my $date = $params{date} || ''; + my $createdate = $params{createdate} || ''; my $recurse = $params{'recurse'} || ''; my $finalTerm = $inline ? ( $params{nofinalnewline} || 0 ) : 0; @@ -665,15 +666,35 @@ } } - if( $date ){ + if( $date || $createdate ) { use TWiki::Time; - my @ends = &TWiki::Time::parseInterval( $date ); + my @ends = (); my @resultList = (); - foreach my $topic ( @topicList ) { - # if date falls out of interval: exclude topic from result - my $topicdate = $store->getTopicLatestRevTime( $web, $topic ); - push( @resultList, $topic ) - unless ( $topicdate < $ends[0] || $topicdate > $ends[1] ); + + # Design Decision: although the inner foreach loop is mostly common for + # date and createdate, we do not share it because deciding if we look + # for createdate or last modifieddate in each loop is more expensive + # and weights more than 3-4 lines of code duplication. + # If given both params (date and createdate) we prefer createdate. + if( $createdate ) { + # the createdate = date of the first revision + @ends = &TWiki::Time::parseInterval( $createdate ); + foreach my $topic ( @topicList ) { + # if date falls out of interval: exclude topic from result + my $r1info = {}; + my $topicdate = $this->_getRev1Info( $web, $topic, 'unformatteddate', $r1info ); + push( @resultList, $topic ) + unless ( $topicdate < $ends[0] || $topicdate > $ends[1] ); + } + } else { + # the date = date of the last (actual) revision + @ends = &TWiki::Time::parseInterval( $date ); + foreach my $topic ( @topicList ) { + # if date falls out of interval: exclude topic from result + my $topicdate = $store->getTopicLatestRevTime( $web, $topic ); + push( @resultList, $topic ) + unless ( $topicdate < $ends[0] || $topicdate > $ends[1] ); + } } @topicList = @resultList; } @@ -1078,7 +1099,8 @@ # Returns the topic revision info of the base version, # attributes are 'date', 'username', 'wikiname', -# 'wikiusername'. Revision info is cached in the search +# 'wikiusername' and 'unformatteddate'. +# Revision info is cached in the search # object for speed. sub _getRev1Info { my( $this, $web, $topic, $attr, $info ) = @_; @@ -1104,6 +1126,9 @@ if( $attr eq 'date' ) { return TWiki::Time::formatTime( $info->{date} ); } + if( $attr eq 'unformatteddate' ) { + return $info->{date}; + } return 1; }