From 72631eab8f956d23e0d4d34af6f965f03d584b64 Mon Sep 17 00:00:00 2001 From: Fish2 Date: Thu, 16 Nov 2017 19:20:41 +0000 Subject: [PATCH] Fixed: moment.js deprecated zone and add functions (Fixes #2232) (Fixes #2231) (#2264) --- src/UI/Calendar/CalendarView.js | 2 +- src/UI/Calendar/UpcomingItemView.js | 2 +- src/UI/Cells/RelativeDateCell.js | 4 ++-- src/UI/Commands/CommandController.js | 2 +- src/UI/Movies/Details/SeasonLayout.js | 6 +++--- src/UI/Series/Details/SeasonLayout.js | 6 +++--- src/UI/Shared/FormatHelpers.js | 4 ++-- src/UI/System/Logs/Table/LogTimeCell.js | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/UI/Calendar/CalendarView.js b/src/UI/Calendar/CalendarView.js index d2f482aa7..81389df6f 100644 --- a/src/UI/Calendar/CalendarView.js +++ b/src/UI/Calendar/CalendarView.js @@ -151,7 +151,7 @@ module.exports = Marionette.ItemView.extend({ start = model.get("physicalRelease"); } var runtime = model.get('runtime'); - var end = moment(start).add('minutes', runtime).toISOString(); + var end = moment(start).add(runtime, 'minutes').toISOString(); var event = { title : seriesTitle, diff --git a/src/UI/Calendar/UpcomingItemView.js b/src/UI/Calendar/UpcomingItemView.js index 8e1273413..d34371d73 100644 --- a/src/UI/Calendar/UpcomingItemView.js +++ b/src/UI/Calendar/UpcomingItemView.js @@ -13,7 +13,7 @@ module.exports = Marionette.ItemView.extend({ initialize : function() { var start = this.model.get('inCinemas'); var runtime = this.model.get('runtime'); - var end = moment(start).add('minutes', runtime); + var end = moment(start).add(runtime, 'minutes'); this.model.set({ end : end.toISOString() diff --git a/src/UI/Cells/RelativeDateCell.js b/src/UI/Cells/RelativeDateCell.js index eb69fc855..df147b6a2 100644 --- a/src/UI/Cells/RelativeDateCell.js +++ b/src/UI/Cells/RelativeDateCell.js @@ -12,7 +12,7 @@ module.exports = NzbDroneCell.extend({ if (dateStr) { var date = moment(dateStr); - var diff = date.diff(moment().zone(date.zone()).startOf('day'), 'days', true); + var diff = date.diff(moment().utcOffset(date.utcOffset()).startOf('day'), 'days', true); var result = '{1}'; var tooltip = date.format(UiSettings.longDateTime()); var text; @@ -31,4 +31,4 @@ module.exports = NzbDroneCell.extend({ } return this; } -}); \ No newline at end of file +}); diff --git a/src/UI/Commands/CommandController.js b/src/UI/Commands/CommandController.js index 8ca7157da..ea301e32f 100644 --- a/src/UI/Commands/CommandController.js +++ b/src/UI/Commands/CommandController.js @@ -20,7 +20,7 @@ var singleton = function() { var attr = _.extend({ name : name.toLocaleLowerCase() }, properties); var commandModel = new CommandModel(attr); - if (this._lastCommand.command && this._lastCommand.command.isSameCommand(attr) && moment().add('seconds', -5).isBefore(this._lastCommand.time)) { + if (this._lastCommand.command && this._lastCommand.command.isSameCommand(attr) && moment().add(-5, 'seconds').isBefore(this._lastCommand.time)) { Messenger.show({ message : 'Please wait at least 5 seconds before running this command again', diff --git a/src/UI/Movies/Details/SeasonLayout.js b/src/UI/Movies/Details/SeasonLayout.js index 2638a2b70..fa362c775 100644 --- a/src/UI/Movies/Details/SeasonLayout.js +++ b/src/UI/Movies/Details/SeasonLayout.js @@ -214,8 +214,8 @@ module.exports = Marionette.Layout.extend({ }, _shouldShowEpisodes : function() { - var startDate = moment().add('month', -1); - var endDate = moment().add('year', 1); + var startDate = moment().add(-1, 'month'); + var endDate = moment().add(1, 'year'); return this.episodeCollection.some(function(episode) { var airDate = episode.get('airDateUtc'); @@ -298,4 +298,4 @@ module.exports = Marionette.Layout.extend({ vent.trigger(vent.Commands.OpenModalCommand, view); } -}); \ No newline at end of file +}); diff --git a/src/UI/Series/Details/SeasonLayout.js b/src/UI/Series/Details/SeasonLayout.js index cf10b6fa8..231810647 100644 --- a/src/UI/Series/Details/SeasonLayout.js +++ b/src/UI/Series/Details/SeasonLayout.js @@ -214,8 +214,8 @@ module.exports = Marionette.Layout.extend({ }, _shouldShowEpisodes : function() { - var startDate = moment().add('month', -1); - var endDate = moment().add('year', 1); + var startDate = moment().add(-1, 'month'); + var endDate = moment().add(1, 'year'); return this.episodeCollection.some(function(episode) { var airDate = episode.get('airDateUtc'); @@ -298,4 +298,4 @@ module.exports = Marionette.Layout.extend({ vent.trigger(vent.Commands.OpenModalCommand, view); } -}); \ No newline at end of file +}); diff --git a/src/UI/Shared/FormatHelpers.js b/src/UI/Shared/FormatHelpers.js index 303f60ff6..3c1703203 100644 --- a/src/UI/Shared/FormatHelpers.js +++ b/src/UI/Shared/FormatHelpers.js @@ -40,7 +40,7 @@ module.exports = { return 'in ' + date.fromNow(true); } - if (date.isBefore(moment().add('years', -1))) { + if (date.isBefore(moment().add(-1, 'years'))) { return date.format(UiSettings.get('shortDateFormat')); } @@ -68,4 +68,4 @@ module.exports = { return unit + 's'; } -}; \ No newline at end of file +}; diff --git a/src/UI/System/Logs/Table/LogTimeCell.js b/src/UI/System/Logs/Table/LogTimeCell.js index 1adbab10e..c82f87c39 100644 --- a/src/UI/System/Logs/Table/LogTimeCell.js +++ b/src/UI/System/Logs/Table/LogTimeCell.js @@ -9,7 +9,7 @@ module.exports = NzbDroneCell.extend({ render : function() { var dateStr = this._getValue(); var date = moment(dateStr); - var diff = date.diff(moment().zone(date.zone()).startOf('day'), 'days', true); + var diff = date.diff(moment().utcOffset(date.utcOffset()).startOf('day'), 'days', true); var result = '{1}'; var tooltip = date.format(UiSettings.longDateTime(true)); var text; @@ -28,4 +28,4 @@ module.exports = NzbDroneCell.extend({ return this; } -}); \ No newline at end of file +});