You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readarr/UI/Shared/FormatHelpers.js

51 lines
1.3 KiB

'use strict';
12 years ago
define(
[
'moment',
'filesize'
], function (Moment, Filesize) {
12 years ago
return {
12 years ago
Bytes: function (sourceSize) {
var size = Number(sourceSize);
return Filesize(size, 1, false);
},
12 years ago
DateHelper: function (sourceDate) {
if (!sourceDate) {
return '';
}
var date = Moment(sourceDate);
if (date.isAfter(Moment().add('days', 6))) {
return date.fromNow(true);
}
12 years ago
11 years ago
if (date.isBefore(Moment().add('days', -6))) {
return date.fromNow();
}
var calendarDate = date.calendar();
11 years ago
//TODO: It would be nice to not have to hack this...
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;
},
Number: function (input) {
if (!input) {
return '';
}
return input.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
}
});