<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># we need to comment this out or PAUSE might index it
# pack age DateTime::Format::Apache;

use DateTime::Format::Builder
(
    parsers =&gt; {
	parse_datetime =&gt; {
	    strptime =&gt; '%e/%b/%Y:%H:%M:%S %z',
	    #     params =&gt; [qw( day month year hour minute second time_zone )],
       	    #     regex =&gt; qr{ ^
       	    # 	(\d+)/(\w{3})/(\d{4})
       	    # 	:
       	    # 	(\d\d):(\d\d):(\d\d)
       	    # 	\s
       	    # 	([+-]\d{4})
       	    # 	$ }x,
       	    #     postprocess =&gt; sub {
       	    # 	my %args = @_;
       	    # 	$args{parsed}{month} = month_to_num( $args{parsed}{month} );
       	    # 	1;
       	    #     },
	},
    },
);

sub month_to_num
{
    my $wanted = shift;
    my %months;
    my $lang = DateTime::Language-&gt;new( language =&gt; 'en' );
    my $i;
    $months{$_} = ++$i for @{$lang-&gt;month_abbreviations};
    return $months{$wanted};
}

sub format_datetime
{
    my ($self, $dt) = @_;
    return $dt-&gt;strftime( "%e/%b/%Y:%H:%M:%S %z" );
}

package main;

my $parser = DateTime::Format::Apache-&gt;new();

my @dates = ( '27/Feb/2003:19:45:11 -0400', '27/Apr/2003:19:45:11 -0400' );

for my $date (@dates)
{
    my $dt = $parser-&gt;parse_datetime( $date )-&gt;set_time_zone( 'Australia/Sydney' );
    print "$date =&gt; ", $dt-&gt;datetime, " =&gt; ", $parser-&gt;format_datetime( $dt ), "\n";
}
</pre></body></html>