sub minutes_before { my $minutes_b4=shift; my $month=shift; my $day=shift; my $hour=shift; my $minute=shift; my $MONTHNUM=&month_to_num($month); ( $day < 10 ) ? $FDAY="0$day" : $FDAY=$day; # Lets find n minutes before! $datetime=DateTime->new( year => 2005, month => $MONTHNUM, day => $FDAY, hour => $hour, minute => $minute, second => 00 ); my $formatter=DateTime::Format::Epoch->new( epoch => $datetime, unit => 'seconds', type => 'int', # or 'float', or 'bigint' skip_leap_seconds => 1, start_at => 0, local_epoch => undef ); my $seconds=$formatter->format_datetime($datetime); my $conv_seconds=$minutes_b4 * 60; $seconds=$seconds-$conv_seconds; # And we are left with n seconds before our search time my $MinBefore=$formatter->parse_datetime( $seconds ); # Now we'll reformat $MinBefore to fit the log file my ($DATE2, $TIME2)=split(/T/, $MinBefore); ($YEAR2, $MONTH2, $DAY2)=split(/-/, $DATE2); $MONTHNAME2=&num_to_month($MONTH2); ($HOUR2, $MINUTE2, $SECOND2)=split(/:/, $TIME2); # End of reformatting $MinBefore $DAY2=~s/^0+//; $ready=1; return @MINBEFORE=($MONTHNAME2, $DAY2, $HOUR2, $MINUTE2); }