Files
Readarr/frontend/src/Utilities/Date/formatDateTime.js
T
bakerboy448 94adb4d582 Fixed: Added Various Missing Translations
cleanup en.json of unused translates

Fixes #1397

Closes Sonarr PR # 4791 'Fixed: Better wording of MissingFromDisk'
2022-01-16 21:53:43 +00:00

41 lines
1011 B
JavaScript

import moment from 'moment';
import translate from 'Utilities/String/translate';
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 translate('Yesterday');
}
if (isToday(date)) {
return translate('Today');
}
if (isTomorrow(date)) {
return translate('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;