[mb-commits] branch, beta, updated. Use int(x + 0.5) rather than round()
MusicBrainz Git Server <[email protected]> Sun, 03 Feb 2013 13:26:32 +0000
| Newsgroups | gmane.comp.audio.musicbrainz.cvs |
|---|---|
| Message-ID | <E1U1zaa-00058p-BZ@wiley> |
The branch, beta has been updated
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=25c681cf30bb731f42ce38fa2df10898097bec06 (commit)
from http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=b6ab2b37132bdcbba92ffba5e07343fbda71b4c6 (commit)
Summary of changes:
lib/MusicBrainz/Server/Track.pm | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 25c681cf30bb731f42ce38fa2df10898097bec06
Author: Oliver Charles <[email protected]>
Date: Sun Feb 3 15:57:46 2013 +0000
Use int(x + 0.5) rather than round()
I incorrectly assumed round was present in standard Perl functions, so instead
this now uses the idiom of int(x + 0.5). This works correctly for positive
numbers, but not for negative numbers - however track durations are inherently
positive so this assumption holds.
diff --git a/lib/MusicBrainz/Server/Track.pm b/lib/MusicBrainz/Server/Track.pm
index 37007fc..9adbccb 100644
--- a/lib/MusicBrainz/Server/Track.pm
+++ b/lib/MusicBrainz/Server/Track.pm
@@ -30,7 +30,7 @@ sub FormatTrackLength
my ($hours, $minutes, $seconds);
($hours, $ms) = (floor($ms / $one_hour), $ms % $one_hour);
($minutes, $ms) = (floor($ms / $one_minute), $ms % $one_minute);
- $seconds = round($ms / $one_second);
+ $seconds = int(($ms / $one_second) + 0.5);
return $hours > 0 ?
sprintf ("%d:%02d:%02d", $hours, $minutes, $seconds) :
-----------------------------------------------------------------------
hooks/post-receive
--
mb_server