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 // NewHeader creates and populates a new timeline header
// and returns it // and returns it
func NewHeader(evtType EventType, expires time.Duration) TimelineHeader { func NewHeader(t time.Time, evtType EventType, expires time.Duration) TimelineHeader {
now := time.Now() _, offset := t.Zone()
_, offset := now.Zone() t = t.Add(time.Duration(offset) * time.Second)
now = now.Add(time.Duration(offset) * time.Second)
return TimelineHeader{ return TimelineHeader{
Timestamp: uint64(now.Unix()), Timestamp: uint64(t.Unix()),
Expires: uint32(expires.Seconds()), Expires: uint32(expires.Seconds()),
EventType: evtType, EventType: evtType,
} }