From 88e047d21037ccccc4dd09bc99d542141b2262b5 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sat, 2 Apr 2022 04:29:23 +0400 Subject: [PATCH] Moved time formats to constanst. --- internal/radio/icecast.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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]}) }