aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/spf13/cast/caste.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/spf13/cast/caste.go')
-rw-r--r--vendor/github.com/spf13/cast/caste.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/vendor/github.com/spf13/cast/caste.go b/vendor/github.com/spf13/cast/caste.go
index 23f59a1..1aaa1ff 100644
--- a/vendor/github.com/spf13/cast/caste.go
+++ b/vendor/github.com/spf13/cast/caste.go
@@ -18,15 +18,21 @@ import (
func ToTimeE(i interface{}) (tim time.Time, err error) {
i = indirect(i)
- switch s := i.(type) {
+ switch v := i.(type) {
case time.Time:
- return s, nil
+ return v, nil
case string:
- d, e := StringToDate(s)
+ d, e := StringToDate(v)
if e == nil {
return d, nil
}
return time.Time{}, fmt.Errorf("Could not parse Date/Time format: %v\n", e)
+ case int:
+ return time.Unix(int64(v), 0), nil
+ case int32:
+ return time.Unix(int64(v), 0), nil
+ case int64:
+ return time.Unix(v, 0), nil
default:
return time.Time{}, fmt.Errorf("Unable to Cast %#v to Time\n", i)
}
@@ -513,6 +519,7 @@ func StringToDate(s string) (time.Time, error) {
"02 Jan 2006",
"2006-01-02 15:04:05 -07:00",
"2006-01-02 15:04:05 -0700",
+ "2006-01-02 15:04:05",
})
}