Fix pubdate parse error.
This commit is contained in:
parent
ec9836a432
commit
4aa53515e3
|
@ -473,17 +473,24 @@ class DBHelper {
|
||||||
try {
|
try {
|
||||||
date = DateFormat('EEE, dd MMM yyyy HH:mm Z', 'en_US').parse(pubDate);
|
date = DateFormat('EEE, dd MMM yyyy HH:mm Z', 'en_US').parse(pubDate);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//parse date using regex, still have issue in parse maonth/day
|
|
||||||
var year = yyyy.stringMatch(pubDate);
|
var year = yyyy.stringMatch(pubDate);
|
||||||
var time = hhmm.stringMatch(pubDate);
|
var time = hhmm.stringMatch(pubDate);
|
||||||
var month = ddmmm.stringMatch(pubDate);
|
var month = ddmmm.stringMatch(pubDate);
|
||||||
if (year != null && time != null && month != null) {
|
if (year != null && time != null && month != null) {
|
||||||
|
try {
|
||||||
date = DateFormat('dd MMM yyyy HH:mm', 'en_US')
|
date = DateFormat('dd MMM yyyy HH:mm', 'en_US')
|
||||||
.parse(month + year + time);
|
.parse('$month $year $time');
|
||||||
|
} catch (e) {
|
||||||
|
date = DateTime.now();
|
||||||
|
}
|
||||||
} else if (year != null && time != null && month == null) {
|
} else if (year != null && time != null && month == null) {
|
||||||
var month = mmDd.stringMatch(pubDate);
|
var month = mmDd.stringMatch(pubDate);
|
||||||
|
try {
|
||||||
date =
|
date =
|
||||||
DateFormat('yyyy-MM-dd HH:mm', 'en_US').parse('$month $time');
|
DateFormat('yyyy-MM-dd HH:mm', 'en_US').parse('$month $time');
|
||||||
|
} catch (e) {
|
||||||
|
date = DateTime.now();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
date = DateTime.now();
|
date = DateTime.now();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue