mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-02 18:36:49 +01:00
Work on parsing dates, still not done.
This commit is contained in:
parent
b4d5c0983b
commit
710d36440a
@ -322,8 +322,7 @@ bool FeedsModelStandardFeed::removeItself() {
|
||||
}
|
||||
|
||||
void FeedsModelStandardFeed::updateMessages(const QList<Message> &messages) {
|
||||
int feed_id = id(), message_id;
|
||||
qint64 message_creation_date;
|
||||
int feed_id = id();
|
||||
QSqlDatabase database = DatabaseFactory::instance()->connection("FeedsModelStandardFeed",
|
||||
DatabaseFactory::FromSettings);
|
||||
|
||||
|
12
src/core/parsingfactory.cpp
Normal file → Executable file
12
src/core/parsingfactory.cpp
Normal file → Executable file
@ -53,10 +53,9 @@ QList<Message> ParsingFactory::parseAsATOM10(const QString &data) {
|
||||
QDomNodeList elem_links = message_item.toElement().elementsByTagName("link");
|
||||
|
||||
for (int i = 0; i < elem_links.size(); i++) {
|
||||
QDomNode elem_link = elem_links.at(i);
|
||||
new_message.m_url = elem_links.at(i).attributes().namedItem("href").toAttr().value();
|
||||
|
||||
if (elem_link.attributes().namedItem("rel").toAttr().value() == "alternate") {
|
||||
new_message.m_url = elem_link.attributes().namedItem("href").toAttr().value();
|
||||
if (!new_message.m_url.isNull() && !new_message.m_url.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -214,9 +213,12 @@ QList<Message> ParsingFactory::parseAsRSS20(const QString &data) {
|
||||
|
||||
// Deal with creation date.
|
||||
new_message.m_created = TextFactory::parseDateTime(message_item.namedItem("pubDate").toElement().text());
|
||||
new_message.m_createdFromFeed = !new_message.m_created.isNull();
|
||||
|
||||
if (!new_message.m_createdFromFeed) {
|
||||
if (new_message.m_created.isNull()) {
|
||||
new_message.m_created = TextFactory::parseDateTime(message_item.namedItem("date").toElement().text());
|
||||
}
|
||||
|
||||
if (!(new_message.m_createdFromFeed = !new_message.m_created.isNull())) {
|
||||
// Date was NOT obtained from the feed,
|
||||
// set current date as creation date for the message.
|
||||
new_message.m_created = current_time;
|
||||
|
7
src/core/textfactory.cpp
Normal file → Executable file
7
src/core/textfactory.cpp
Normal file → Executable file
@ -24,8 +24,8 @@ QDateTime TextFactory::parseDateTime(const QString &date_time) {
|
||||
date_patterns << "yyyy-MM-ddTHH:mm:ss" << "MMM dd yyyy hh:mm:ss" <<
|
||||
"MMM d yyyy hh:mm:ss" << "ddd, dd MMM yyyy HH:mm:ss" <<
|
||||
"dd MMM yyyy" << "yyyy-MM-dd HH:mm:ss.z" << "yyyy-MM-dd" <<
|
||||
"YYYY" << "YYYY-MM" << "YYYY-MM-DD" << "YYYY-MM-DDThh:mm" <<
|
||||
"YYYY-MM-DDThh:mm:ss";
|
||||
"yyyy" << "yyyy-MM" << "yyyy-MM-dd" << "yyyy-MM-ddThh:mm" <<
|
||||
"yyyy-MM-ddThh:mm:ss";
|
||||
|
||||
// Check if last part of date is time zone offset,
|
||||
// represented as [+|-]hh:mm.
|
||||
@ -85,8 +85,7 @@ QDateTime TextFactory::parseDateTime(const QString &date_time) {
|
||||
}
|
||||
|
||||
QDateTime TextFactory::parseDateTime(qint64 milis_from_epoch) {
|
||||
QDateTime converted = QDateTime::fromMSecsSinceEpoch(milis_from_epoch);
|
||||
return converted;
|
||||
return QDateTime::fromMSecsSinceEpoch(milis_from_epoch);
|
||||
}
|
||||
|
||||
QString TextFactory::shorten(const QString &input, int text_length_limit) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user