Dates use AirTime and UtcOffset when displaying

This commit is contained in:
Mark McDowall 2013-02-13 21:56:06 -06:00 committed by kay.one
parent 5930a15d3a
commit a04695a3e7
5 changed files with 35 additions and 2 deletions

View File

@ -59,7 +59,8 @@ namespace NzbDrone.Api
Mapper.CreateMap<Core.Repository.Series, SeriesResource>()
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.SeriesId))
.ForMember(dest => dest.CustomStartDate, opt => opt.ResolveUsing<NullableDatetimeToString>().FromMember(src => src.CustomStartDate))
.ForMember(dest => dest.BacklogSetting, opt => opt.MapFrom(src => (Int32)src.BacklogSetting));
.ForMember(dest => dest.BacklogSetting, opt => opt.MapFrom(src => (Int32)src.BacklogSetting))
.ForMember(dest => dest.NextAiring, opt => opt.ResolveUsing<NextAiringResolver>());
}
protected override ILifetimeScope GetApplicationContainer()

View File

@ -95,6 +95,7 @@
<Compile Include="Directories\DirectoryModule.cs" />
<Compile Include="Extentions\NancyJsonSerializer.cs" />
<Compile Include="Extentions\Serializer.cs" />
<Compile Include="Resolvers\NextAiringResolver.cs" />
<Compile Include="Resolvers\NullableDatetimeToString.cs" />
<Compile Include="RootFolders\RootFolderModule.cs" />
<Compile Include="Series\SeriesResource.cs" />

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using NzbDrone.Api.QualityProfiles;
using NzbDrone.Core.Repository.Quality;
namespace NzbDrone.Api.Resolvers
{
public class NextAiringResolver : ValueResolver<Core.Repository.Series, DateTime?>
{
protected override DateTime? ResolveCore(Core.Repository.Series source)
{
if(String.IsNullOrWhiteSpace(source.AirTime) || !source.NextAiring.HasValue)
return source.NextAiring;
return source.NextAiring.Value.Add(Convert.ToDateTime(source.AirTime).TimeOfDay)
.AddHours(source.UtcOffset * -1);
}
}
}

View File

@ -4,7 +4,7 @@
<td name="qualityProfileName"></td>
<td name="network"></td>
<!-- If only DT could access the backbone model -->
<td><span data-date="{{nextAiring}}">{{bestDateString}}</span></td>
<td><span title="{{formatedDateString}}" data-date="{{nextAiring}}">{{bestDateString}}</span></td>
<td>
<div class="progress">
<span class="progressbar-back-text">{{episodeFileCount}} / {{episodeCount}}</span>

View File

@ -18,6 +18,16 @@
return date.format('{MM}/{dd}/{yyyy}');
},
formatedDateString: function () {
var dateSource = this.get('nextAiring');
if (!dateSource) return '';
var date = Date.create(dateSource);
return date.format('{Weekday} {Month} {dd}, {yyyy} {12hr}:{mm} {TT}');
},
percentOfEpisodes: function () {
var episodeCount = this.get('episodeCount');
var episodeFileCount = this.get('episodeFileCount');