2013-06-22 08:24:24 +02:00
|
|
|
'use strict';
|
2013-06-07 04:39:12 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'sugar'
|
|
|
|
], {
|
2013-06-25 06:43:16 +02:00
|
|
|
Bytes: function (sourceSize) {
|
2013-06-25 01:41:59 +02:00
|
|
|
var size = Number(sourceSize);
|
|
|
|
return size.bytes(1);
|
|
|
|
},
|
2013-06-07 04:39:12 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
DateHelper: function (sourceDate) {
|
|
|
|
if (!sourceDate) {
|
|
|
|
return '';
|
|
|
|
}
|
2013-06-07 04:39:12 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
var date = Date.create(sourceDate);
|
2013-06-07 04:39:12 +02:00
|
|
|
|
2013-06-25 01:41:59 +02: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-07 04:39:12 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
if (date.isAfter(Date.create().addDays(6))) {
|
|
|
|
return date.relative().replace(' from now', '');
|
|
|
|
}
|
2013-06-21 03:43:58 +02:00
|
|
|
|
2013-06-25 01:41:59 +02:00
|
|
|
return date.format('{MM}/{dd}/{yyyy}');
|
|
|
|
}
|
|
|
|
});
|