diff page-paste.c @ 77:fe78b16c694d

pasterd: refactor json utilities
author David Demelier <markand@malikania.fr>
date Thu, 16 Mar 2023 15:05:26 +0100
parents b12491ceabfd
children 9bfe5ce3cc45
line wrap: on
line diff
--- a/page-paste.c	Thu Mar 16 13:35:17 2023 +0100
+++ b/page-paste.c	Thu Mar 16 15:05:26 2023 +0100
@@ -19,26 +19,14 @@
 #include <assert.h>
 
 #include "database.h"
-#include "paste.h"
+#include "json-util.h"
 #include "page-paste.h"
 #include "page.h"
+#include "paste.h"
 #include "util.h"
 
 #include "html/paste.h"
 
-// TODO: share this.
-static inline json_t *
-create_date(const struct paste *paste)
-{
-	return json_string(bstrftime("%c", localtime(&paste->timestamp)));
-}
-
-static inline json_t *
-create_expiration(const struct paste *paste)
-{
-	return json_string(ttl(paste->timestamp, paste->duration));
-}
-
 static inline json_t *
 create_pagetitle(const struct paste *paste)
 {
@@ -56,8 +44,8 @@
 		"language",     paste->language,
 		"code",         paste->code,
 		"public",       paste->visible ? "Yes" : "No",
-		"date",         create_date(paste),
-		"expiration",   create_expiration(paste)
+		"date",         ju_date(paste),
+		"expiration",   ju_expiration(paste)
 	);
 }