Work on parsing dates, still not done.
This commit is contained in:
		
							parent
							
								
									b4d5c0983b
								
							
						
					
					
						commit
						710d36440a
					
				
					 3 changed files with 12 additions and 12 deletions
				
			
		| 
						 | 
					@ -322,8 +322,7 @@ bool FeedsModelStandardFeed::removeItself() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void FeedsModelStandardFeed::updateMessages(const QList<Message> &messages) {
 | 
					void FeedsModelStandardFeed::updateMessages(const QList<Message> &messages) {
 | 
				
			||||||
  int feed_id = id(), message_id;
 | 
					  int feed_id = id();
 | 
				
			||||||
  qint64 message_creation_date;
 | 
					 | 
				
			||||||
  QSqlDatabase database = DatabaseFactory::instance()->connection("FeedsModelStandardFeed",
 | 
					  QSqlDatabase database = DatabaseFactory::instance()->connection("FeedsModelStandardFeed",
 | 
				
			||||||
                                                                  DatabaseFactory::FromSettings);
 | 
					                                                                  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");
 | 
					    QDomNodeList elem_links = message_item.toElement().elementsByTagName("link");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (int i = 0; i < elem_links.size(); i++) {    
 | 
					    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") {
 | 
					      if (!new_message.m_url.isNull() && !new_message.m_url.isEmpty()) {
 | 
				
			||||||
        new_message.m_url = elem_link.attributes().namedItem("href").toAttr().value();
 | 
					 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -214,9 +213,12 @@ QList<Message> ParsingFactory::parseAsRSS20(const QString &data) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Deal with creation date.
 | 
					    // Deal with creation date.
 | 
				
			||||||
    new_message.m_created = TextFactory::parseDateTime(message_item.namedItem("pubDate").toElement().text());
 | 
					    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,
 | 
					      // Date was NOT obtained from the feed,
 | 
				
			||||||
      // set current date as creation date for the message.
 | 
					      // set current date as creation date for the message.
 | 
				
			||||||
      new_message.m_created = current_time;
 | 
					      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" <<
 | 
					  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" <<
 | 
					                   "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" <<
 | 
					                   "dd MMM yyyy" << "yyyy-MM-dd HH:mm:ss.z" << "yyyy-MM-dd" <<
 | 
				
			||||||
                   "YYYY" << "YYYY-MM" << "YYYY-MM-DD" << "YYYY-MM-DDThh:mm" <<
 | 
					                   "yyyy" << "yyyy-MM" << "yyyy-MM-dd" << "yyyy-MM-ddThh:mm" <<
 | 
				
			||||||
                   "YYYY-MM-DDThh:mm:ss";
 | 
					                   "yyyy-MM-ddThh:mm:ss";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Check if last part of date is time zone offset,
 | 
					  // Check if last part of date is time zone offset,
 | 
				
			||||||
  // represented as [+|-]hh:mm.
 | 
					  // represented as [+|-]hh:mm.
 | 
				
			||||||
| 
						 | 
					@ -85,8 +85,7 @@ QDateTime TextFactory::parseDateTime(const QString &date_time) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QDateTime TextFactory::parseDateTime(qint64 milis_from_epoch) {
 | 
					QDateTime TextFactory::parseDateTime(qint64 milis_from_epoch) {
 | 
				
			||||||
  QDateTime converted = QDateTime::fromMSecsSinceEpoch(milis_from_epoch);
 | 
					  return QDateTime::fromMSecsSinceEpoch(milis_from_epoch);
 | 
				
			||||||
  return converted;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QString TextFactory::shorten(const QString &input, int text_length_limit) {
 | 
					QString TextFactory::shorten(const QString &input, int text_length_limit) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue