Skip to content

Commit

Permalink
Added secondary time format for spot prices
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasfaerber committed May 29, 2024
1 parent 9bb3b41 commit 2358b63
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion spotprice.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func GetSpotPrice() (float64, bool) {
}

SpotPriceDateLayout := "2006-01-02T15:04:05"
SpotPriceDateLayout2 := "2006-01-02T15:04:05Z"
//SpotPriceDateLayout := time.RFC3339

//SpotCount++
Expand All @@ -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) {
Expand Down

0 comments on commit 2358b63

Please sign in to comment.