I didn't set it to 24 I tried 0 and 00, thats why the error seems odd to me.
here is the beginning of the sub where this is located
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 'b
+igint'
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);
}
and here is where $hour gets set:
if ( defined (param('MONTH')) and
defined (param('DAY')) and
defined (param('HOUR')) and
defined (param('MINUTE')) )
{
$MONTH=param('MONTH');
$DAY=param('DAY');
$HOUR=param('HOUR');
$MINUTE=param('MINUTE');
snip...
@M1=&minutes_before(1, $MONTH, $DAY, $HOUR, $MINUTE);
The code works as its supposed to execept when I enter 0 or 00.
Thanks
Ted
update
$hour % 24 didn't work either.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.