Remove logger parameter from XmlReaderExtensions.TryReadDateTime

pull/10352/head
Patrick Barron 1 year ago
parent 1dd6442e89
commit 40e1c5f4c6

@ -5,7 +5,6 @@ using System.Linq;
using System.Xml; using System.Xml;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Controller.Extensions; namespace MediaBrowser.Controller.Extensions;
@ -43,26 +42,17 @@ public static class XmlReaderExtensions
/// Parses a <see cref="DateTime"/> from the current node. /// Parses a <see cref="DateTime"/> from the current node.
/// </summary> /// </summary>
/// <param name="reader">The <see cref="XmlReader"/>.</param> /// <param name="reader">The <see cref="XmlReader"/>.</param>
/// <param name="logger">The <see cref="ILogger"/> to use on failure.</param>
/// <param name="value">The parsed <see cref="DateTime"/>.</param> /// <param name="value">The parsed <see cref="DateTime"/>.</param>
/// <returns>A value indicating whether the parsing succeeded.</returns> /// <returns>A value indicating whether the parsing succeeded.</returns>
public static bool TryReadDateTime(this XmlReader reader, ILogger logger, out DateTime value) public static bool TryReadDateTime(this XmlReader reader, out DateTime value)
{ {
ArgumentNullException.ThrowIfNull(reader); ArgumentNullException.ThrowIfNull(reader);
ArgumentNullException.ThrowIfNull(logger);
var text = reader.ReadElementContentAsString();
if (DateTime.TryParse(
text,
CultureInfo.InvariantCulture,
DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal,
out value))
{
return true;
}
logger.LogWarning("Invalid date: {Date}", text); return DateTime.TryParse(
return false; reader.ReadElementContentAsString(),
CultureInfo.InvariantCulture,
DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal,
out value);
} }
/// <summary> /// <summary>

@ -130,7 +130,7 @@ namespace MediaBrowser.LocalMetadata.Parsers
switch (reader.Name) switch (reader.Name)
{ {
case "Added": case "Added":
if (reader.TryReadDateTime(Logger, out var dateCreated)) if (reader.TryReadDateTime(out var dateCreated))
{ {
item.DateCreated = dateCreated; item.DateCreated = dateCreated;
} }

@ -268,7 +268,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
switch (reader.Name) switch (reader.Name)
{ {
case "dateadded": case "dateadded":
if (reader.TryReadDateTime(Logger, out var dateCreated)) if (reader.TryReadDateTime(out var dateCreated))
{ {
item.DateCreated = dateCreated; item.DateCreated = dateCreated;
} }
@ -327,7 +327,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
break; break;
case "lastplayed": case "lastplayed":
if (reader.TryReadDateTime(Logger, out var lastPlayed) if (reader.TryReadDateTime(out var lastPlayed)
&& Guid.TryParse(nfoConfiguration.UserId, out var lastPlayedUserId)) && Guid.TryParse(nfoConfiguration.UserId, out var lastPlayedUserId))
{ {
var user = _userManager.GetUserById(lastPlayedUserId); var user = _userManager.GetUserById(lastPlayedUserId);

Loading…
Cancel
Save