commit 7c220b7102082d975ef0c901e1beb76040e33b7a
parent 84266bd4447a8f66e77f4179d7f1cdc6d2012258
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 3 Jan 2015 17:19:21 +0100
sfeed: remove level of indent in parsetime
Diffstat:
M | sfeed.c | | | 29 | +++++++++++++++-------------- |
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/sfeed.c b/sfeed.c
@@ -364,20 +364,21 @@ parsetime(const char *s, char *buf, size_t bufsiz, time_t *tp)
memset(&tm, 0, sizeof(tm));
for(i = 0; formats[i]; i++) {
- if((p = strptime(s, formats[i], &tm))) {
- tm.tm_isdst = -1; /* don't use DST */
- if((t = mktime(&tm)) == -1) /* error */
- return -1;
- if(gettimetz(p, tz, sizeof(tz), &tzoffset) != -1)
- t -= tzoffset;
- if(buf)
- snprintf(buf, bufsiz, "%04d-%02d-%02d %02d:%02d:%02d %s",
- tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec, tz);
- if(tp)
- *tp = t;
- return 0;
- }
+ if(!(p = strptime(s, formats[i], &tm)))
+ continue;
+ tm.tm_isdst = -1; /* don't use DST */
+ if((t = mktime(&tm)) == -1) /* error */
+ return -1;
+ if(gettimetz(p, tz, sizeof(tz), &tzoffset) != -1)
+ t -= tzoffset;
+ if(buf)
+ snprintf(buf, bufsiz,
+ "%04d-%02d-%02d %02d:%02d:%02d %s",
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+ tm.tm_hour, tm.tm_min, tm.tm_sec, tz);
+ if(tp)
+ *tp = t;
+ return 0;
}
return -1;
}