From 010774d775e0fd2d0b7ce6fb0660fc6182f7d1b6 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Mon, 2 Oct 2023 03:48:31 +0400 Subject: [PATCH] Return a formatted string alongside with duration in milliseconds. --- internal/radio/song.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/radio/song.go b/internal/radio/song.go index 28e3ee0..f9d90e3 100644 --- a/internal/radio/song.go +++ b/internal/radio/song.go @@ -24,13 +24,15 @@ func (s *Song) MarshalJSON() ([]byte, error) { return json.Marshal(&struct { Artist string `json:"artist"` Title string `json:"title"` - Duration int64 `json:"duration_milliseconds"` + DurationMill int64 `json:"duration_milliseconds"` + Duration string `json:"duration"` MaxListeners int `json:"listeners"` StartAt string `json:"start_at"` }{ Artist: s.Artist, Title: s.Title, - Duration: s.Duration.Milliseconds(), + DurationMill: s.Duration.Milliseconds(), + Duration: time.UnixMilli(s.Duration.Milliseconds()).Format("04:05"), MaxListeners: s.MaxListeners, StartAt: s.StartAt.UTC().Format(time.RFC3339)}) }