diff --git a/lib/music_library/records/record.ex b/lib/music_library/records/record.ex index 82d0d8f4..d88c2237 100644 --- a/lib/music_library/records/record.ex +++ b/lib/music_library/records/record.ex @@ -104,4 +104,15 @@ defmodule MusicLibrary.Records.Record do def format_long_label(:blu_ray), do: "Blu-ray" def format_long_label(:dvd), do: "DVD" def format_long_label(:multi), do: "Multi" + + def format_release(nil), do: "N/A" + + def format_release(release) do + case String.split(release, "-") do + [] -> "N/A" + [year] -> year + [year, month] -> "#{month}/#{year}" + [year, month, day] -> "#{day}/#{month}/#{year}" + end + end end diff --git a/lib/music_library_web/live/record_live/index.html.heex b/lib/music_library_web/live/record_live/index.html.heex index 41dbee47..6829a470 100644 --- a/lib/music_library_web/live/record_live/index.html.heex +++ b/lib/music_library_web/live/record_live/index.html.heex @@ -46,7 +46,9 @@ <:col :let={{_id, record}}>

<%= format_artist_names(record.artists) %>

<%= record.title %>

-

<%= record.release %>

+

+ <%= Records.Record.format_release(record.release) %> +

<:action :let={{_id, record}}>
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 0d09a29b..cbe17c40 100644 --- a/lib/music_library_web/live/record_live/show.html.heex +++ b/lib/music_library_web/live/record_live/show.html.heex @@ -34,7 +34,9 @@ <%= @record.musicbrainz_id %> - <:item title="Release"><%= @record.release %> + <:item title="Release"> + <%= Records.Record.format_release(@record.release) %> + <:item title="Genres">