Parse strings as time if needed

This commit is contained in:
Tobie Morgan Hitchcock 2019-05-09 20:37:22 +01:00
parent 1b0e9ce86f
commit 9979d911c7

View file

@ -132,6 +132,10 @@ func ensureTime(val interface{}) (out time.Time, ok bool) {
switch val := val.(type) { switch val := val.(type) {
case time.Time: case time.Time:
return val, true return val, true
case string:
if val, err := time.Parse(time.RFC3339Nano, val); err == nil {
return val, true
}
} }
return defaultTime, false return defaultTime, false
} }