|
@@ -14,14 +14,20 @@ const (
|
|
|
)
|
|
|
|
|
|
func ParseSqlResultTimeStr(timeStr string) (time.Time, error) {
|
|
|
- var layout string
|
|
|
-
|
|
|
- if strings.HasSuffix(timeStr, ".000000+08:00") {
|
|
|
- layout = sqlResultTimeMicroFormat
|
|
|
- } else if strings.HasSuffix(timeStr, ".000+08:00") {
|
|
|
- layout = sqlResultTimeMilliFormat
|
|
|
- } else {
|
|
|
- layout = sqlResultTimeSecFormat
|
|
|
+ layout := sqlResultTimeSecFormat
|
|
|
+
|
|
|
+ timeZoneIndex := strings.LastIndex(timeStr, "+08:")
|
|
|
+ if timeZoneIndex != -1 {
|
|
|
+ timeStr = timeStr[:timeZoneIndex]
|
|
|
+
|
|
|
+ afterSecondIndex := strings.LastIndex(timeStr, ".")
|
|
|
+ if afterSecondIndex != -1 {
|
|
|
+ if len(timeStr)-afterSecondIndex-1 == 6 {
|
|
|
+ layout = sqlResultTimeMicroFormat
|
|
|
+ } else if len(timeStr)-afterSecondIndex-1 == 3 {
|
|
|
+ layout = sqlResultTimeMilliFormat
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return time.ParseInLocation(layout, timeStr, time.Local)
|