1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2025-03-05 19:21:55 +00:00
Sonarr/UI/Shared/FormatHelpers.js

39 lines
974 B
JavaScript
Raw Normal View History

2013-06-21 23:24:24 -07:00
'use strict';
2013-06-06 19:39:12 -07:00
define(
[
'sugar'
], {
2013-06-24 21:43:16 -07:00
Bytes: function (sourceSize) {
var size = Number(sourceSize);
return size.bytes(1);
},
2013-06-06 19:39:12 -07:00
DateHelper: function (sourceDate) {
if (!sourceDate) {
return '';
}
2013-06-06 19:39:12 -07:00
var date = Date.create(sourceDate);
2013-06-06 19:39:12 -07:00
if (date.isYesterday()) {
return 'Yesterday';
}
if (date.isToday()) {
return 'Today';
}
if (date.isTomorrow()) {
return 'Tomorrow';
}
if (date.isAfter(Date.create('tomorrow')) && date.isBefore(Date.create().addDays(7))) {
return date.format('{Weekday}');
}
2013-06-06 19:39:12 -07:00
if (date.isAfter(Date.create().addDays(6))) {
return date.relative().replace(' from now', '');
}
2013-06-20 18:43:58 -07:00
return date.format('{MM}/{dd}/{yyyy}');
}
});