Skip to content

Commit

Permalink
MP2-543: Fixed more date parsing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
morpheusxx committed Jan 11, 2017
1 parent 896789a commit f78ad31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 5 additions & 4 deletions TvEngine3/TVLibrary/Plugins/TvMovie/TvMovieDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Data;
using System.Data.OleDb;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -363,8 +364,8 @@ public bool NeedsImport
try
{
TimeSpan restTime = new TimeSpan(Convert.ToInt32(TvBLayer.GetSetting("TvMovieRestPeriod", "24").Value), 0, 0);
DateTime lastUpdated = Convert.ToDateTime(TvBLayer.GetSetting("TvMovieLastUpdate", "0").Value);
// if (Convert.ToInt64(TvBLayer.GetSetting("TvMovieLastUpdate", "0").Value) == LastUpdate)
DateTime lastUpdated;
DateTime.TryParse(TvBLayer.GetSetting("TvMovieLastUpdate", "").Value, CultureInfo.InvariantCulture, DateTimeStyles.None, out lastUpdated);
if (lastUpdated >= (DateTime.Now - restTime))
{
return false;
Expand Down Expand Up @@ -416,7 +417,7 @@ public void Import()
// setting update time of epg import to avoid that the background thread triggers another import
// if the process lasts longer than the timer's update check interval
Setting setting = TvBLayer.GetSetting("TvMovieLastUpdate");
setting.Value = DateTime.Now.ToString();
setting.Value = DateTime.Now.ToString(CultureInfo.InvariantCulture);
setting.Persist();

Log.Debug("TVMovie: Mapped {0} stations for EPG import", Convert.ToString(maximum));
Expand Down Expand Up @@ -490,7 +491,7 @@ public void Import()
try
{
setting = TvBLayer.GetSetting("TvMovieLastUpdate");
setting.Value = DateTime.Now.ToString();
setting.Value = DateTime.Now.ToString(CultureInfo.InvariantCulture);
setting.Persist();

TimeSpan ImportDuration = (DateTime.Now - ImportStartTime);
Expand Down
6 changes: 4 additions & 2 deletions TvEngine3/TVLibrary/TvLibrary.Utils/Time/WorldDateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class WorldDateTime : IComparable

#region Variables

public static readonly DateTime EPOCH_START_TIME = new DateTime(1970, 1, 1, 12, 0, 0);

//private DateTime _dt;
private int _year;
private int _month;
Expand Down Expand Up @@ -349,7 +351,7 @@ public long ToEpochTime()
DateTime dt = this.DateTime;
if (_timeZone != null)
dt = _timeZone.ToUniversalTime(dt);
DateTime dtEpochStartTime = Convert.ToDateTime("1/1/1970 12:00:00 AM");
DateTime dtEpochStartTime = EPOCH_START_TIME;
TimeSpan ts = dt.Subtract(dtEpochStartTime);

//long epochtime = ((((((ts.Days * 24) + ts.Hours) * 60) + ts.Minutes) * 60) + ts.Seconds);
Expand All @@ -362,7 +364,7 @@ public long ToEpochDate()
DateTime dt = this.DateTime;
if (_timeZone != null)
dt = _timeZone.ToUniversalTime(dt);
DateTime dtEpochStartTime = Convert.ToDateTime("1/1/1970 12:00:00 AM");
DateTime dtEpochStartTime = EPOCH_START_TIME;
TimeSpan ts = dt.Subtract(dtEpochStartTime);

return ts.Days;
Expand Down

0 comments on commit f78ad31

Please sign in to comment.