RSSyl: use procheader_date_parse() instead of parseRFC822Date().
authorAndrej Kacian <ticho@claws-mail.org>
Wed, 6 May 2015 22:19:03 +0000 (00:19 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Wed, 6 May 2015 22:33:49 +0000 (00:33 +0200)
src/plugins/rssyl/libfeed/date.c
src/plugins/rssyl/libfeed/date.h
src/plugins/rssyl/libfeed/parser_rdf.c
src/plugins/rssyl/libfeed/parser_rss20.c

index 92f5a860dae3132ff8476eabf19f7dc58f9052d9..b00555a006666c602cd412d6e30f888489ebf675 100644 (file)
@@ -120,32 +120,3 @@ gchar *createRFC822Date(const time_t *time) {
        return g_strdup_printf("%s, %2d %s %4d %02d:%02d:%02d GMT", dayofweek[tm->tm_wday], tm->tm_mday,
                                           months[tm->tm_mon], 1900 + tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec);
 }
        return g_strdup_printf("%s, %2d %s %4d %02d:%02d:%02d GMT", dayofweek[tm->tm_wday], tm->tm_mday,
                                           months[tm->tm_mon], 1900 + tm->tm_year, tm->tm_hour, tm->tm_min, tm->tm_sec);
 }
-
-time_t parseRFC822Date(gchar *date)
-{
-       struct tm t;
-       memset(&t, 0, sizeof(struct tm));
-       const char *c = setlocale(LC_TIME, NULL);
-
-       /* Adjust the LC_TIME locale to standard C in order for strptime()
-        * to work reliably. */
-       if (c != NULL)
-               setlocale(LC_TIME, "C");
-
-       if (date != NULL &&
-                       !strptime(date, "%a, %d %b %Y %H:%M:%S %Z", &t) &&
-                       !strptime(date, "%a, %d %b %Y %H:%M %Z", &t) &&
-                       !strptime(date, "%d %b %Y %H:%M:%S %Z", &t) &&
-                       !strptime(date, "%d %b %Y %H:%M %Z", &t)) {
-               g_warning("Invalid RFC822 date!\n");
-               if (c != NULL)
-                       setlocale(LC_TIME, c);
-               return 0;
-       }
-
-       /* Restore the original LC_TIME locale. */
-       if (c != NULL)
-               setlocale(LC_TIME, c);
-
-       return mktime(&t);
-}
index c8ea1a6193b4076927d35b0cb89054bd31f04103..27c1353212a8927e323fa1d3f9e1e4b4225cba92 100644 (file)
@@ -6,6 +6,5 @@
 
 time_t parseISO8601Date(gchar *date);
 gchar *createRFC822Date(const time_t *time);
 
 time_t parseISO8601Date(gchar *date);
 gchar *createRFC822Date(const time_t *time);
-time_t parseRFC822Date(gchar *date);
 
 #endif /* __DATE_H */
 
 #endif /* __DATE_H */
index f469e060e4f5f3cda0909ebbab0f3b74e7d0e3f3..02b80ea680f8da9a76aa010d83361f4a594767c9 100644 (file)
@@ -22,6 +22,8 @@
 #include <expat.h>
 #include <string.h>
 
 #include <expat.h>
 #include <string.h>
 
+#include <procheader.h>
+
 #include "feed.h"
 #include "date.h"
 #include "parser_rdf.h"
 #include "feed.h"
 #include "date.h"
 #include "parser_rdf.h"
@@ -104,7 +106,7 @@ void feed_parser_rdf_end(void *data, const gchar *el)
                                        } else if( !strcmp(el, "dc:date") ) {
                                                feed->date = parseISO8601Date(text);
                                        } else if( !strcmp(el, "pubDate") ) {
                                        } else if( !strcmp(el, "dc:date") ) {
                                                feed->date = parseISO8601Date(text);
                                        } else if( !strcmp(el, "pubDate") ) {
-                                               feed->date = parseRFC822Date(text);
+                                               feed->date = procheader_date_parse(NULL, text, 0);
                                        }
 
                                        break;
                                        }
 
                                        break;
@@ -129,7 +131,7 @@ void feed_parser_rdf_end(void *data, const gchar *el)
                                        } else if( !strcmp(el, "dc:date") ) {
                                                ctx->curitem->date_modified = parseISO8601Date(text);
                                        } else if( !strcmp(el, "pubDate") ) {
                                        } else if( !strcmp(el, "dc:date") ) {
                                                ctx->curitem->date_modified = parseISO8601Date(text);
                                        } else if( !strcmp(el, "pubDate") ) {
-                                               ctx->curitem->date_modified = parseRFC822Date(text);
+                                               ctx->curitem->date_modified = procheader_date_parse(NULL, text, 0);
                                        }
 
                                        break;
                                        }
 
                                        break;
index 3882750a8760e5445ea063d612fa212e320e7965..25cea33d8d2a9fb762e7af3a5722f715d05967cf 100644 (file)
@@ -22,6 +22,8 @@
 #include <expat.h>
 #include <string.h>
 
 #include <expat.h>
 #include <string.h>
 
+#include <procheader.h>
+
 #include "feed.h"
 #include "feeditem.h"
 #include "feeditemenclosure.h"
 #include "feed.h"
 #include "feeditem.h"
 #include "feeditemenclosure.h"
@@ -132,7 +134,7 @@ void feed_parser_rss20_end(void *data, const gchar *el)
                        } else if( !strcmp(el, "dc:date") ) {
                                feed->date = parseISO8601Date(text);
                        } else if( !strcmp(el, "pubDate") ) {
                        } else if( !strcmp(el, "dc:date") ) {
                                feed->date = parseISO8601Date(text);
                        } else if( !strcmp(el, "pubDate") ) {
-                               feed->date = parseRFC822Date(text);
+                               feed->date = procheader_date_parse(NULL, text, 0);
                        }
 
                        break;
                        }
 
                        break;
@@ -162,7 +164,7 @@ void feed_parser_rss20_end(void *data, const gchar *el)
                        } else if( !strcmp(el, "dc:date") ) {
                                ctx->curitem->date_modified = parseISO8601Date(text);
                        } else if( !strcmp(el, "pubDate") ) {
                        } else if( !strcmp(el, "dc:date") ) {
                                ctx->curitem->date_modified = parseISO8601Date(text);
                        } else if( !strcmp(el, "pubDate") ) {
-                               ctx->curitem->date_modified = parseRFC822Date(text);
+                               ctx->curitem->date_modified = procheader_date_parse(NULL, text, 0);
                        } else if( !strcmp(el, "dc:creator")) {
                                FILL(ctx->curitem->author)
                        }
                        } else if( !strcmp(el, "dc:creator")) {
                                FILL(ctx->curitem->author)
                        }