// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package util import ( "strings" "time" ) func ParseTime(str string) time.Time { layOut := "2006-01-02 15:04:05" if strings.Contains(str, ":") == false && strings.Contains(str, "-") == false { layOut = "20060102150405" } else if strings.Contains(str, "T") { layOut = "2006-01-02T15:04:05" } loc, _ := time.LoadLocation("Local") t, err := time.ParseInLocation(layOut, str, loc) if err != nil { return time.Now() } return t }