diff --git a/web/static/index.css b/web/static/index.css
index cf5f1ba..f56e6ca 100644
--- a/web/static/index.css
+++ b/web/static/index.css
@@ -529,4 +529,8 @@ footer {
.post-img-full {
max-width: 100%;
}
+
+ textarea {
+ font-size: 16px;
+ }
}
diff --git a/web/static/thread.js b/web/static/thread.js
index c82a95f..a26f2f0 100644
--- a/web/static/thread.js
+++ b/web/static/thread.js
@@ -77,4 +77,24 @@ function togglePostFile(el) {
}
}
-insertHeaderReplies()
+function initializePosts() {
+ // set dates to correct timezone
+ document.querySelectorAll('.post-datetime').forEach(el => {
+ const utcDateStr = el.getAttribute('data-utc');
+ const localDate = new Date(utcDateStr);
+
+ const hours = localDate.getHours() % 12 || 12;
+ const minutes = String(localDate.getMinutes()).padStart(2, '0');
+ const ampm = localDate.getHours() >= 12 ? 'PM' : 'AM';
+
+ const month = String(localDate.getMonth() + 1).padStart(2, '0');
+ const day = String(localDate.getDate()).padStart(2, '0');
+ const year = localDate.getFullYear();
+
+ el.textContent = `${month}/${day}/${year} ${hours}:${minutes} ${ampm}`;
+ });
+
+ insertHeaderReplies()
+}
+
+initializePosts();
diff --git a/web/views/thread.templ b/web/views/thread.templ
index 11b4a10..f6b181c 100644
--- a/web/views/thread.templ
+++ b/web/views/thread.templ
@@ -6,6 +6,7 @@ import (
"github.com/dominicf2001/comfychan/internal/util"
"github.com/dominicf2001/comfychan/web/views/shared"
"strconv"
+ "time"
)
templ PostAdminDialog(post database.Post) {
@@ -105,8 +106,7 @@ templ PostOriginal(post database.Post, thread database.Thread) {
{ thread.Subject }
{ post.Author }
- { post.CreatedAt.Format("01/02/2006") }
- { post.CreatedAt.Format("15:04") }
+
>%d\n'
@@ -138,8 +138,7 @@ templ PostReply(post database.Post, threadContext ThreadContext) {
}
{ post.Author }
- { post.CreatedAt.Format("01/02/2006") }
- { post.CreatedAt.Format("15:04") }
+
>%d\n'
@@ -232,7 +231,7 @@ templ Thread(board database.Board, thread database.Thread, posts []database.Post
class="thread"
hx-get={ fmt.Sprintf("/hx/%s/threads/%d/posts", thread.BoardSlug, thread.Id) }
hx-trigger="refreshPosts from:body"
- _="on htmx:afterSwap call insertHeaderReplies() then smoothScrollTo('bottom')"
+ _="on htmx:afterSwap call initializePosts() then smoothScrollTo('bottom')"
>
@Posts(posts, thread, threadContext)