Skip to content

Commit 4050332

Browse files
rubiojrmuesli
authored andcommitted
Add support for time.Time conversions
1 parent 948b537 commit 4050332

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

bees/placeholders.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"reflect"
2929
"strconv"
3030
"strings"
31+
"time"
3132
)
3233

3334
// Placeholders is an array of Placeholder.
@@ -204,6 +205,18 @@ func ConvertValue(v interface{}, dst interface{}) error {
204205
panic(fmt.Sprintf("Unhandled type %+v for int conversion", reflect.TypeOf(vt)))
205206
}
206207

208+
case *time.Time:
209+
switch vt := v.(type) {
210+
case time.Time:
211+
*d = vt
212+
case int:
213+
*d = time.Unix(int64(vt), 0)
214+
case int64:
215+
*d = time.Unix(vt, 0)
216+
default:
217+
panic(fmt.Sprintf("Unhandled type %+v for time.Time conversion", reflect.TypeOf(vt)))
218+
}
219+
207220
case *url.Values:
208221
switch vt := v.(type) {
209222
case string:

0 commit comments

Comments
 (0)