|Perl: the Markov chain saw|
Round time to nearest 15 or 30 minutesby jesuashok (Curate)
|on Apr 25, 2006 at 03:29 UTC||Need Help??|
jesuashok has asked for the
wisdom of the Perl Monks concerning the following question:
I have subroutine which gets two params
The function has to extract the minutes from time_stamp (i,e) substr("200504250946",10,2) which results '46' from the example.
Interval is passed as 15.
from the hash "%normalise_with_this" using interval value I have to acess the first level of hash that is 15 or 30,
in our case I have to access 15.
From this I am able to access the second level of hash with the keys '00','15','30','45'.
In any of the values '46' will be there. In our case key '45' contains, 46 in it. (i,e) "45 .. 59 ".
How to point this efficiently using the above inputs which comes as a param to a function.
So function has to return the key 45.
If minute is 34, then function has to retun 30. because 34 lies in 30 => " 30 .. 44 ".
"Keep pouring your ideas"