commit:213e6e64dd863fd39d0db7c6fb4ccf1970a868fb
author:Chip Black
committer:Chip Black
date:Wed Jan 5 04:48:38 2011 -0600
parents:5e2384b55931c3a4f986272e2b29ff518a7c8a5b
Add pubDate to RSS generator
diff --git a/cgi/rss.c b/cgi/rss.c
line changes: +7/-0
index a9e3464..24133f6
--- a/cgi/rss.c
+++ b/cgi/rss.c
@@ -1,5 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <time.h>
 #include <cgi-util.h>
 #include "database.h"
 #include "escapery.h"
@@ -12,6 +13,8 @@ int fprint_rss(FILE *f, const char *username) {
 	uint64_t i = (record_count > 50 ? record_count - 50 : 0);
 	char *data;
 	char *tmp;
+	time_t post_time;
+	char date[40];
 	int len;
 
 	fprintf(f,
@@ -30,10 +33,14 @@ int fprint_rss(FILE *f, const char *username) {
 	while (i < record_count) {
 		blerg_fetch(b, i, &data, &len);
 		tmp = xml_escape_data(data, len);
+		post_time = blerg_get_timestamp(b, i);
+		strftime(date, 39, "%a, %d %b %Y %H:%M:%S %Z", gmtime(&post_time));
 		fprintf(f,
 			"<item>\n"
+			"<pubDate>%s</pubDate>\n"
 			"<description>%s</description>\n"
 			"</item>\n",
+			date,
 			tmp
 		);
 		free(tmp);

diff --git a/database/database.h b/database/database.h
line changes: +1/-0
index 0ef1c7d..d128869
--- a/database/database.h
+++ b/database/database.h
@@ -34,5 +34,6 @@ int blerg_close(struct blerg *);
 int blerg_store(struct blerg *, const char *, int);
 int blerg_fetch(struct blerg *, int, char **, int *);
 uint64_t blerg_get_record_count(struct blerg *);
+time_t blerg_get_timestamp(struct blerg *blerg, int record);
 
 #endif //_DATABASE_H