]> code.octet-stream.net Git - broadcaster/blobdiff - radio/main.go
Handle timestamps with no seconds cleanly
[broadcaster] / radio / main.go
index ca7c99633d8fa6d4595a6d403d4d8f336e15580e..85d15b1d715e6046b60dd1366da574acbf8ff15e 100644 (file)
@@ -20,7 +20,7 @@ import (
        "golang.org/x/net/websocket"
 )
 
        "golang.org/x/net/websocket"
 )
 
-const version = "v1.0.0"
+const version = "v1.1.0"
 const sampleRate = 44100
 
 var config RadioConfig = NewRadioConfig()
 const sampleRate = 44100
 
 var config RadioConfig = NewRadioConfig()
@@ -227,7 +227,10 @@ func playlistWorker(ch <-chan []protocol.PlaylistSpec, stop <-chan bool) {
                        }
                        var soonestTime time.Time
                        for _, v := range specs {
                        }
                        var soonestTime time.Time
                        for _, v := range specs {
-                               t, err := time.ParseInLocation(protocol.StartTimeFormat, v.StartTime, loc)
+                               t, err := time.ParseInLocation(protocol.StartTimeFormatSecs, v.StartTime, loc)
+                               if err != nil {
+                                       t, err = time.ParseInLocation(protocol.StartTimeFormat, v.StartTime, loc)
+                               }
                                if err != nil {
                                        log.Println("Error parsing start time", err)
                                        continue
                                if err != nil {
                                        log.Println("Error parsing start time", err)
                                        continue
@@ -242,7 +245,7 @@ func playlistWorker(ch <-chan []protocol.PlaylistSpec, stop <-chan bool) {
                                }
                        }
                        if found {
                                }
                        }
                        if found {
-                               duration := soonestTime.Sub(time.Now())
+                               duration := time.Until(soonestTime)
                                log.Println("Next playlist will be id", nextId, "in", duration.Seconds(), "seconds")
                                timer = time.NewTimer(duration)
                        } else {
                                log.Println("Next playlist will be id", nextId, "in", duration.Seconds(), "seconds")
                                timer = time.NewTimer(duration)
                        } else {