Add the ability to set a custom time in weather timeline headers

This commit is contained in:
Elara Musayelyan 2023-06-28 22:14:35 -07:00
parent f2640203e9
commit f5546ca32e

View file

@ -81,13 +81,12 @@ type TimelineHeader struct {
// NewHeader creates and populates a new timeline header
// and returns it
func NewHeader(evtType EventType, expires time.Duration) TimelineHeader {
now := time.Now()
_, offset := now.Zone()
now = now.Add(time.Duration(offset) * time.Second)
func NewHeader(t time.Time, evtType EventType, expires time.Duration) TimelineHeader {
_, offset := t.Zone()
t = t.Add(time.Duration(offset) * time.Second)
return TimelineHeader{
Timestamp: uint64(now.Unix()),
Timestamp: uint64(t.Unix()),
Expires: uint32(expires.Seconds()),
EventType: evtType,
}