2013-03-30 19:33:41 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
//TODO: global function, not good!
|
2013-03-29 23:28:58 +00:00
|
|
|
function bestDateString(sourceDate) {
|
|
|
|
if (!sourceDate) {
|
|
|
|
return '';
|
|
|
|
}
|
2013-03-01 04:59:06 +00:00
|
|
|
|
|
|
|
var date = Date.create(sourceDate);
|
|
|
|
|
2013-03-29 23:28:58 +00: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-03-01 04:59:06 +00:00
|
|
|
|
|
|
|
return date.format('{MM}/{dd}/{yyyy}');
|
|
|
|
}
|