1
0
Fork 0

Handle more date formats

This commit is contained in:
Frédéric Guillot 2018-01-03 18:59:29 -08:00
parent 462b4a2642
commit efac11e082
2 changed files with 6 additions and 0 deletions

View file

@ -203,6 +203,11 @@ func Parse(ds string) (t time.Time, err error) {
}
}
lastSpace := strings.LastIndex(ds, " ")
if lastSpace > 0 {
return Parse(ds[0:lastSpace])
}
err = fmt.Errorf(`date parser: failed to parse date "%s"`, ds)
return
}

View file

@ -46,6 +46,7 @@ func TestParseWeirdDateFormat(t *testing.T) {
"9 Dec 2016 12:00 GMT",
"Friday, December 22, 2017 - 3:09pm",
"Friday, December 8, 2017 - 3:07pm",
"Thu, 25 Feb 2016 00:00:00 Europe/Brussels",
}
for _, date := range dates {