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_frames.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'sfeed_frames.c') diff --git a/sfeed_frames.c b/sfeed_frames.c index cd873c1..64fbbc8 100644 --- a/sfeed_frames.c +++ b/sfeed_frames.c @@ -108,6 +108,7 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f) ssize_t linelen; FILE *fpcontent = NULL; unsigned int isnew; + struct tm *tm; time_t parsedtime; int fd, r; @@ -153,6 +154,9 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f) parsedtime = 0; strtotime(fields[FieldUnixTimestamp], &parsedtime); + if (!(tm = localtime(&parsedtime))) + err(1, "localtime"); + /* content file doesn't exist yet and has error? */ if ((fd = open(filepath, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1) { @@ -208,7 +212,11 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f) else fputs("", fpitems); fputs("", fpitems); - xmlencode(fields[FieldTimeFormatted], fpitems); + + fprintf(fpitems, "%04d-%02d-%02d %02d:%02d ", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min); + fputs("", fpitems); if (isnew) fputs("", fpitems); -- cgit v1.2.3