fix changing added value

This commit is contained in:
Luke Pulverenti 2016-01-27 14:28:33 -05:00
parent f0adb2e891
commit 9dd55c15c0
2 changed files with 11 additions and 5 deletions

View File

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

View File

@ -416,6 +416,8 @@ namespace MediaBrowser.XbmcMetadata.Savers
writer.WriteEndElement();
}
public const string DateAddedFormat = "yyyy-MM-dd HH:mm:ss";
/// <summary>
/// Adds the common nodes.
/// </summary>
@ -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");