diff --git a/cast_test.go b/cast_test.go index cc4ebce..c54ba26 100644 --- a/cast_test.go +++ b/cast_test.go @@ -1218,9 +1218,9 @@ func TestToTimeEE(t *testing.T) { {uint(1482597504), time.Date(2016, 12, 24, 16, 38, 24, 0, time.UTC), false}, {uint64(1234567890), time.Date(2009, 2, 13, 23, 31, 30, 0, time.UTC), false}, {uint32(1234567890), time.Date(2009, 2, 13, 23, 31, 30, 0, time.UTC), false}, + {"1234567890", time.Date(2009, 2, 13, 23, 31, 30, 0, time.UTC), false}, {time.Date(2009, 2, 13, 23, 31, 30, 0, time.UTC), time.Date(2009, 2, 13, 23, 31, 30, 0, time.UTC), false}, // errors - {"2006", time.Time{}, true}, {testing.T{}, time.Time{}, true}, } diff --git a/caste.go b/caste.go index 9ac1015..e662a35 100644 --- a/caste.go +++ b/caste.go @@ -1273,6 +1273,10 @@ func parseDateWith(s string, dates []string) (d time.Time, e error) { return } } + if i, err := strconv.Atoi(s); err == nil { + return time.Unix(int64(i), 0), nil + } + return d, fmt.Errorf("unable to parse date: %s", s) }