Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Round time to nearest 15 or 30 minutes

by l.frankline (Hermit)
on Apr 25, 2006 at 04:41 UTC ( [id://545470]=note: print w/replies, xml ) Need Help??


in reply to Round time to nearest 15 or 30 minutes

This will also do for you:

%normalise_with_this = ( 15 => { 00 => [ 0 .. 14 ], 15 => [ 15 .. 29 ], 30 => [ 30 .. 44 ], 45 => [ 45 .. 59 ] }, 30 => { 00 => [ 0 .. 29 ], 30 => [ 30 .. 59 ] } ); &dofunc("200504250946",15); sub dofunc { my ($interval, $pos) = @_; $min = substr($interval,10,2); foreach $v (keys %{$normalise_with_this{$pos}}) { for (@{$normalise_with_this{$pos}{$v}} ) { print $v if grep /$min/,$_; } } }

Don't put off till tomorrow, what you can do today.

Log In?
Username:
Password:

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

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

    No recent polls found