diff --git a/internal/radio/icecast.go b/internal/radio/icecast.go index 516235e..54d1f3e 100644 --- a/internal/radio/icecast.go +++ b/internal/radio/icecast.go @@ -13,6 +13,11 @@ import ( "github.com/pkg/errors" ) +const ( + IcecastPlaylistDateFormat = "02/Jan/2006:15:04:05 -0700" + SongTimeFormat = "2006 15:04-0700" +) + type IcecastStatusDTO struct { Icestats struct { ServerStartISO8601 string `json:"server_start_iso8601"` @@ -117,9 +122,9 @@ func lastPlayedSongs(lastNSongs int, playlistPath string) ([]Song, error) { if len(ts) <= 1 { continue } - tim, _ := time.Parse("02/Jan/2006:15:04:05 -0700", ts[0]) + tim, _ := time.Parse(IcecastPlaylistDateFormat, ts[0]) songs = append(songs, Song{ - Time: tim.Format("15:04-0700"), + Time: tim.Format(SongTimeFormat), Listeners: ts[1], Song: ts[2]}) }