mirror of
https://github.com/WCBROW01/zblock.git
synced 2025-12-11 20:18:07 -05:00
Fix time parsing behavior
This commit is contained in:
@ -40,7 +40,7 @@ time_t pubDate_to_time_t(char *s) {
|
||||
if(!strptime(s, "%a, %d %b %Y %T %Z", &tm)) return 0; // invalid time
|
||||
}
|
||||
|
||||
return mktime(&tm);
|
||||
return timegm(&tm);
|
||||
}
|
||||
|
||||
// check if the feed currently exists. the result is in the exists pointer.
|
||||
|
||||
5
main.c
5
main.c
@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
@ -133,8 +134,8 @@ static void timer_retrieve_feeds(struct discord *client, struct discord_timer *t
|
||||
mrss_error_t mrss_err = mrss_parse_buffer(feed_buffer->buf, feed_buffer->bufsize, &mrss_feed);
|
||||
if (!mrss_err) {
|
||||
// get publication date of entries and send any new ones
|
||||
mrss_item_t *item = mrss_feed->item;
|
||||
time_t last_pubDate_time = pubDate_to_time_t(feed_buffer->info.last_pubDate);
|
||||
mrss_item_t *item = mrss_feed->item;
|
||||
bool update_pubDate = false;
|
||||
while (item && pubDate_to_time_t(item->pubDate) > last_pubDate_time) {
|
||||
update_pubDate = true;
|
||||
@ -365,6 +366,8 @@ static void on_interaction(struct discord *client, const struct discord_interact
|
||||
int main(void) {
|
||||
int exit_code = 0;
|
||||
|
||||
// set locale for time
|
||||
setlocale(LC_ALL, "C");
|
||||
srand(time(NULL));
|
||||
struct discord *client = discord_config_init("config.json");
|
||||
zblock_config_load(client);
|
||||
|
||||
Reference in New Issue
Block a user