diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2016-03-29 10:21:06 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2016-03-29 10:21:06 +0200 |
commit | e92d374581061255f6fdb70c68843bc077c33825 (patch) | |
tree | f280b4b231a949bdc00328eb3657351678a6a1d2 /sfeed_html.c | |
parent | 847a78083f4437d5110e3877fe8f57e7da2a40ae (diff) |
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.
Diffstat (limited to 'sfeed_html.c')
-rw-r--r-- | sfeed_html.c | 8 |
1 files changed, 7 insertions, 1 deletions
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("<tr>", stdout); fputs("<td nowrap valign=\"top\">", 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("</td><td nowrap valign=\"top\">", stdout); if (isnew) fputs("<b><u>", stdout); |