From 2358b63b5b8e64dca4811a03678347047326aab6 Mon Sep 17 00:00:00 2001 From: Andreas Faerber Date: Wed, 29 May 2024 23:34:34 +0200 Subject: [PATCH] Added secondary time format for spot prices --- spotprice.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/spotprice.go b/spotprice.go index 11c2968..3fc5308 100644 --- a/spotprice.go +++ b/spotprice.go @@ -35,6 +35,7 @@ func GetSpotPrice() (float64, bool) { } SpotPriceDateLayout := "2006-01-02T15:04:05" + SpotPriceDateLayout2 := "2006-01-02T15:04:05Z" //SpotPriceDateLayout := time.RFC3339 //SpotCount++ @@ -47,9 +48,18 @@ func GetSpotPrice() (float64, bool) { for _, entry := range SpotPrices { StartDate, err := time.ParseInLocation(SpotPriceDateLayout, entry.StartDate, location) + if err != nil { + StartDate, err = time.ParseInLocation(SpotPriceDateLayout2, entry.StartDate, location) + if err != nil { + panic(err) + } + } EndDate, err := time.ParseInLocation(SpotPriceDateLayout, entry.EndDate, location) if err != nil { - panic(err) + EndDate, err = time.ParseInLocation(SpotPriceDateLayout2, entry.EndDate, location) + if err != nil { + panic(err) + } } if currentTime.After(StartDate) && currentTime.Before(EndDate) {