summaryrefslogtreecommitdiff
path: root/sfeed.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2020-10-06 18:44:35 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2020-10-09 11:27:06 +0200
commitac9fbcd7c4c5603d0a430b82021e6b45c8a02836 (patch)
tree5398c1eb0e8f7a5dba24dc77c874903130fe474c /sfeed.c
parent688fbed347554944aa8f9d0bbd9f66694a8fa353 (diff)
sfeed: support the ISO8601 time format without separators
For example "19720229T132245Z" is now supported.
Diffstat (limited to 'sfeed.c')
-rw-r--r--sfeed.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sfeed.c b/sfeed.c
index ecc28ce..a3ece79 100644
--- 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 == ':'))