1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/Shared/FormatHelpers.js

39 lines
1.0 KiB
JavaScript
Raw Normal View History

2013-06-22 09:24:24 +03:00
'use strict';
2013-06-07 05:39:12 +03:00
define(
[
'moment',
'filesize'
], function (Moment, Filesize) {
2013-06-07 05:39:12 +03:00
return {
2013-06-07 05:39:12 +03:00
Bytes: function (sourceSize) {
var size = Number(sourceSize);
return Filesize(size, 1, false);
},
2013-06-07 05:39:12 +03:00
DateHelper: function (sourceDate) {
if (!sourceDate) {
return '';
}
var date = Moment(sourceDate);
if (date.isAfter(Moment().add('days', 6))) {
return date.fromNow(true);
}
2013-06-21 04:43:58 +03:00
//TODO: It would be nice to not have to hack this...
var calendarDate = date.calendar();
return calendarDate.substring(0, calendarDate.indexOf(' at '));
},
pad: function(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
}
});