switch to DateTimeOffset

This commit is contained in:
Luke Pulverenti
2018-09-07 15:22:39 -04:00
parent 07c5c2f9aa
commit 46ea3e4c21
5 changed files with 39 additions and 51 deletions
@@ -37,35 +37,4 @@ namespace MediaBrowser.Plugins.VuPlus.Helpers
} }
} }
public static class RecordingHelper
{
}
public static class ApiHelper
{
private static readonly DateTime UnixEpoch =
new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public static long GetCurrentUnixTimestampMillis()
{
return (long)(DateTime.UtcNow - UnixEpoch).TotalMilliseconds;
}
public static DateTime DateTimeFromUnixTimestampMillis(long millis)
{
return UnixEpoch.AddMilliseconds(millis);
}
public static long GetCurrentUnixTimestampSeconds(DateTime date)
{
return (long)(date - UnixEpoch).TotalSeconds;
}
public static DateTime DateTimeFromUnixTimestampSeconds(long seconds)
{
return UnixEpoch.AddSeconds(seconds);
}
}
} }
+8 -8
View File
@@ -43,7 +43,7 @@ namespace MediaBrowser.Plugins.VuPlus
private String tvBouquetSRef; private String tvBouquetSRef;
List<ChannelInfo> tvChannelInfos = new List<ChannelInfo>(); List<ChannelInfo> tvChannelInfos = new List<ChannelInfo>();
public DateTime LastRecordingChange = DateTime.MinValue; public DateTimeOffset LastRecordingChange = DateTimeOffset.MinValue;
public LiveTvService(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogger logger) public LiveTvService(IHttpClient httpClient, IJsonSerializer jsonSerializer, ILogger logger)
{ {
@@ -675,7 +675,7 @@ namespace MediaBrowser.Plugins.VuPlus
recordingInfo.CommunityRating = 0; recordingInfo.CommunityRating = 0;
long sdated = Int64.Parse(e2time); long sdated = Int64.Parse(e2time);
DateTime sdate = ApiHelper.DateTimeFromUnixTimestampSeconds(sdated); var sdate = DateTimeOffset.FromUnixTimeSeconds(sdated);
recordingInfo.StartDate = sdate.ToUniversalTime(); recordingInfo.StartDate = sdate.ToUniversalTime();
//length in format mm:ss //length in format mm:ss
@@ -683,7 +683,7 @@ namespace MediaBrowser.Plugins.VuPlus
long mins = Int64.Parse(words[0]); long mins = Int64.Parse(words[0]);
long seconds = Int64.Parse(words[1]); long seconds = Int64.Parse(words[1]);
long edated = Int64.Parse(e2time) + (mins * 60) + (seconds); long edated = Int64.Parse(e2time) + (mins * 60) + (seconds);
DateTime edate = ApiHelper.DateTimeFromUnixTimestampSeconds(edated); var edate = DateTimeOffset.FromUnixTimeSeconds(edated);
recordingInfo.EndDate = edate.ToUniversalTime(); recordingInfo.EndDate = edate.ToUniversalTime();
//recordingInfo.EpisodeTitle = e2title; //recordingInfo.EpisodeTitle = e2title;
@@ -1098,7 +1098,7 @@ namespace MediaBrowser.Plugins.VuPlus
timerInfo.ChannelId = e2servicereference; timerInfo.ChannelId = e2servicereference;
long edated = Int64.Parse(e2timeend); long edated = Int64.Parse(e2timeend);
DateTime edate = ApiHelper.DateTimeFromUnixTimestampSeconds(edated); var edate = DateTimeOffset.FromUnixTimeSeconds(edated);
timerInfo.EndDate = edate.ToUniversalTime(); timerInfo.EndDate = edate.ToUniversalTime();
timerInfo.Id = e2servicereference + "~" + e2eit + "~" + e2timebegin + "~" + e2timeend + "~" + count; timerInfo.Id = e2servicereference + "~" + e2eit + "~" + e2timebegin + "~" + e2timeend + "~" + count;
@@ -1114,7 +1114,7 @@ namespace MediaBrowser.Plugins.VuPlus
timerInfo.SeriesTimerId = null; timerInfo.SeriesTimerId = null;
long sdated = Int64.Parse(e2timebegin); long sdated = Int64.Parse(e2timebegin);
DateTime sdate = ApiHelper.DateTimeFromUnixTimestampSeconds(sdated); var sdate = DateTimeOffset.FromUnixTimeSeconds(sdated);
timerInfo.StartDate = sdate.ToUniversalTime(); timerInfo.StartDate = sdate.ToUniversalTime();
if (e2state == "0") if (e2state == "0")
@@ -1316,7 +1316,7 @@ namespace MediaBrowser.Plugins.VuPlus
/// <param name="endDateUtc">end date/time</param> /// <param name="endDateUtc">end date/time</param>
/// <param name="cancellationToken">The CancellationToken</param> /// <param name="cancellationToken">The CancellationToken</param>
/// <returns>IEnumerable<ProgramInfo></returns> /// <returns>IEnumerable<ProgramInfo></returns>
public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken) public async Task<IEnumerable<ProgramInfo>> GetProgramsAsync(string channelId, DateTimeOffset startDateUtc, DateTimeOffset endDateUtc, CancellationToken cancellationToken)
{ {
_logger.Info("[VuPlus] Start GetProgramsAsync"); _logger.Info("[VuPlus] Start GetProgramsAsync");
await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false); await EnsureConnectionAsync(cancellationToken).ConfigureAwait(false);
@@ -1420,7 +1420,7 @@ namespace MediaBrowser.Plugins.VuPlus
} }
long sdated = Int64.Parse(e2eventstart); long sdated = Int64.Parse(e2eventstart);
DateTime sdate = ApiHelper.DateTimeFromUnixTimestampSeconds(sdated); var sdate = DateTimeOffset.FromUnixTimeSeconds(sdated);
// Check whether the current element is within the time range passed // Check whether the current element is within the time range passed
if (sdate > endDateUtc) if (sdate > endDateUtc)
@@ -1463,7 +1463,7 @@ namespace MediaBrowser.Plugins.VuPlus
programInfo.Overview = e2eventdescriptionextended; programInfo.Overview = e2eventdescriptionextended;
long edated = Int64.Parse(e2eventstart) + Int64.Parse(e2eventduration); long edated = Int64.Parse(e2eventstart) + Int64.Parse(e2eventduration);
DateTime edate = ApiHelper.DateTimeFromUnixTimestampSeconds(edated); var edate = DateTimeOffset.FromUnixTimeSeconds(edated);
programInfo.StartDate = sdate.ToUniversalTime(); programInfo.StartDate = sdate.ToUniversalTime();
programInfo.EndDate = edate.ToUniversalTime(); programInfo.EndDate = edate.ToUniversalTime();
@@ -1,21 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks> <TargetFrameworks>netstandard2.0;</TargetFrameworks>
<AssemblyVersion>3.1.8</AssemblyVersion> <AssemblyVersion>3.1.9</AssemblyVersion>
<FileVersion>3.1.8</FileVersion> <FileVersion>3.1.9</FileVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="Configuration\configPage.html" /> <None Remove="Configuration\configPage.html" />
<None Remove="Images\thumb.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="Configuration\configPage.html" /> <EmbeddedResource Include="Configuration\configPage.html" />
<EmbeddedResource Include="Images\thumb.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="mediabrowser.server.core" Version="3.3.28" /> <PackageReference Include="mediabrowser.server.core" Version="3.6.0.36-beta" />
<PackageReference Include="System.Memory" Version="4.5.1" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+17 -1
View File
@@ -5,13 +5,15 @@ using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
using MediaBrowser.Plugins.VuPlus.Configuration; using MediaBrowser.Plugins.VuPlus.Configuration;
using System.IO;
using MediaBrowser.Model.Drawing;
namespace MediaBrowser.Plugins.VuPlus namespace MediaBrowser.Plugins.VuPlus
{ {
/// <summary> /// <summary>
/// Class Plugin /// Class Plugin
/// </summary> /// </summary>
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages, IHasThumbImage
{ {
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
: base(applicationPaths, xmlSerializer) : base(applicationPaths, xmlSerializer)
@@ -63,5 +65,19 @@ namespace MediaBrowser.Plugins.VuPlus
} }
}; };
} }
public Stream GetThumbImage()
{
var type = GetType();
return type.Assembly.GetManifestResourceStream(type.Namespace + ".Images.thumb.png");
}
public ImageFormat ThumbImageFormat
{
get
{
return ImageFormat.Png;
}
}
} }
} }
@@ -71,7 +71,7 @@ namespace MediaBrowser.Plugins.VuPlus
public string GetCacheKey(string userId) public string GetCacheKey(string userId)
{ {
var now = DateTime.UtcNow; var now = DateTimeOffset.UtcNow;
var values = new List<string>(); var values = new List<string>();
@@ -113,7 +113,7 @@ namespace MediaBrowser.Plugins.VuPlus
{ {
return Task.FromResult(new DynamicImageResponse return Task.FromResult(new DynamicImageResponse
{ {
Path = "https://github.com/CompoUK/MediaBrowser.Plugins.VuPlus/blob/master/src/Images/Vu+.png?raw=true", Path = "https://github.com/MediaBrowser/MediaBrowser.Plugins.VuPlus/raw/master/MediaBrowser.Plugins.VuPlus/Images/thumb.png",
Protocol = MediaProtocol.Http, Protocol = MediaProtocol.Http,
HasImage = true HasImage = true
}); });
@@ -157,7 +157,7 @@ namespace MediaBrowser.Plugins.VuPlus
{ {
var result = await GetChannelItems(new InternalChannelItemQuery(), i => true, cancellationToken).ConfigureAwait(false); var result = await GetChannelItems(new InternalChannelItemQuery(), i => true, cancellationToken).ConfigureAwait(false);
return result.Items.OrderByDescending(i => i.DateCreated ?? DateTime.MinValue); return result.Items.OrderByDescending(i => i.DateCreated ?? DateTimeOffset.MinValue);
} }
public Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken) public Task<ChannelItemResult> GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken)
@@ -410,12 +410,12 @@ namespace MediaBrowser.Plugins.VuPlus
/// <summary> /// <summary>
/// The start date of the recording, in UTC. /// The start date of the recording, in UTC.
/// </summary> /// </summary>
public DateTime StartDate { get; set; } public DateTimeOffset StartDate { get; set; }
/// <summary> /// <summary>
/// The end date of the recording, in UTC. /// The end date of the recording, in UTC.
/// </summary> /// </summary>
public DateTime EndDate { get; set; } public DateTimeOffset EndDate { get; set; }
/// <summary> /// <summary>
/// Gets or sets the program identifier. /// Gets or sets the program identifier.
@@ -462,7 +462,7 @@ namespace MediaBrowser.Plugins.VuPlus
/// Gets or sets the original air date. /// Gets or sets the original air date.
/// </summary> /// </summary>
/// <value>The original air date.</value> /// <value>The original air date.</value>
public DateTime? OriginalAirDate { get; set; } public DateTimeOffset? OriginalAirDate { get; set; }
/// <summary> /// <summary>
/// Gets or sets a value indicating whether this instance is movie. /// Gets or sets a value indicating whether this instance is movie.
@@ -545,7 +545,7 @@ namespace MediaBrowser.Plugins.VuPlus
/// Gets or sets the date last updated. /// Gets or sets the date last updated.
/// </summary> /// </summary>
/// <value>The date last updated.</value> /// <value>The date last updated.</value>
public DateTime DateLastUpdated { get; set; } public DateTimeOffset DateLastUpdated { get; set; }
public MyRecordingInfo() public MyRecordingInfo()
{ {