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