mirror of
https://github.com/Readarr/Readarr
synced 2025-12-17 22:03:05 +01:00
25 lines
No EOL
545 B
JavaScript
25 lines
No EOL
545 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}');
|
|
}
|
|
|
|
return date.format('{MM}/{dd}/{yyyy}');
|
|
} |