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_plain.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_plain.c')
-rw-r--r-- | sfeed_plain.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sfeed_plain.c b/sfeed_plain.c index 0c6b436..78cfae0 100644 --- a/sfeed_plain.c +++ b/sfeed_plain.c @@ -15,6 +15,7 @@ static void printfeed(FILE *fp, const char *feedname) { char *fields[FieldLast]; + struct tm *tm; time_t parsedtime; ssize_t linelen; @@ -26,6 +27,8 @@ printfeed(FILE *fp, const char *feedname) parsedtime = 0; strtotime(fields[FieldUnixTimestamp], &parsedtime); + if (!(tm = localtime(&parsedtime))) + err(1, "localtime"); if (parsedtime >= comparetime) fputs("N ", stdout); @@ -33,8 +36,11 @@ printfeed(FILE *fp, const char *feedname) fputs(" ", stdout); if (feedname[0]) - printf("%-15.15s ", feedname); - printf("%-30.30s ", fields[FieldTimeFormatted]); + printf("%-15.15s ", feedname); + + fprintf(stdout, "%04d-%02d-%02d %02d:%02d ", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min); printutf8pad(stdout, fields[FieldTitle], 70, ' '); printf(" %s\n", fields[FieldLink]); } |