Added AirDateUtc for UTC offset time

pull/4/head
Mark McDowall 12 years ago
parent 7689b50dee
commit eb5a15a8ca

@ -12,6 +12,7 @@ namespace NzbDrone.Api.Episodes
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; }

@ -22,7 +22,6 @@ namespace NzbDrone.Api.Series
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; }

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

@ -69,7 +69,8 @@ namespace NzbDrone.Core.MetadataSource
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;
}

@ -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" />

@ -17,7 +17,7 @@ namespace NzbDrone.Core.Parser.Model
public bool IsRecentEpisode()
{
return Episodes.Any(e => e.AirDate >= DateTime.Today.AddDays(-14));
return Episodes.Any(e => e.AirDateUtc >= DateTime.Today.AddDays(-14));
}
}
}

@ -16,6 +16,7 @@ namespace NzbDrone.Core.Tv
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; }

@ -106,8 +106,8 @@ namespace NzbDrone.Core.Tv
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 @@ namespace NzbDrone.Core.Tv
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())

@ -148,6 +148,7 @@ namespace NzbDrone.Core.Tv
episodeToUpdate.Title = episode.Title;
episodeToUpdate.Overview = episode.Overview;
episodeToUpdate.AirDate = episode.AirDate;
episodeToUpdate.AirDateUtc = episode.AirDateUtc;
successCount++;
}

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save