1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-27 23:06:29 -04:00
This commit is contained in:
Mark McDowall
2018-01-12 18:01:27 -08:00
committed by Taloth Saldono
parent 99feff549d
commit 5894b4fd95
1183 changed files with 91622 additions and 4978 deletions
@@ -0,0 +1,39 @@
import moment from 'moment';
import formatTime from './formatTime';
import isToday from './isToday';
import isTomorrow from './isTomorrow';
import isYesterday from './isYesterday';
function getRelativeDay(date, includeRelativeDate) {
if (!includeRelativeDate) {
return '';
}
if (isYesterday(date)) {
return 'Yesterday, ';
}
if (isToday(date)) {
return 'Today, ';
}
if (isTomorrow(date)) {
return 'Tomorrow, ';
}
return '';
}
function formatDateTime(date, dateFormat, timeFormat, { includeSeconds = false, includeRelativeDay = false } = {}) {
if (!date) {
return '';
}
const relativeDay = getRelativeDay(date, includeRelativeDay);
const formattedDate = moment(date).format(dateFormat);
const formattedTime = formatTime(date, timeFormat, { includeMinuteZero: true, includeSeconds });
return `${relativeDay}${formattedDate} ${formattedTime}`;
}
export default formatDateTime;