The time doesn't display in a right way
0x0cqq opened this issue · comments
When the reading time is greater than 1 hours, it will display like this:
I believe that the problem is caused by the mistake in here:
// /lib/helper.js
var getFormatTime = function(minutes, suffix) {
var fHours = Math.floor(minutes / 60);
var fMinutes = Math.floor(minutes - (fHours * 60));
if (fMinutes < 1) { fMinutes = 1; } // 0 => 1
if (!suffix) { suffix = 'mins.'; } // 1 => 1 mins.
return fHours < 1
? fMinutes + ' ' + suffix // < 59 => 59 mins.
: fHours + ':' + (fMinutes < 10 && (fMinutes = '0' + fMinutes)); // = 61 => 1:01
};
because when I changed this javascript, it worked well.
var getFormatTime = function(minutes, suffix) {
var fHours = Math.floor(minutes / 60);
var fMinutes = Math.floor(minutes - (fHours * 60));
if (fMinutes < 1) { fMinutes = 1; } // 0 => 1
if (!suffix) { suffix = 'mins.'; } // 1 => 1 mins.
if (fMinutes < 10) fMinutes = '0' + fMinutes;
return fHours < 1
? fMinutes + ' ' + suffix // < 59 => 59 mins.
: (fHours + ':' + fMinutes); // = 61 => 1:01
};
I don't know much about javascript, so I hope that you can fix this bug quickly.
Sorry for my poor English.
Sorry, the right code should be:
var getFormatTime = function(minutes, suffix) {
var fHours = Math.floor(minutes / 60);
var fMinutes = Math.floor(minutes - (fHours * 60));
if (fMinutes < 1) { fMinutes = 1; } // 0 => 1
if (!suffix) { suffix = 'mins.'; } // 1 => 1 mins.
if (fHours > 0 && fMinutes < 10) fMinutes = '0' + fMinutes;
return fHours < 1
? fMinutes + ' ' + suffix // < 59 => 59 mins.
: (fHours + ':' + fMinutes); // = 61 => 1:01
};
It may have other bugs, since I haven't learned javascript.
@ChenQiqian please, try to fix by this #14 pull. It works fine?
I haven't noticed that pull request fix this bug.
I thought it only solved the bug when the minutes were less than 10 minutes.
Thanks. @ivan-nginx
@ChenQiqian so, this pull fix your bug or not? I must know it same bug or it another bug.
yes.
Ok, thank's!
Fixed in v0.4.4 release.
If solved, close it please.