streaming

Media streaming and broadcast systems in Go
Log | Files | Refs | README | LICENSE

commit 3df4029f13d7c363d034d1c5aed186ba947ab8a6
parent a5e36fbfb60aadd58d7a06c29272251c0a8f8c0e
Author: Oliver Lowe <o@olowe.co>
Date:   Tue, 20 May 2025 16:03:16 +1000

m3u8: unexport, use consistent timestamp layout

The layout is meant to be used internally; the external interface is
regular time.Time values.

Diffstat:
Mm3u8/m3u8.go | 2+-
Mm3u8/segment.go | 4++--
Mm3u8/write.go | 4++--
3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/m3u8/m3u8.go b/m3u8/m3u8.go @@ -14,7 +14,7 @@ import ( const MimeType string = "application/vnd.apple.mpegurl" -const RFC3339Milli string = "2006-01-02T15:04:05.999Z07:00" +const rfc3339Milli string = "2006-01-02T15:04:05.999Z07:00" type Playlist struct { Version int diff --git a/m3u8/segment.go b/m3u8/segment.go @@ -86,7 +86,7 @@ func parseSegment(items chan item, leading item) (*Segment, error) { seg.Map = &m case tagDateTime: it = <-segItems - t, err := time.Parse(time.RFC3339Nano, it.val) + t, err := time.Parse(rfc3339Milli, it.val) if err != nil { return nil, fmt.Errorf("bad date time tag: %w", err) } @@ -275,7 +275,7 @@ func (seg *Segment) MarshalText() ([]byte, error) { tags = append(tags, seg.Map.String()) } if !seg.DateTime.IsZero() { - tags = append(tags, fmt.Sprintf("%s:%s", tagDateTime, seg.DateTime.Format(RFC3339Milli))) + tags = append(tags, fmt.Sprintf("%s:%s", tagDateTime, seg.DateTime.Format(rfc3339Milli))) } us := seg.Duration / time.Microsecond // we do .03f for the same precision as test-streams.mux.dev. diff --git a/m3u8/write.go b/m3u8/write.go @@ -86,9 +86,9 @@ func writeDateRange(w io.Writer, dr *DateRange) error { } var attrs []string attrs = append(attrs, fmt.Sprintf("ID=%q", dr.ID)) - attrs = append(attrs, fmt.Sprintf("START-DATE=%q", dr.Start.Format(time.RFC3339))) + attrs = append(attrs, fmt.Sprintf("START-DATE=%q", dr.Start.Format(rfc3339Milli))) if !dr.End.IsZero() { - attrs = append(attrs, fmt.Sprintf("END-DATE=%q", dr.End.Format(time.RFC3339))) + attrs = append(attrs, fmt.Sprintf("END-DATE=%q", dr.End.Format(rfc3339Milli))) } if dr.Class != "" { attrs = append(attrs, fmt.Sprintf("CLASS=%q", dr.Class))