1
0

Added a duration field to Song_ struct.

This commit is contained in:
Alexander Andreev 2023-10-02 01:26:22 +04:00
parent a741e3eb9a
commit c054c3b32e
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -11,6 +11,7 @@ import (
type Song_ struct {
Artist string
Title string
Duration time.Duration
MaxListeners int
StartAt time.Time
}
@ -23,11 +24,13 @@ func (s *Song_) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Artist string `json:"artist"`
Title string `json:"title"`
Duration int64 `json:"duration_milliseconds"`
MaxListeners int `json:"listeners"`
StartAt string `json:"start_at"`
}{
Artist: s.Artist,
Title: s.Title,
Duration: s.Duration.Milliseconds(),
MaxListeners: s.MaxListeners,
StartAt: s.StartAt.UTC().Format(time.RFC3339)})
}