1
0

Return a formatted string alongside with duration in milliseconds.

This commit is contained in:
Alexander Andreev 2023-10-02 03:48:31 +04:00
parent 437403aa9e
commit 010774d775
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -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)})
}