1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

Added AirDateUtc for UTC offset time

This commit is contained in:
Mark McDowall 2013-07-23 22:28:06 -07:00
parent 7689b50dee
commit eb5a15a8ca
18 changed files with 41 additions and 20 deletions

View File

@ -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; }

View File

@ -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<Core.MediaCover.MediaCover> Images { get; set; }
public String RemotePoster { get; set; }

View File

@ -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");
}
}
}

View File

@ -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;
}

View File

@ -213,6 +213,7 @@
<Compile Include="Datastore\Migration\010_add_monitored.cs" />
<Compile Include="Datastore\Migration\011_remove_ignored.cs" />
<Compile Include="Datastore\Migration\012_remove_custom_start_date.cs" />
<Compile Include="Datastore\Migration\013_add_air_date_utc.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />

View File

@ -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));
}
}
}

View File

@ -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; }

View File

@ -106,8 +106,8 @@ public List<Episode> EpisodesWithFiles()
public List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate)
{
return Query.Join<Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id)
.Where<Episode>(e => e.AirDate >= startDate)
.AndWhere(e => e.AirDate <= endDate)
.Where<Episode>(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<Episode> GetEpisodesWithoutFilesQuery(PagingSpec<Episode> pa
return Query.Join<Episode, Series>(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())

View File

@ -148,6 +148,7 @@ private void RefreshEpisodeInfo(Series series, IEnumerable<Episode> remoteEpisod
episodeToUpdate.Title = episode.Title;
episodeToUpdate.Overview = episode.Overview;
episodeToUpdate.AirDate = episode.AirDate;
episodeToUpdate.AirDateUtc = episode.AirDateUtc;
successCount++;
}

View File

@ -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';

View File

@ -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;
}

View File

@ -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();

View File

@ -1,13 +1,13 @@
<div class="event">
<div class="date {{StatusLevel}}">
<h1>{{Day airDate}}</h1>
<h4>{{Month airDate}}</h4>
<h1>{{Day airDateUtc}}</h1>
<h4>{{Month airDateUtc}}</h4>
</div>
{{#with series}}
<a href="{{route}}">
<h4>{{title}}</h4>
</a>
{{/with}}
<p>{{StartTime airDate}} {{ShortDate airDate}}<span class="pull-right">{{seasonNumber}}x{{Pad2 episodeNumber}}</span><br>{{episodeTitle}}</p>
<p>{{StartTime airDateUtc}} {{ShortDate airDateUtc}}<span class="pull-right">{{seasonNumber}}x{{Pad2 episodeNumber}}</span><br>{{episodeTitle}}</p>
<p class="episode-title x-episode-title">{{title}}</p>
</div>

View File

@ -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';

View File

@ -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)) {

View File

@ -10,7 +10,7 @@ define(
state: {
pageSize: 15,
sortKey : 'airDate',
sortKey : 'airDateUtc',
order : 1
},

View File

@ -54,7 +54,7 @@ define(
sortable: false
},
{
name : 'airDate',
name : 'airDateUtc',
label: 'Air Date',
cell : AirDateCell
} ,

View File

@ -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));