diff --git a/convert/time.go b/convert/time.go index f93e5c1e..dab6a9a2 100644 --- a/convert/time.go +++ b/convert/time.go @@ -40,13 +40,6 @@ func String2Time(s string, originalLocation *time.Location, convertedLocation *t } dt = dt.In(convertedLocation) return &dt, nil - } else if len(s) >= 21 && s[10] == 'T' && s[19] == '.' && s[len(s)-3] == ':' { - dt, err := time.Parse(time.RFC3339, s) - if err != nil { - return nil, err - } - dt = dt.In(convertedLocation) - return &dt, nil } else if len(s) >= 21 && s[10] == 'T' && s[19] == '.' { dt, err := time.Parse(time.RFC3339, s) if err != nil { diff --git a/convert/time_test.go b/convert/time_test.go index 52a14333..02c14867 100644 --- a/convert/time_test.go +++ b/convert/time_test.go @@ -18,12 +18,17 @@ func TestString2Time(t *testing.T) { var kases = map[string]time.Time{ "2021-08-10": time.Date(2021, 8, 10, 8, 0, 0, 0, expectedLoc), "2021-06-06T22:58:20+08:00": time.Date(2021, 6, 6, 22, 58, 20, 0, expectedLoc), - "2021-06-06T22:58:20.999999999+08:00": time.Date(2021, 6, 6, 22, 58, 20, 999999999, expectedLoc), "2021-06-06T22:58:20.999+08:00": time.Date(2021, 6, 6, 22, 58, 20, 999000000, expectedLoc), + "2021-06-06T22:58:20.999999+08:00": time.Date(2021, 6, 6, 22, 58, 20, 999999000, expectedLoc), + "2021-06-06T22:58:20.999999999+08:00": time.Date(2021, 6, 6, 22, 58, 20, 999999999, expectedLoc), "2021-07-11 10:44:00": time.Date(2021, 7, 11, 18, 44, 0, 0, expectedLoc), + "2021-07-11 10:44:00.999": time.Date(2021, 7, 11, 18, 44, 0, 999000000, expectedLoc), + "2021-07-11 10:44:00.999999": time.Date(2021, 7, 11, 18, 44, 0, 999999000, expectedLoc), + "2021-07-11 10:44:00.999999999": time.Date(2021, 7, 11, 18, 44, 0, 999999999, expectedLoc), "2021-08-10T10:33:04Z": time.Date(2021, 8, 10, 18, 33, 04, 0, expectedLoc), - "2021-08-10T10:33:04.999999999Z": time.Date(2021, 8, 10, 18, 33, 04, 999999999, expectedLoc), "2021-08-10T10:33:04.999Z": time.Date(2021, 8, 10, 18, 33, 04, 999000000, expectedLoc), + "2021-08-10T10:33:04.999999Z": time.Date(2021, 8, 10, 18, 33, 04, 999999000, expectedLoc), + "2021-08-10T10:33:04.999999999Z": time.Date(2021, 8, 10, 18, 33, 04, 999999999, expectedLoc), } for layout, tm := range kases { t.Run(layout, func(t *testing.T) {