29 const Cc = Components.classes;
30 const Ci = Components.interfaces;
31 const Cr = Components.results
35 localeBundlePath:
"chrome://songbird/locale/songbird.properties"
56 formatSingle:
function(aTime) {
59 throw Cr.NS_ERROR_INVALID_ARG;
66 formatTime = (aTime * 10) / 3600;
67 formatTime = Math.floor(formatTime);
68 formatTime = formatTime / 10;
70 formatTimeUnit =
"timeformatter.hours";
72 formatTimeUnit =
"timeformatter.hour";
73 }
else if (aTime >= 60) {
74 formatTime = (aTime * 10) / 60;
75 formatTime = Math.floor(formatTime);
76 formatTime = formatTime / 10;
78 formatTimeUnit =
"timeformatter.minutes";
80 formatTimeUnit =
"timeformatter.minute";
82 formatTime = Math.floor(aTime);
84 formatTimeUnit =
"timeformatter.seconds";
86 formatTimeUnit =
"timeformatter.second";
90 var stringBundleService =
Cc[
"@mozilla.org/intl/stringbundle;1"]
91 .getService(
Ci.nsIStringBundleService);
92 var
bundle = stringBundleService.createBundle(this._cfg.localeBundlePath);
93 formatTime = bundle.formatStringFromName(formatTimeUnit, [ formatTime ], 1);
114 formatHMS:
function formatHMS(aTime) {
115 function number(x) {
return typeof(x) ==
"number"; }
116 function pad(n) {
return (n < 10 ?
"0" :
"") + n; }
121 let hours = Math.floor(aTime / 3600);
122 let minutes = Math.floor((aTime - hours * 3600) / 60);
123 let seconds = Math.floor((aTime - hours * 3600 - minutes * 60));
124 return [hours ||
null, minutes, seconds].filter(number).map(pad).join(
":");