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) {
|
||||||
date = DateFormat('dd MMM yyyy HH:mm', 'en_US')
|
try {
|
||||||
.parse(month + year + time);
|
date = DateFormat('dd MMM yyyy HH:mm', 'en_US')
|
||||||
|
.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);
|
||||||
date =
|
try {
|
||||||
DateFormat('yyyy-MM-dd HH:mm', 'en_US').parse('$month $time');
|
date =
|
||||||
|
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