Author: Adam <git@apiote.xyz>
fix getting feed timezone return feedInfo with timezone only if found
traffic/date.go | 9 +++++----
diff --git a/traffic/date.go b/traffic/date.go index 286fafa2056034b0b763b494726eca0fc04f7821..77388819524edaacc32c40bfab98e0c932dd665e 100644 --- a/traffic/date.go +++ b/traffic/date.go @@ -12,12 +12,13 @@ if stop.Timezone != "" { return time.LoadLocation(stop.Timezone) } - var feedInfo FeedInfo for _, feedInfos := range t.FeedInfos { - feedInfo = feedInfos[feedID] - return time.LoadLocation(feedInfo.Timezone) + feedInfo, ok := feedInfos[feedID] + if ok { + return time.LoadLocation(feedInfo.Timezone) + } } - return nil, nil + return nil, fmt.Errorf("cannot find feedInfo for %s in timezone calculation", feedID) } func ParseDate(dateString string, feedName string, t *Traffic) (Validity, time.Time, error) {