Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: DateTime and hour 0

by fglock (Vicar)
on Apr 18, 2005 at 15:04 UTC ( #448908=note: print w/ replies, xml ) Need Help??


in reply to DateTime and hour 0

I can't replicate the problem here. How about simplifying the algorithm instead?

sub minutes_before { my $minutes_b4=shift; my $month=shift; my $day=shift; my $hour=shift; my $minute=shift; # Lets find n minutes before! my $datetime=DateTime->new( year => 2005, month => month_to_num($month), day => $day, hour => $hour, minute => $minute, second => 00 ); $datetime->subtract( minutes => $minutes_b4 ); $ready=1; return @MINBEFORE = ( num_to_month( $datetime->month ), $datetime->day, $datetime->hour, $datetime->minute ); }


Comment on Re: DateTime and hour 0
Download Code
Re^2: DateTime and hour 0
by tcf03 (Deacon) on Apr 18, 2005 at 15:51 UTC
    Thanks That seems to work better, Im just trying to zero-pad the day and num_to_month( $datetime->month ) isnt returning anything. But I get the idea. Thanks again.
    Ted
      Zero-padding is best done with printf or sprintf. I don't know where num_to_month is coming from (something you wrote?) but why not just use $datetime->month_name?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2014-11-25 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (160 votes), past polls