[mb-commits] branch, mbs-5765, updated. MBS-5765: Use the same implementation of FormatTrackLength (Perl) in formatTr...
MusicBrainz Git Server <[email protected]> Tue, 29 Jan 2013 12:39:44 +0000
| Newsgroups | gmane.comp.audio.musicbrainz.cvs |
|---|---|
| Message-ID | <E1U0ATY-0001xR-SZ@wiley> |
The branch, mbs-5765 has been updated
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=c28ab6858fb558b201c7f88ea9cc719fd5144d72 (commit)
from http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=63289a136150f379cd8b21e2a964e1cf910ff6a2 (commit)
Summary of changes:
lib/MusicBrainz/Server/Track.pm | 2 +-
root/static/scripts/common/MB/utility.js | 34 +++++++++++++++---------------
2 files changed, 18 insertions(+), 18 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 c28ab6858fb558b201c7f88ea9cc719fd5144d72
Author: Oliver Charles <[email protected]>
Date: Tue Jan 29 12:43:12 2013 +0000
MBS-5765: Use the same implementation of FormatTrackLength (Perl) in formatTrackLength (JS)
diff --git a/lib/MusicBrainz/Server/Track.pm b/lib/MusicBrainz/Server/Track.pm
index 789793e..37007fc 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 = floor($ms / $one_second);
+ $seconds = round($ms / $one_second);
return $hours > 0 ?
sprintf ("%d:%02d:%02d", $hours, $minutes, $seconds) :
diff --git a/root/static/scripts/common/MB/utility.js b/root/static/scripts/common/MB/utility.js
index d0eb2e9..fb278ac 100644
--- a/root/static/scripts/common/MB/utility.js
+++ b/root/static/scripts/common/MB/utility.js
@@ -197,29 +197,29 @@ MB.utility.formatTrackLength = function (duration)
return duration + ' ms';
}
- var seconds = 1000;
- var minutes = 60 * seconds;
- var hours = 60 * minutes;
+ var one_second = 1000.0;
+ var one_minute = 60 * one_second;
+ var one_hour = 60 * one_minute;
- var hours_str = '';
- duration = duration + 500;
+ var hours = Math.floor(duration / one_hour);
+ duration = duration % one_hour;
- if (duration > 1 * hours)
- {
- hours_str = Math.floor (duration / hours) + ':';
- duration = Math.floor (duration % hours);
- }
+ var minutes = Math.floor(duration / one_minute);
+ duration = duration % one_minute;
- /* pad minutes with zeroes of the hours string is non-empty. */
- var minutes_str = hours_str === '' ?
- Math.floor (duration / minutes) + ':' :
- ('00' + Math.floor (duration / minutes)).slice (-2) + ':';
+ var seconds = Math.round(duration / one_second);
- duration = Math.floor (duration % minutes);
+ var ret = '';
+ ret = ('00' + seconds).slice(-2);
- var seconds_str = ('00' + Math.floor (duration / seconds)).slice (-2);
+ if (hours > 0) {
+ ret = hours + ':' + ('00' + minutes).slice(-2) + ':' + ret;
+ }
+ else {
+ ret = minutes + ':' + ret;
+ }
- return hours_str + minutes_str + seconds_str;
+ return ret;
};
-----------------------------------------------------------------------
hooks/post-receive
--
mb_server