sugar kills (removed sugar.js)

Relative dates for next airing on posters and list (series)
History time shows real time on tooltip
This commit is contained in:
Mark McDowall 2013-07-16 23:23:44 -07:00
commit 207d9c256d
21 changed files with 296 additions and 9100 deletions

View file

@ -2,37 +2,37 @@
define(
[
'sugar'
], {
Bytes: function (sourceSize) {
var size = Number(sourceSize);
return size.bytes(1);
},
'moment',
'filesize'
], function (Moment, Filesize) {
DateHelper: function (sourceDate) {
if (!sourceDate) {
return '';
}
return {
var date = Date.create(sourceDate);
Bytes: function (sourceSize) {
var size = Number(sourceSize);
return Filesize(size, 1, false);
},
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}');
}
DateHelper: function (sourceDate) {
if (!sourceDate) {
return '';
}
if (date.isAfter(Date.create().addDays(6))) {
return date.relative().replace(' from now', '');
}
var date = Moment(sourceDate);
return date.format('{MM}/{dd}/{yyyy}');
if (date.isAfter(Moment().add('days', 6))) {
return date.fromNow(true);
}
//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;
}
}
});

View file

@ -0,0 +1,23 @@
'use strict';
define(
[
], function () {
return {
startsWith: function(str, starts){
if (starts === '') return true;
if (str == null || starts == null) return false;
str = String(str); starts = String(starts);
return str.length >= starts.length && str.slice(0, starts.length) === starts;
},
endsWith: function(str, ends){
if (ends === '') return true;
if (str == null || ends == null) return false;
str = String(str); ends = String(ends);
return str.length >= ends.length && str.slice(str.length - ends.length) === ends;
}
}
});