diff options
author | Mark Powers <mark@marks.kitchen> | 2020-12-20 13:33:17 -0600 |
---|---|---|
committer | Mark Powers <mark@marks.kitchen> | 2020-12-20 13:33:17 -0600 |
commit | ee5600aac9548075634f51113f9b5ed078f82e12 (patch) | |
tree | b5bd41aac59caa5423f7458be914dd472fa69206 /src/server.js | |
parent | 188a48b728080d8ffce1d304580964ea50b30a61 (diff) |
Fix date format on posts to show year
Diffstat (limited to 'src/server.js')
-rw-r--r-- | src/server.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/server.js b/src/server.js index 81b7b0e..81f1edb 100644 --- a/src/server.js +++ b/src/server.js @@ -50,6 +50,11 @@ function hashWithSalt(password, salt){ return hash.digest("base64"); }; +function formatDate(d) { + let month = d.toLocaleString('default', { month: 'long' }); + return month + " " + d.getDate() + ", " + (1900+d.getYear()) +} + async function formatPostsforSingle(models, postType, postId){ var posts = await models.posts.findAll({ where: { @@ -60,7 +65,8 @@ async function formatPostsforSingle(models, postType, postId){ posts = posts.map(x => x.get({ plain: true })); await addImagesAndTagsToPosts(models, posts) posts.forEach(post => { - post.createdAt = post.createdAt.toString().substring(0, 10) + post.createdAt = formatDate(post.createdAt) + post.showTitle = post.type != "bread" }) return posts } @@ -72,7 +78,7 @@ async function formatPostsForType(models, postType){ posts = posts.map(x => x.get({ plain: true })); await addImagesAndTagsToPosts(models, posts) posts.forEach(post => { - post.createdAt = post.createdAt.toString().substring(0, 10) + post.createdAt = formatDate(post.createdAt) post.showTitle = post.type != "bread" }) return posts; |