commit e817ed9d48ac974181c1a45ad193c7f924503c81
parent 03bc1ec04b449df679a025bf1c57275aad341e69
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Wed, 19 Jan 2022 20:40:44 +0100
sfeed: extend the time range, use long long instead of time_t
This allows to parse the time as a number in the 64-bit range, even on 32-bit
platforms. Note that the sfeed formatting tools can still truncate/wrap the
value to time_t, which can be 32-bit.
Diffstat:
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/sfeed.c b/sfeed.c
@@ -1,5 +1,3 @@
-#include <sys/types.h>
-
#include <ctype.h>
#include <errno.h>
#include <stdint.h>
@@ -103,7 +101,7 @@ static FeedTag * gettag(enum FeedType, const char *, size_t);
static long gettzoffset(const char *);
static int isattr(const char *, size_t, const char *, size_t);
static int istag(const char *, size_t, const char *, size_t);
-static int parsetime(const char *, time_t *);
+static int parsetime(const char *, long long *);
static void printfields(void);
static void string_append(String *, const char *, size_t);
static void string_buffer_realloc(String *, size_t);
@@ -425,13 +423,13 @@ string_print_uri(String *s)
void
string_print_timestamp(String *s)
{
- time_t t;
+ long long t;
if (!s->data || !s->len)
return;
if (parsetime(s->data, &t) != -1)
- printf("%lld", (long long)t);
+ printf("%lld", t);
}
long long
@@ -541,7 +539,7 @@ gettzoffset(const char *s)
}
static int
-parsetime(const char *s, time_t *tp)
+parsetime(const char *s, long long *tp)
{
static struct {
char *name;