diff options
author | Shantana Hardy <shantana.hardy@gmail.com> | 2017-10-28 18:46:05 -0700 |
---|---|---|
committer | Shantana Hardy <shantana.hardy@gmail.com> | 2017-10-28 19:18:16 -0700 |
commit | bedf06ec0466d2a3b4d3ad9be9bb8acd7f5f841c (patch) | |
tree | 0c8dd689064c25bdf31b9b90052bfb911f2488a1 /core | |
parent | 90cc07c9bb7335e5b8a2e4035f11f111d0af76cc (diff) | |
download | AntennaPod-bedf06ec0466d2a3b4d3ad9be9bb8acd7f5f841c.zip |
Parse RSS pubDate fields containing "Sept"
Diffstat (limited to 'core')
-rw-r--r-- | core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java | 8 | ||||
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java b/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java index 8adcc41c5..ee90d9116 100644 --- a/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java +++ b/core/src/androidTest/java/de/danoeh/antennapod/core/tests/util/DateUtilsTest.java @@ -130,4 +130,12 @@ public class DateUtilsTest extends AndroidTestCase { Date actual = DateUtils.parse("Thu, 8 Oct 2014 09:00:00 GMT"); // actually a Wednesday assertEquals(expected, actual); } + + public void testParseDateWithBadAbbreviation() { + GregorianCalendar exp1 = new GregorianCalendar(2014, 8, 8, 0, 0, 0); + exp1.setTimeZone(TimeZone.getTimeZone("GMT")); + Date expected = new Date(exp1.getTimeInMillis()); + Date actual = DateUtils.parse("Mon, 8 Sept 2014 00:00:00 GMT"); // should be Sep + assertEquals(expected, actual); + } } diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java index f63f0983f..5056ea274 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/DateUtils.java @@ -31,6 +31,9 @@ public class DateUtils { date = date.replaceAll("CEST$", "+02:00"); date = date.replaceAll("CET$", "+01:00"); + // some generators use "Sept" for September + date = date.replaceAll("\\bSept\\b", "Sep"); + // if datetime is more precise than seconds, make sure the value is in ms if (date.contains(".")) { int start = date.indexOf('.'); |