From 9fef78926f54c881158d5fa1620e6fc0714f6405 Mon Sep 17 00:00:00 2001 From: joshx Date: Mon, 25 Jul 2022 10:32:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B32006-01-02T15:04:05.67Z?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E6=97=B6=E9=97=B4=E8=BF=94=E5=9B=9E=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convert/time.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/convert/time.go b/convert/time.go index cc2e0a10..98e9881e 100644 --- a/convert/time.go +++ b/convert/time.go @@ -40,6 +40,13 @@ func String2Time(s string, originalLocation *time.Location, convertedLocation *t } dt = dt.In(convertedLocation) return &dt, nil + } else if len(s) >= 21 && s[10] == 'T' { + dt, err := time.ParseInLocation("2006-01-02T15:04:05", s[:19], originalLocation) + if err != nil { + return nil, err + } + dt = dt.In(convertedLocation) + return &dt, nil } else if len(s) >= 21 && s[19] == '.' { var layout = "2006-01-02 15:04:05." + strings.Repeat("0", len(s)-20) dt, err := time.ParseInLocation(layout, s, originalLocation)