mirror of
https://github.com/WCBROW01/zblock.git
synced 2025-12-11 20:18:07 -05:00
[feed_info.c] Fix pubDate_to_time_t to work with both types of time strings
This commit is contained in:
10
feed_info.c
10
feed_info.c
@ -32,13 +32,13 @@ const char *zblock_feed_info_strerror(zblock_feed_info_err error) {
|
||||
return error < 0 || error >= ZBLOCK_FEED_INFO_ERRORCOUNT ? "Unspecified error" : ZBLOCK_FEED_INFO_ERRORS[error];
|
||||
}
|
||||
|
||||
// format string for for the time format of pubDate
|
||||
#define PUBDATE_FMT "%a, %d %b %Y %T %z"
|
||||
|
||||
time_t pubDate_to_time_t(char *s) {
|
||||
struct tm tm;
|
||||
char *res = strptime(s, PUBDATE_FMT, &tm);
|
||||
if (!res || !*res) return 0; // invalid time
|
||||
|
||||
// time format with e.g. +0000
|
||||
if (!strptime(s, "%a, %d %b %Y %T %z", &tm)) { // try the other time format with timezone
|
||||
if(!strptime(s, "%a, %d %b %Y %T %Z", &tm)) return 0; // invalid time
|
||||
}
|
||||
|
||||
return mktime(&tm);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user