Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: DateTime and hour 0

by tcf03 (Deacon)
on Apr 18, 2005 at 13:54 UTC ( [id://448864]=note: print w/replies, xml ) Need Help??


in reply to Re: DateTime and hour 0
in thread DateTime and hour 0

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://448864]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-16 21:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found