Skip to main content.
home | support | download

Back to List Archive

Re: Reverse sort date

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Mon Jul 29 2002 - 19:25:00 GMT
At 11:38 AM 07/29/02 -0700, Scot Hacker wrote:
>One final question: Where can I alter the date format in swish.cgi output?
>e.g. if I want to change:
>
>Last Changed:    2002-06-17 18:19:56 Pacific Daylight Time
>
>to read just:
>
>Last Changed:    2002-06-17

Take a look at 
 http://swish-e.org/2.2/docs/SWISH-RUN.html#Searching_Command_Line_Arguments

and look how to set the 'fmt' with the -x parameter.

Unfortunately, it's not too easy.

The swish.cgi script defines properties in the config file like:

 display_props   => [qw/swishlastmodified swishdocsize swishdocpath/],

then in the script it builds a list of properties and then builds the -x
parameter like:

$self->swish_command( -x => join( '\t', map { "<$_>" } @properties ) . '\n' );

which is just making a string like

   -x '<swishrank>\t<swishlastmodifed>\t....\n'

The format of the date should be a presentation issue, and not really set
in the script -- so in some ways it would be best to return a timestamp and
then format the date in the template or whatever you are using to generate
output.

But, perl is suppose to make thing easy, so you might try this untested bit
of code.  Replace the above line in swish.cgi with:

    my @props = map {
        $_ eq 'swishlastmodified' ? "$_ fmt='%Y-%m-%d'" : $_
    } @properties;

    $self->swish_command( -x => join( '\t', map { "<$_>" } @props ) . '\n' );


BTW -- If you need to change the timezone for the files you can just set
the TZ environment variable when the script is running.  For example, I've
got a .swishcgi.conf file that has:

  # Display swish times in GMT
  $ENV{TZ} = 'UTC';

Hope this helps.


-- 
Bill Moseley
mailto:moseley@hank.org
Received on Mon Jul 29 19:28:31 2002