Permalink
Browse files

Add 0.5 ms in format track length functions to make sure they're roun…

…ding correctly.
  • Loading branch information...
1 parent 808b5eb commit 7fcda887e03201e7c72f20cf830584417de54eee @warpr warpr committed Aug 3, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/MusicBrainz/Server/Track.pm
@@ -23,7 +23,7 @@ sub FormatTrackLength
return $ms unless looks_like_number($ms);
return "$ms ms" if $ms < 1000;
- my $seconds = $ms / 1000;
+ my $seconds = $ms / 1000.0 + 0.5;
my $pattern = $seconds >= 3600 ? "%H:%M:%S" : "%M:%S";
my $f = DateTime::Format::Duration->new (normalize => 1, pattern => $pattern);
@@ -35,7 +35,7 @@ sub FormatXSDTrackLength
my $ms = shift;
return undef unless $ms;
- my $length_in_secs = ($ms / 1000.0);
+ my $length_in_secs = ($ms / 1000.0 + 0.5);
sprintf "PT%dM%dS",
int($length_in_secs / 60),
($length_in_secs % 60),

0 comments on commit 7fcda88

Please sign in to comment.