On 04/05/2011 18:14, C.DeRykus wrote:
On May 3, 4:12 pm, rob.di...@gmx.com (Rob Dixon) wrote:
On 03/05/2011 19:49, C.DeRykus wrote:
use Time::localtime;
use List::Util qw/reduce/;
my @rounded_5mins = grep { not $_ % 5 } 0..60;
my $curr_min = localtime->min;
my $round_min = reduce { $curr_min-$a< $b-$curr_min ? $a : $b }
@rounded_5mins;
Both this and Uri's earlier suggestion ignore the seconds field. I would
be surprised if it was acceptable to round 10:02:59
to 10:00:00 rather than 10:05:00.
Depends on how precise the partition counts need to be... maybe just
determining the approx. spread of timestamps in 5 min. increments
suffices. And of course, if there's some other criteria, maybe, even
a biasing that causes 10:02:30 to fall into a 10:00:00 rather than a
10:05:00 slot, won't be acceptable either.
Maybe, anything is possible, I am just saying I think it is highly
unlikely. If precision is not an issue and the data just needs to be
bundled into intervals then why not just truncate to the preceding
five-minute mark? And if there is to be any attempt at finding
a near value then rounding 40% of the data upward and 60% of it downward
is a bizarre requirement.
Rob
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/