From caa7deafb097eab2d49ad7515525a1cf42c6b830 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 27 Jan 2016 14:28:33 -0500 Subject: [PATCH] fix changing added value --- MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs | 10 +++++++--- MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index c5184ec3d..0fbf2fd11 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -215,7 +215,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { DateTime added; - if (DateTime.TryParse(val, out added)) + if (DateTime.TryParseExact(val, BaseNfoSaver.DateAddedFormat, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out added)) + { + item.EndDate = added.ToUniversalTime(); + } + else if (DateTime.TryParse(val, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out added)) { item.DateCreated = added.ToUniversalTime(); } @@ -976,11 +980,11 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val) && !string.IsNullOrWhiteSpace(userDataUserId)) { DateTime parsedValue; - if (DateTime.TryParseExact(val, "yyyy-MM-dd HH:mm:ss", _usCulture, DateTimeStyles.None, out parsedValue)) + if (DateTime.TryParseExact(val, "yyyy-MM-dd HH:mm:ss", _usCulture, DateTimeStyles.AssumeLocal, out parsedValue)) { var userData = GetOrAdd(itemResult, userDataUserId); - userData.LastPlayedDate = parsedValue; + userData.LastPlayedDate = parsedValue.ToUniversalTime(); } } break; diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index 6faa4ba66..ec12088b3 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -416,6 +416,8 @@ namespace MediaBrowser.XbmcMetadata.Savers writer.WriteEndElement(); } + public const string DateAddedFormat = "yyyy-MM-dd HH:mm:ss"; + /// /// Adds the common nodes. /// @@ -472,7 +474,7 @@ namespace MediaBrowser.XbmcMetadata.Savers writer.WriteElementString("type", item.DisplayMediaType); } - writer.WriteElementString("dateadded", item.DateCreated.ToString("yyyy-MM-dd HH:mm:ss")); + writer.WriteElementString("dateadded", item.DateCreated.ToLocalTime().ToString(DateAddedFormat)); writer.WriteElementString("title", item.Name ?? string.Empty); writer.WriteElementString("originaltitle", item.Name ?? string.Empty); @@ -949,7 +951,7 @@ namespace MediaBrowser.XbmcMetadata.Savers if (userdata.LastPlayedDate.HasValue) { - writer.WriteElementString("lastplayed", userdata.LastPlayedDate.Value.ToString("yyyy-MM-dd HH:mm:ss").ToLower()); + writer.WriteElementString("lastplayed", userdata.LastPlayedDate.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss").ToLower()); } writer.WriteStartElement("resume");