Consolidate datetime as date formatting

This commit is contained in:
Claudio Ortolina
2025-01-05 15:48:56 +00:00
parent 75154df3cf
commit 9428828064
8 changed files with 20 additions and 30 deletions
+1 -1
View File
@@ -229,7 +229,7 @@ defmodule MusicLibrary.Records.Record do
end
end
def format_purchased_at(purchased_at) do
def format_as_date(purchased_at) do
"#{purchased_at.day}/#{purchased_at.month}/#{purchased_at.year}"
end
@@ -66,7 +66,7 @@ defmodule MusicLibraryWeb.RecordComponents do
aria-hidden="true"
data-slot="icon"
/>
{Records.Record.format_purchased_at(record.purchased_at)}
{Records.Record.format_as_date(record.purchased_at)}
</span>
</p>
</div>
@@ -90,7 +90,7 @@ defmodule MusicLibraryWeb.RecordComponents do
{gettext("Purchased on")}
</span>
<.icon name="hero-banknotes" class="-mt-1 h-4 w-4" aria-hidden="true" data-slot="icon" />
{Records.Record.format_purchased_at(record.purchased_at)}
{Records.Record.format_as_date(record.purchased_at)}
</p>
</div>
<%!-- TODO: replace with OSS version --%>
@@ -138,10 +138,6 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
defp title_segment(:show), do: gettext("Show")
defp title_segment(:edit), do: gettext("Edit")
defp human_datetime(dt) do
"#{dt.day}/#{dt.month}/#{dt.year}"
end
defp toggle_actions_menu(record_id) do
JS.toggle(to: "#actions-#{record_id}")
|> JS.toggle_class("pointer-events-none", to: "#records > li")
@@ -181,7 +181,7 @@
{gettext("Purchased on")}
</dt>
<dd class="mt-1 text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
{human_datetime(@record.purchased_at)}
{Records.Record.format_as_date(@record.purchased_at)}
</dd>
</div>
<div
@@ -204,7 +204,7 @@
{gettext("Inserted at")}
</dt>
<dd class="mt-1 text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
{human_datetime(@record.inserted_at)}
{Records.Record.format_as_date(@record.inserted_at)}
</dd>
</div>
<div class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
@@ -212,7 +212,7 @@
{gettext("Updated at")}
</dt>
<dd class="mt-1 text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
{human_datetime(@record.updated_at)}
{Records.Record.format_as_date(@record.updated_at)}
</dd>
</div>
</dl>
@@ -135,10 +135,6 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
defp title_segment(:show), do: gettext("Show")
defp title_segment(:edit), do: gettext("Edit")
defp human_datetime(dt) do
"#{dt.day}/#{dt.month}/#{dt.year}"
end
defp toggle_actions_menu(record_id) do
JS.toggle(to: "#actions-#{record_id}")
|> JS.toggle_class("pointer-events-none", to: "#records > li")
@@ -214,7 +214,7 @@
{gettext("Inserted at")}
</dt>
<dd class="mt-1 text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
{human_datetime(@record.inserted_at)}
{Records.Record.format_as_date(@record.inserted_at)}
</dd>
</div>
<div class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
@@ -222,7 +222,7 @@
{gettext("Updated at")}
</dt>
<dd class="mt-1 text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
{human_datetime(@record.updated_at)}
{Records.Record.format_as_date(@record.updated_at)}
</dd>
</div>
</dl>