From e92d374581061255f6fdb70c68843bc077c33825 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Tue, 29 Mar 2016 10:21:06 +0200 Subject: add time parsing to sfeed itself, remove time field - less overhead (we only need GMT time) so no setenv("TZ", ...) tzset() crap. - timezone format (for example %z in strptime) is non-standard, this will add some lines of code and some complexity to our code though, but the trade-off is worth it imho. --- sfeed_html.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'sfeed_html.c') diff --git a/sfeed_html.c b/sfeed_html.c index 028653b..a98e64b 100644 --- a/sfeed_html.c +++ b/sfeed_html.c @@ -17,6 +17,7 @@ static void printfeed(FILE *fp, struct feed *f) { char *fields[FieldLast]; + struct tm *tm; time_t parsedtime; unsigned int islink, isnew; ssize_t linelen; @@ -37,8 +38,11 @@ printfeed(FILE *fp, struct feed *f) line[--linelen] = '\0'; if (!parseline(line, fields)) break; + parsedtime = 0; strtotime(fields[FieldUnixTimestamp], &parsedtime); + if (!(tm = localtime(&parsedtime))) + err(1, "localtime"); isnew = (parsedtime >= comparetime) ? 1 : 0; islink = (fields[FieldLink][0] != '\0') ? 1 : 0; @@ -52,7 +56,9 @@ printfeed(FILE *fp, struct feed *f) else fputs("", stdout); fputs("", stdout); - fputs(fields[FieldTimeFormatted], stdout); + fprintf(stdout, "%04d-%02d-%02d %02d:%02d", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min); fputs("", stdout); if (isnew) fputs("", stdout); -- cgit v1.2.3