Round the time (in seconds) up to the next minute. If the time is already an even minute, nothing is changed.
Download timeceiling.zip
Synopsis: |
| timeceiling.pl |
| ||
#round up to the nearest minute, exact minutes stay where they are
# input parameter is a time in epoch seconds, e.g. time()
sub TimeCeiling($)
{
my ($t) = @_;
my $offset = $t % 60;
$t = $t + 60 - $offset if $offset > 0;
return $t;
}
#-- unit tests
sub test_timeceiling()
{
ut::assert(TimeCeiling(599), 600);
ut::assert(TimeCeiling(600), 600);
ut::assert(TimeCeiling(601), 660);
}
1;
|
| Contact me about content on this page using john_web-at-arrizza-dot-com |
| For Web Master or site problems contact: webadmin-at-arrizza-dot-com |
| Copyright John Arrizza (c) 2001-2010 |