Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Re^2: DateTime and hour 0 by tcf03
in thread DateTime and hour 0 by tcf03

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-03-28 11:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found