Mercurial > paster
diff page-index.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-index.c Thu Mar 16 13:35:17 2023 +0100 +++ b/page-index.c Thu Mar 16 15:05:26 2023 +0100 @@ -19,6 +19,7 @@ #include <assert.h> #include "database.h" +#include "json-util.h" #include "page-index.h" #include "page.h" #include "paste.h" @@ -43,18 +44,6 @@ } 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_pastes(const struct paste *pastes, size_t pastesz) { json_t *array = json_array(); @@ -67,8 +56,8 @@ "id", paste->id, "author", paste->author, "title", paste->title, - "date", create_date(paste), - "expiration", create_expiration(paste) + "date", ju_date(paste), + "expiration", ju_expiration(paste) )); }