Remove logger parameter from XmlReaderExtensions.TryReadDateTime

This commit is contained in:
Patrick Barron 2023-10-06 16:56:50 -04:00
parent 1dd6442e89
commit 40e1c5f4c6
3 changed files with 9 additions and 19 deletions

View File

@ -5,7 +5,6 @@ using System.Linq;
using System.Xml;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Controller.Extensions;
@ -43,26 +42,17 @@ public static class XmlReaderExtensions
/// Parses a <see cref="DateTime"/> from the current node.
/// </summary>
/// <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>
/// <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(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 false;
return DateTime.TryParse(
reader.ReadElementContentAsString(),
CultureInfo.InvariantCulture,
DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal,
out value);
}
/// <summary>

View File

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

View File

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