diff --git a/NzbDrone.Api/Episodes/EpisodeResource.cs b/NzbDrone.Api/Episodes/EpisodeResource.cs index 8b97f5a4e..f81b5f075 100644 --- a/NzbDrone.Api/Episodes/EpisodeResource.cs +++ b/NzbDrone.Api/Episodes/EpisodeResource.cs @@ -12,6 +12,7 @@ public class EpisodeResource : RestResource public Int32 EpisodeNumber { get; set; } public String Title { get; set; } public DateTime? AirDate { get; set; } + public DateTime? AirDateUtc { get; set; } public String Overview { get; set; } public EpisodeFile EpisodeFile { get; set; } diff --git a/NzbDrone.Api/Series/SeriesResource.cs b/NzbDrone.Api/Series/SeriesResource.cs index 4de8a4687..5b0ef2641 100644 --- a/NzbDrone.Api/Series/SeriesResource.cs +++ b/NzbDrone.Api/Series/SeriesResource.cs @@ -22,7 +22,6 @@ public class SeriesResource : RestResource public DateTime? NextAiring { get; set; } public String Network { get; set; } public String AirTime { get; set; } - public Int32 UtcOffset { get; set; } public List Images { get; set; } public String RemotePoster { get; set; } diff --git a/NzbDrone.Core/Datastore/Migration/013_add_air_date_utc.cs b/NzbDrone.Core/Datastore/Migration/013_add_air_date_utc.cs new file mode 100644 index 000000000..3a0a148c8 --- /dev/null +++ b/NzbDrone.Core/Datastore/Migration/013_add_air_date_utc.cs @@ -0,0 +1,17 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Tags("")] + [Migration(13)] + public class add_air_date_utc : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("Episodes").AddColumn("AirDateUtc").AsDateTime().Nullable(); + + Execute.Sql("UPDATE Episodes SET AirDateUtc = AirDate"); + } + } +} diff --git a/NzbDrone.Core/MetadataSource/TraktProxy.cs b/NzbDrone.Core/MetadataSource/TraktProxy.cs index 9f56bcd84..ead507936 100644 --- a/NzbDrone.Core/MetadataSource/TraktProxy.cs +++ b/NzbDrone.Core/MetadataSource/TraktProxy.cs @@ -69,7 +69,8 @@ private static Episode MapEpisode(Trakt.Episode traktEpisode) episode.EpisodeNumber = traktEpisode.number; episode.TvDbEpisodeId = traktEpisode.tvdb_id; episode.Title = traktEpisode.title; - episode.AirDate = FromIso(traktEpisode.first_aired_iso); + episode.AirDate = FromEpoch(traktEpisode.first_aired); + episode.AirDateUtc = FromIso(traktEpisode.first_aired_iso); return episode; } diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 132a8d089..9deaeec44 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -213,6 +213,7 @@ + diff --git a/NzbDrone.Core/Parser/Model/RemoteEpisode.cs b/NzbDrone.Core/Parser/Model/RemoteEpisode.cs index 703d6fae3..4632ba00e 100644 --- a/NzbDrone.Core/Parser/Model/RemoteEpisode.cs +++ b/NzbDrone.Core/Parser/Model/RemoteEpisode.cs @@ -17,7 +17,7 @@ public class RemoteEpisode public bool IsRecentEpisode() { - return Episodes.Any(e => e.AirDate >= DateTime.Today.AddDays(-14)); + return Episodes.Any(e => e.AirDateUtc >= DateTime.Today.AddDays(-14)); } } } \ No newline at end of file diff --git a/NzbDrone.Core/Tv/Episode.cs b/NzbDrone.Core/Tv/Episode.cs index 09be230e4..2afaaba10 100644 --- a/NzbDrone.Core/Tv/Episode.cs +++ b/NzbDrone.Core/Tv/Episode.cs @@ -16,6 +16,7 @@ public class Episode : ModelBase public int EpisodeNumber { get; set; } public string Title { get; set; } public DateTime? AirDate { get; set; } + public DateTime? AirDateUtc { get; set; } public string Overview { get; set; } public Boolean Monitored { get; set; } diff --git a/NzbDrone.Core/Tv/EpisodeRepository.cs b/NzbDrone.Core/Tv/EpisodeRepository.cs index b7545cd21..006d26ef1 100644 --- a/NzbDrone.Core/Tv/EpisodeRepository.cs +++ b/NzbDrone.Core/Tv/EpisodeRepository.cs @@ -106,8 +106,8 @@ public List EpisodesWithFiles() public List EpisodesBetweenDates(DateTime startDate, DateTime endDate) { return Query.Join(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id) - .Where(e => e.AirDate >= startDate) - .AndWhere(e => e.AirDate <= endDate) + .Where(e => e.AirDateUtc >= startDate) + .AndWhere(e => e.AirDateUtc <= endDate) .AndWhere(e => e.Monitored) .AndWhere(e => e.Series.Monitored) .ToList(); @@ -145,7 +145,7 @@ private SortBuilder GetEpisodesWithoutFilesQuery(PagingSpec pa return Query.Join(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id) .Where(e => e.EpisodeFileId == 0) .AndWhere(e => e.SeasonNumber >= startingSeasonNumber) - .AndWhere(e => e.AirDate <= currentTime) + .AndWhere(e => e.AirDateUtc <= currentTime) .AndWhere(e => e.Monitored) .AndWhere(e => e.Series.Monitored) .OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection()) diff --git a/NzbDrone.Core/Tv/RefreshSeriesService.cs b/NzbDrone.Core/Tv/RefreshSeriesService.cs index ea83a12c9..85650608a 100644 --- a/NzbDrone.Core/Tv/RefreshSeriesService.cs +++ b/NzbDrone.Core/Tv/RefreshSeriesService.cs @@ -148,6 +148,7 @@ private void RefreshEpisodeInfo(Series series, IEnumerable remoteEpisod episodeToUpdate.Title = episode.Title; episodeToUpdate.Overview = episode.Overview; episodeToUpdate.AirDate = episode.AirDate; + episodeToUpdate.AirDateUtc = episode.AirDateUtc; successCount++; } diff --git a/UI/Calendar/CalendarView.js b/UI/Calendar/CalendarView.js index f6e897f05..c8d8bb4fb 100644 --- a/UI/Calendar/CalendarView.js +++ b/UI/Calendar/CalendarView.js @@ -58,7 +58,7 @@ define( _.each(calendarCollection.models, function (element) { var episodeTitle = element.get('title'); var seriesTitle = element.get('series').get('title'); - var start = element.get('airDate'); + var start = element.get('airDateUtc'); var statusLevel = _instance.getStatusLevel(element); element.set({ @@ -80,7 +80,7 @@ define( getStatusLevel: function (element) { var hasFile = element.get('hasFile'); var currentTime = Moment(); - var start = Moment(element.get('airDate')); + var start = Moment(element.get('airDateUtc')); var end = Moment(element.get('end')); var statusLevel = 'primary'; diff --git a/UI/Calendar/Collection.js b/UI/Calendar/Collection.js index 64121cc54..41efd7979 100644 --- a/UI/Calendar/Collection.js +++ b/UI/Calendar/Collection.js @@ -9,7 +9,7 @@ define( model: EpisodeModel, comparator: function (model) { - var date = new Date(model.get('airDate')); + var date = new Date(model.get('airDateUtc')); var time = date.getTime(); return time; } diff --git a/UI/Calendar/UpcomingCollection.js b/UI/Calendar/UpcomingCollection.js index a7e3ba58a..fdc7d58a0 100644 --- a/UI/Calendar/UpcomingCollection.js +++ b/UI/Calendar/UpcomingCollection.js @@ -10,11 +10,11 @@ define( model: EpisodeModel, comparator: function (model1, model2) { - var airDate1 = model1.get('airDate'); + var airDate1 = model1.get('airDateUtc'); var date1 = Moment(airDate1); var time1 = date1.unix(); - var airDate2 = model2.get('airDate'); + var airDate2 = model2.get('airDateUtc'); var date2 = Moment(airDate2); var time2 = date2.unix(); diff --git a/UI/Calendar/UpcomingItemTemplate.html b/UI/Calendar/UpcomingItemTemplate.html index af4490153..bfb5daca1 100644 --- a/UI/Calendar/UpcomingItemTemplate.html +++ b/UI/Calendar/UpcomingItemTemplate.html @@ -1,13 +1,13 @@ 
-

{{Day airDate}}

-

{{Month airDate}}

+

{{Day airDateUtc}}

+

{{Month airDateUtc}}

{{#with series}}

{{title}}

{{/with}} -

{{StartTime airDate}} {{ShortDate airDate}}{{seasonNumber}}x{{Pad2 episodeNumber}}
{{episodeTitle}}

+

{{StartTime airDateUtc}} {{ShortDate airDateUtc}}{{seasonNumber}}x{{Pad2 episodeNumber}}
{{episodeTitle}}

{{title}}

diff --git a/UI/Cells/EpisodeNumberCell.js b/UI/Cells/EpisodeNumberCell.js index f51589f51..b72720de1 100644 --- a/UI/Cells/EpisodeNumberCell.js +++ b/UI/Cells/EpisodeNumberCell.js @@ -13,7 +13,7 @@ define( this.$el.empty(); - var airDateField = this.column.get('airDate') || 'airDate'; + var airDateField = this.column.get('airDateUtc') || 'airDateUtc'; var seasonField = this.column.get('seasonNumber') || 'seasonNumber'; var episodeField = this.column.get('episodes') || 'episodeNumber'; diff --git a/UI/Handlebars/Helpers/Episode.js b/UI/Handlebars/Helpers/Episode.js index c9acf9e0c..463d37eb3 100644 --- a/UI/Handlebars/Helpers/Episode.js +++ b/UI/Handlebars/Helpers/Episode.js @@ -8,7 +8,7 @@ define( Handlebars.registerHelper('EpisodeNumber', function () { if (this.series.seriesType === 'daily') { - return Moment(this.airDate).format('L'); + return Moment(this.airDateUtc).format('L'); } else { @@ -21,7 +21,7 @@ define( var hasFile = this.hasFile; var currentTime = Moment(); - var start = Moment(this.airDate); + var start = Moment(this.airDateUtc); var end = Moment(this.end); if (currentTime.isAfter(start) && currentTime.isBefore(end)) { diff --git a/UI/Missing/Collection.js b/UI/Missing/Collection.js index 3ffdcdcdd..7ef9f627f 100644 --- a/UI/Missing/Collection.js +++ b/UI/Missing/Collection.js @@ -10,7 +10,7 @@ define( state: { pageSize: 15, - sortKey : 'airDate', + sortKey : 'airDateUtc', order : 1 }, diff --git a/UI/Series/Details/SeasonLayout.js b/UI/Series/Details/SeasonLayout.js index 9d9cc276b..e35c59711 100644 --- a/UI/Series/Details/SeasonLayout.js +++ b/UI/Series/Details/SeasonLayout.js @@ -54,7 +54,7 @@ define( sortable: false }, { - name : 'airDate', + name : 'airDateUtc', label: 'Air Date', cell : AirDateCell } , diff --git a/UI/Series/EpisodeModel.js b/UI/Series/EpisodeModel.js index 8f64780ce..bdfaeedab 100644 --- a/UI/Series/EpisodeModel.js +++ b/UI/Series/EpisodeModel.js @@ -9,7 +9,7 @@ define( initialize: function () { if (this.has('series')) { - var start = Moment(this.get('airDate')); + var start = Moment(this.get('airDateUtc')); var runtime = this.get('series').get('runtime'); this.set('end', start.add('minutes', runtime));