summaryrefslogtreecommitdiff
path: root/sfeed_frames.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2016-03-29 10:21:06 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2016-03-29 10:21:06 +0200
commite92d374581061255f6fdb70c68843bc077c33825 (patch)
treef280b4b231a949bdc00328eb3657351678a6a1d2 /sfeed_frames.c
parent847a78083f4437d5110e3877fe8f57e7da2a40ae (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_frames.c')
-rw-r--r--sfeed_frames.c10
1 files changed, 9 insertions, 1 deletions
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("<tr>", fpitems);
fputs("<td nowrap valign=\"top\">", 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("</td><td nowrap valign=\"top\">", fpitems);
if (isnew)
fputs("<b><u>", fpitems);