Use local times for post dates

This commit is contained in:
2023-02-25 15:04:36 +11:00
parent 49bf9dc52d
commit f3cf53938e
5 changed files with 18 additions and 3 deletions

View File

@@ -10,6 +10,10 @@ module Adamantium
published_at.strftime("%e %B, %Y")
end
def machine_published_at
published_at.rfc2822
end
def syndicated?
!syndication_sources.empty?
end

View File

@@ -22,6 +22,7 @@ html
link rel="icon" type="image/x-icon" href="/assets/favicon.ico"
script data-domain="dnitza.com" src="https://stats.dnitza.com/js/script.js" defer="true"
script src="/assets/index.js"
script src="https://unpkg.com/htmx.org@1.8.4" integrity="sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV" crossorigin="anonymous"

View File

@@ -7,6 +7,7 @@ div class="mb-8"
= bookmark.content
== render :tags, tags: bookmark.tags
p class="text-sm u-url text-blue-400 hover:text-blue-600 dark:hover:text-blue-200"
p class="text-sm text-blue-400"
a href="/bookmark/#{bookmark.slug}"
= bookmark.display_published_at
time class="dt-published" datetime=bookmark.machine_published_at
= bookmark.display_published_at

View File

@@ -7,5 +7,5 @@ div class="mb-8 h-entry"
== render :tags, tags: post.tags
p class="text-sm text-blue-400"
time class="dt-published" datetime=post.published_at
time class="dt-published" datetime=post.machine_published_at
= post.display_published_at

9
public/assets/index.js Normal file
View File

@@ -0,0 +1,9 @@
(function() {
document.addEventListener("DOMContentLoaded", function () {
const times = document.querySelectorAll('time');
times.forEach((time) => {
const oldDtime = Date.parse(time.dateTime);
time.innerHTML = new Date(oldDtime).toLocaleDateString(navigator.language, { weekday:"long", year:"numeric", month:"short", day:"numeric"});
});
});
})();