1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00
Radarr/UI/Mixins/spoon.js
2013-04-23 22:53:44 -07:00

29 lines
659 B
JavaScript

"use strict";
//TODO: global function, not good!
function bestDateString(sourceDate) {
if (!sourceDate) {
return '';
}
var date = Date.create(sourceDate);
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}');
}
if (date.isAfter(Date.create().addDays(6))) {
return date.relative().replace(' from now', '');
}
return date.format('{MM}/{dd}/{yyyy}');
}