araddon / dateparse

GoLang Parse many date strings without knowing format in advance.
MIT License
2.03k stars 164 forks source link

Timezone 'Z' not parsed for time string with milliseconds after period #130

Open zifengyu opened 3 years ago

zifengyu commented 3 years ago

'Z' is not parsed after timePeriod '.'. In below sample, the timezone is not detected and ParseIn will have incorrect result.

func main() {
    loc, _ := time.LoadLocation("Asia/Shanghai")
    inputs := []string{
        "1985-04-12T23:20:50Z",
        "1985-04-12T23:20:50.52Z"}
    for _, in := range inputs {
        t, _ := dateparse.ParseIn(in, loc)
        fmt.Println(t)
    }
}

https://goplay.space/#Kj1UBJ-bHsW