meh, JS Date support is so annoyingly bad

This commit is contained in:
Stefan Breunig
2013-02-05 20:03:30 +01:00
parent 4809af142d
commit 1cfd9330e6
2 changed files with 7 additions and 3 deletions

View File

@ -81,7 +81,9 @@ window.unixTimeToString = function(time, full) {
window.unixTimeToHHmm = function(time) {
if(!time) return null;
var d = new Date(typeof time === 'string' ? parseInt(time) : time);
return d.getHours() + ':' + d.getSeconds();
var h = '' + d.getHours(); h = h.length === 1 ? '0' + h : h;
var s = '' + d.getSeconds(); s = s.length === 1 ? '0' + s : s;
return h + ':' + s;
}