mirror of
https://github.com/WCBROW01/zblock.git
synced 2025-12-12 04:28: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
|
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.
|
// 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 <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <locale.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include <curl/curl.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);
|
mrss_error_t mrss_err = mrss_parse_buffer(feed_buffer->buf, feed_buffer->bufsize, &mrss_feed);
|
||||||
if (!mrss_err) {
|
if (!mrss_err) {
|
||||||
// get publication date of entries and send any new ones
|
// 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);
|
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;
|
bool update_pubDate = false;
|
||||||
while (item && pubDate_to_time_t(item->pubDate) > last_pubDate_time) {
|
while (item && pubDate_to_time_t(item->pubDate) > last_pubDate_time) {
|
||||||
update_pubDate = true;
|
update_pubDate = true;
|
||||||
@ -365,6 +366,8 @@ static void on_interaction(struct discord *client, const struct discord_interact
|
|||||||
int main(void) {
|
int main(void) {
|
||||||
int exit_code = 0;
|
int exit_code = 0;
|
||||||
|
|
||||||
|
// set locale for time
|
||||||
|
setlocale(LC_ALL, "C");
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
struct discord *client = discord_config_init("config.json");
|
struct discord *client = discord_config_init("config.json");
|
||||||
zblock_config_load(client);
|
zblock_config_load(client);
|
||||||
|
|||||||
Reference in New Issue
Block a user