diff --git a/internal/radio/song.go b/internal/radio/song.go index f9d90e3..ccc70f4 100644 --- a/internal/radio/song.go +++ b/internal/radio/song.go @@ -20,6 +20,13 @@ func (s *Song) ArtistTitle() string { return s.Artist + " - " + s.Title } +func (s *Song) DurationString() string { + if s.Duration.Hours() > 0 { + return time.UnixMilli(s.Duration.Milliseconds()).Format("15:04:05") + } + return time.UnixMilli(s.Duration.Milliseconds()).Format("04:05") +} + func (s *Song) MarshalJSON() ([]byte, error) { return json.Marshal(&struct { Artist string `json:"artist"` @@ -32,7 +39,7 @@ func (s *Song) MarshalJSON() ([]byte, error) { Artist: s.Artist, Title: s.Title, DurationMill: s.Duration.Milliseconds(), - Duration: time.UnixMilli(s.Duration.Milliseconds()).Format("04:05"), + Duration: s.DurationString(), MaxListeners: s.MaxListeners, StartAt: s.StartAt.UTC().Format(time.RFC3339)}) }