1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-10-27 06:02:33 +01:00

Remove some instances of moment that are not needed on the index to reduce the load

This commit is contained in:
nitsua 2020-09-30 13:26:00 -04:00 committed by Qstick
parent 82eadcffaa
commit 5b83d09d5e
5 changed files with 21 additions and 12 deletions

View File

@ -4,6 +4,7 @@ import isInNextWeek from 'Utilities/Date/isInNextWeek';
import isToday from 'Utilities/Date/isToday'; import isToday from 'Utilities/Date/isToday';
import isTomorrow from 'Utilities/Date/isTomorrow'; import isTomorrow from 'Utilities/Date/isTomorrow';
import isYesterday from 'Utilities/Date/isYesterday'; import isYesterday from 'Utilities/Date/isYesterday';
import translate from 'Utilities/String/translate';
function getRelativeDate(date, shortDateFormat, showRelativeDates, { timeFormat, includeSeconds = false, timeForToday = false } = {}) { function getRelativeDate(date, shortDateFormat, showRelativeDates, { timeFormat, includeSeconds = false, timeForToday = false } = {}) {
if (!date) { if (!date) {
@ -21,15 +22,15 @@ function getRelativeDate(date, shortDateFormat, showRelativeDates, { timeFormat,
} }
if (isYesterday(date)) { if (isYesterday(date)) {
return 'Yesterday'; return translate('Yesterday');
} }
if (isTodayDate) { if (isTodayDate) {
return 'Today'; return translate('Today');
} }
if (isTomorrow(date)) { if (isTomorrow(date)) {
return 'Tomorrow'; return translate('Tomorrow');
} }
if (isInNextWeek(date)) { if (isInNextWeek(date)) {

View File

@ -1,11 +1,12 @@
import moment from 'moment';
function isToday(date) { function isToday(date) {
if (!date) { if (!date) {
return false; return false;
} }
return moment(date).isSame(moment(), 'day'); const dateObj = (typeof date === 'object') ? date : new Date(date);
const today = new Date();
return dateObj.getDate() === today.getDate() && dateObj.getMonth() === today.getMonth() && dateObj.getFullYear() === today.getFullYear();
} }
export default isToday; export default isToday;

View File

@ -1,11 +1,13 @@
import moment from 'moment';
function isTomorrow(date) { function isTomorrow(date) {
if (!date) { if (!date) {
return false; return false;
} }
return moment(date).isSame(moment().add(1, 'day'), 'day'); const dateObj = (typeof date === 'object') ? date : new Date(date);
const today = new Date();
const tomorrow = new Date((today.setDate(today.getDate() + 1)));
return dateObj.getDate() === tomorrow.getDate() && dateObj.getMonth() === tomorrow.getMonth() && dateObj.getFullYear() === tomorrow.getFullYear();
} }
export default isTomorrow; export default isTomorrow;

View File

@ -1,11 +1,13 @@
import moment from 'moment';
function isYesterday(date) { function isYesterday(date) {
if (!date) { if (!date) {
return false; return false;
} }
return moment(date).isSame(moment().subtract(1, 'day'), 'day'); const dateObj = (typeof date === 'object') ? date : new Date(date);
const today = new Date();
const yesterday = new Date((today.setDate(today.getDate() - 1)));
return dateObj.getDate() === yesterday.getDate() && dateObj.getMonth() === yesterday.getMonth() && dateObj.getFullYear() === yesterday.getFullYear();
} }
export default isYesterday; export default isYesterday;

View File

@ -751,6 +751,8 @@
"Titles": "Titles", "Titles": "Titles",
"TMDBId": "TMDb Id", "TMDBId": "TMDb Id",
"TmdbIdHelpText": "The TMDb Id of the movie to exclude", "TmdbIdHelpText": "The TMDb Id of the movie to exclude",
"Today": "Today",
"Tomorrow": "Tomorrow",
"TorrentDelay": "Torrent Delay", "TorrentDelay": "Torrent Delay",
"TorrentDelayHelpText": "Delay in minutes to wait before grabbing a torrent", "TorrentDelayHelpText": "Delay in minutes to wait before grabbing a torrent",
"Torrents": "Torrents", "Torrents": "Torrents",
@ -842,5 +844,6 @@
"WhitelistedSubtitleTags": "Whitelisted Subtitle Tags", "WhitelistedSubtitleTags": "Whitelisted Subtitle Tags",
"Year": "Year", "Year": "Year",
"YesCancel": "Yes, Cancel", "YesCancel": "Yes, Cancel",
"Yesterday": "Yesterday",
"YouCanAlsoSearch": "You can also search using TMDb ID or IMDb ID of a movie. eg. tmdb:71663" "YouCanAlsoSearch": "You can also search using TMDb ID or IMDb ID of a movie. eg. tmdb:71663"
} }