fixed dateLayout, fixed variable order in call to ParseInLocation, code formatting
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hammond/db"
|
||||
"hammond/models"
|
||||
"time"
|
||||
@@ -9,11 +10,12 @@ import (
|
||||
func GenericParseRefuelings(content []models.ImportFillup, user *db.User, vehicle *db.Vehicle, timezone string) ([]db.Fillup, []string) {
|
||||
var errors []string
|
||||
var fillups []db.Fillup
|
||||
dateLayout := "2023-04-16T04:41:25.682Z"
|
||||
dateLayout := "2006-01-02T15:04:05.000Z"
|
||||
loc, _ := time.LoadLocation(timezone)
|
||||
for _, record := range content {
|
||||
date, err := time.ParseInLocation(record.Date, dateLayout, loc)
|
||||
date, err := time.ParseInLocation(dateLayout, record.Date, loc)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
date = time.Date(2000, time.December, 0, 0, 0, 0, 0, loc)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user