diff --git a/lib/music_library_web/live/record_live/show.ex b/lib/music_library_web/live/record_live/show.ex index ce8fc7e2..ec0563f4 100644 --- a/lib/music_library_web/live/record_live/show.ex +++ b/lib/music_library_web/live/record_live/show.ex @@ -52,4 +52,8 @@ defmodule MusicLibraryWeb.RecordLive.Show do defp musicbrainz_url(record) do "https://musicbrainz.org/release-group/#{record.musicbrainz_id}" end + + defp human_datetime(dt) do + "#{dt.day}/#{dt.month}/#{dt.year}" + end end diff --git a/lib/music_library_web/live/record_live/show.html.heex b/lib/music_library_web/live/record_live/show.html.heex index 0aae07f5..2adac0c7 100644 --- a/lib/music_library_web/live/record_live/show.html.heex +++ b/lib/music_library_web/live/record_live/show.html.heex @@ -67,7 +67,7 @@ <%= gettext("Purchased on") %>
- <%= @record.purchased_at %> + <%= human_datetime(@record.purchased_at) %>
@@ -75,7 +75,7 @@ <%= gettext("Inserted at") %>
- <%= @record.inserted_at %> + <%= human_datetime(@record.inserted_at) %>
@@ -83,7 +83,7 @@ <%= gettext("Updated at") %>
- <%= @record.updated_at %> + <%= human_datetime(@record.updated_at) %>
diff --git a/lib/music_library_web/live/wishlist_live/show.ex b/lib/music_library_web/live/wishlist_live/show.ex index 6c260f91..7fc5e119 100644 --- a/lib/music_library_web/live/wishlist_live/show.ex +++ b/lib/music_library_web/live/wishlist_live/show.ex @@ -52,4 +52,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do defp musicbrainz_url(record) do "https://musicbrainz.org/release-group/#{record.musicbrainz_id}" end + + defp human_datetime(dt) do + "#{dt.day}/#{dt.month}/#{dt.year}" + end end diff --git a/lib/music_library_web/live/wishlist_live/show.html.heex b/lib/music_library_web/live/wishlist_live/show.html.heex index 111305b2..a7178985 100644 --- a/lib/music_library_web/live/wishlist_live/show.html.heex +++ b/lib/music_library_web/live/wishlist_live/show.html.heex @@ -67,7 +67,7 @@ <%= gettext("Inserted at") %>
- <%= @record.inserted_at %> + <%= human_datetime(@record.inserted_at) %>
@@ -75,7 +75,7 @@ <%= gettext("Updated at") %>
- <%= @record.updated_at %> + <%= human_datetime(@record.updated_at) %>
diff --git a/test/music_library_web/live/record_show_test.exs b/test/music_library_web/live/record_show_test.exs index 685d4aa7..139268f8 100644 --- a/test/music_library_web/live/record_show_test.exs +++ b/test/music_library_web/live/record_show_test.exs @@ -11,6 +11,10 @@ defmodule MusicLibraryWeb.RecordShowTest do |> Phoenix.HTML.safe_to_string() end + defp human_datetime(dt) do + "#{dt.day}/#{dt.month}/#{dt.year}" + end + describe "Edit record from show page" do test "can navigate to the record edit form", %{conn: conn} do record = record_fixture() @@ -36,9 +40,9 @@ defmodule MusicLibraryWeb.RecordShowTest do assert html =~ Record.format_long_label(record.format) assert html =~ record.release assert html =~ ~p"/covers/#{record.id}?vsn=#{record.cover_hash}" - assert html =~ Phoenix.HTML.Safe.to_iodata(record.purchased_at) - assert html =~ Phoenix.HTML.Safe.to_iodata(record.inserted_at) - assert html =~ Phoenix.HTML.Safe.to_iodata(record.updated_at) + assert html =~ human_datetime(record.purchased_at) + assert html =~ human_datetime(record.inserted_at) + assert html =~ human_datetime(record.updated_at) for artist <- record.artists do assert html =~ escape(artist.name)