sfeed

Simple RSS and Atom feed parser
git clone https://git.sinitax.com/codemadness/sfeed
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit ac9fbcd7c4c5603d0a430b82021e6b45c8a02836
parent 688fbed347554944aa8f9d0bbd9f66694a8fa353
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue,  6 Oct 2020 18:44:35 +0200

sfeed: support the ISO8601 time format without separators

For example "19720229T132245Z" is now supported.

Diffstat:
Msfeed.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/sfeed.c b/sfeed.c @@ -496,8 +496,8 @@ parsetime(const char *s, time_t *tp) if (!isdigit((unsigned char)*s) && !isalpha((unsigned char)*s)) return -1; - if (strspn(s, "0123456789") == 4) { - /* format "%Y-%m-%d %H:%M:%S" or "%Y-%m-%dT%H:%M:%S" */ + if (strspn(s, "0123456789") >= 4) { + /* formats "%Y-%m-%d %H:%M:%S", "%Y-%m-%dT%H:%M:%S" or "%Y%m%d%H%M%S" */ vi = 0; } else { /* format: "[%a, ]%d %b %Y %H:%M:%S" */ @@ -543,11 +543,14 @@ parsetime(const char *s, time_t *tp) vi = 3; } - /* parse time part */ + /* parse time parts (and possibly remaining date parts) */ for (; *s && vi < 6; vi++) { - for (i = 0, v = 0; *s && i < 4 && isdigit((unsigned char)*s); s++, i++) + for (i = 0, v = 0; *s && i < ((vi == 0) ? 4 : 2) && + isdigit((unsigned char)*s); s++, i++) { v = (v * 10) + (*s - '0'); + } va[vi] = v; + if ((vi < 2 && *s == '-') || (vi == 2 && (*s == 'T' || isspace((unsigned char)*s))) || (vi > 2 && *s == ':'))