[bugfix] parse unix timestamp to time.Time from string

Fixing https://github.com/spf13/cast/issues/102
This commit is contained in:
Valera 2020-09-16 23:01:43 +03:00 committed by GitHub
parent 8d17101741
commit e85dcc8b38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -1273,6 +1273,10 @@ func parseDateWith(s string, dates []string) (d time.Time, e error) {
return
}
}
if i, err := strconv.Atoi(t); err == nil {
return time.Unix(int64(i), 0), nil
}
return d, fmt.Errorf("unable to parse date: %s", s)
}