]> git.wh0rd.org - tt-rss.git/commitdiff
fix date parsing in feeds
authorAndrew Dolgov <fox@madoka.spb.ru>
Mon, 22 Aug 2005 06:13:33 +0000 (07:13 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Mon, 22 Aug 2005 06:13:33 +0000 (07:13 +0100)
backend.php
functions.php

index 2dac4205fcbdf8b1751499d31efb05c9f674c2ac..eed0687096ad518651166999a336da155e2c6b0b 100644 (file)
@@ -15,7 +15,7 @@
                
        if ($op == "feeds") {
 
-               if ($fetch) update_all_feeds($link);
+               if ($fetch) update_all_feeds($link, $fetch);
 
                $result = pg_query("SELECT *,
                        (SELECT count(id) FROM ttrss_entries 
index cbaefa5037ac8daf94822100e10cc6ccd4bd26fa..0d28016fa38186a4aa72c97e9cb59a0091661d77 100644 (file)
@@ -1,12 +1,19 @@
 <?
        require_once 'config.php';
 
-       function update_all_feeds($link) {
+       function update_all_feeds($link, $fetch) {
 
-               $result = pg_query($link, "SELECT feed_url,id FROM ttrss_feeds WHERE
-                       last_updated is null OR title = '' OR
-                       EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) > " . 
-                       MIN_UPDATE_TIME);
+               if (!$fetch) {
+
+                       $result = pg_query($link, "SELECT feed_url,id FROM ttrss_feeds WHERE
+                               last_updated is null OR title = '' OR
+                               EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM last_updated) > " . 
+                               MIN_UPDATE_TIME);
+
+               } else {
+
+                       $result = pg_query($link, "SELECT feed_url,id FROM ttrss_feeds");
+               }
 
                $num_unread = 0;
 
                                if (!$entry_guid) $entry_guid = $item["guid"];
                                if (!$entry_guid) $entry_guid = $item["link"];
        
-                               $entry_timestamp = $item["pubdate"];
-                               if (!$entry_timestamp) $entry_timestamp = $item["modified"];
-                               if (!$entry_timestamp) $entry_timestamp = $item["updated"];
-
-                               if (!$entry_timestamp) continue;
-
-                               $entry_timestamp = strtotime($entry_timestamp);
-
-                               if (!$entry_timestamp) continue;
+                               $entry_timestamp = "";
+                               
+                               $rss_2_date = $item['pubdate'];
+                               $rss_1_date = $item['dc']['date'];
+                               $atom_date = $item['issued'];
+                               
+                               if ($atom_date != "") $entry_timestamp = parse_w3cdtf($atom_date);
+                               if ($rss_1_date != "") $entry_timestamp = parse_w3cdtf($rss_1_date);
+                               if ($rss_2_date != "") $entry_timestamp = strtotime($rss_2_date);
+                               if ($entry_timestamp == "") $entry_timestamp = time();
 
                                $entry_title = $item["title"];
                                $entry_link = $item["link"];