diff --git a/NzbDrone.Core.Test/IndexerTests/XElementExtensionsFixture.cs b/NzbDrone.Core.Test/IndexerTests/XElementExtensionsFixture.cs
new file mode 100644
index 000000000..d42a822d8
--- /dev/null
+++ b/NzbDrone.Core.Test/IndexerTests/XElementExtensionsFixture.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Xml.Linq;
+using FluentAssertions;
+using NUnit.Framework;
+using NzbDrone.Core.Indexers;
+using NzbDrone.Test.Common;
+
+namespace NzbDrone.Core.Test.IndexerTests
+{
+ [TestFixture]
+ public class XElementExtensionsFixture : TestBase
+ {
+ [TestCase("Wed, 07 Aug 2013 20:37:48 +0000")]
+ [TestCase("Wed, 07 Aug 2013 18:08:46 MST")]
+ public void should_parse_date(string dateString)
+ {
+ var element = new XElement("root");
+ element.Add(new XElement("pubDate", dateString));
+
+ var date = element.PublishDate();
+ date.Year.Should().Be(2013);
+ date.Kind.Should().Be(DateTimeKind.Utc);
+ }
+ }
+}
diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 16f498630..63781f0db 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -123,6 +123,7 @@
+
diff --git a/NzbDrone.Core/Indexers/XElementExtensions.cs b/NzbDrone.Core/Indexers/XElementExtensions.cs
index c80e606f3..8460c34d6 100644
--- a/NzbDrone.Core/Indexers/XElementExtensions.cs
+++ b/NzbDrone.Core/Indexers/XElementExtensions.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
+using System.Text.RegularExpressions;
using System.Xml.Linq;
using NLog;
@@ -11,6 +13,8 @@ public static class XElementExtensions
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+ private static readonly Regex RemoveTimeZoneRegex = new Regex(@"\s[A-Z]{2,4}$", RegexOptions.Compiled);
+
public static string Title(this XElement item)
{
return item.TryGetValue("title", "Unknown");
@@ -22,7 +26,13 @@ public static DateTime PublishDate(this XElement item)
try
{
- return DateTime.Parse(dateString);
+ DateTime result;
+ if (!DateTime.TryParse(dateString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal, out result))
+ {
+ dateString = RemoveTimeZoneRegex.Replace(dateString, "");
+ result = DateTime.Parse(dateString, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AdjustToUniversal);
+ }
+ return result.ToUniversalTime();
}
catch (FormatException e)
{