Moved time formats to constanst.
This commit is contained in:
parent
49ae7467fc
commit
88e047d210
@ -13,6 +13,11 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
IcecastPlaylistDateFormat = "02/Jan/2006:15:04:05 -0700"
|
||||||
|
SongTimeFormat = "2006 15:04-0700"
|
||||||
|
)
|
||||||
|
|
||||||
type IcecastStatusDTO struct {
|
type IcecastStatusDTO struct {
|
||||||
Icestats struct {
|
Icestats struct {
|
||||||
ServerStartISO8601 string `json:"server_start_iso8601"`
|
ServerStartISO8601 string `json:"server_start_iso8601"`
|
||||||
@ -117,9 +122,9 @@ func lastPlayedSongs(lastNSongs int, playlistPath string) ([]Song, error) {
|
|||||||
if len(ts) <= 1 {
|
if len(ts) <= 1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tim, _ := time.Parse("02/Jan/2006:15:04:05 -0700", ts[0])
|
tim, _ := time.Parse(IcecastPlaylistDateFormat, ts[0])
|
||||||
songs = append(songs, Song{
|
songs = append(songs, Song{
|
||||||
Time: tim.Format("15:04-0700"),
|
Time: tim.Format(SongTimeFormat),
|
||||||
Listeners: ts[1],
|
Listeners: ts[1],
|
||||||
Song: ts[2]})
|
Song: ts[2]})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user