From f5546ca32e0695e3775e1da06a7761283bfa1c93 Mon Sep 17 00:00:00 2001 From: Elara Musayelyan Date: Wed, 28 Jun 2023 22:14:35 -0700 Subject: [PATCH] Add the ability to set a custom time in weather timeline headers --- weather/weather.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/weather/weather.go b/weather/weather.go index 1265c50..3174a53 100644 --- a/weather/weather.go +++ b/weather/weather.go @@ -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, }