Merge pull request #2474 from shantanahardy/develop

Parse RSS pubDate fields containing "Sept"
This commit is contained in:
Martin Fietz 2017-10-29 09:04:23 +01:00 committed by GitHub
commit 42cd7ea802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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('.');