NullTime in normalizeTime & tests

This commit is contained in:
Matthew Dillon 2014-10-31 09:38:49 -08:00
parent 58344b82a5
commit f48ee87ccd
8 changed files with 49 additions and 17 deletions

View file

@ -1,9 +1,23 @@
package datastore
import "time"
import (
"fmt"
"time"
func normalizeTime(t ...*time.Time) {
"github.com/lib/pq"
)
func normalizeTime(t ...interface{}) {
for _, v := range t {
*v = v.In(time.UTC)
switch u := v.(type) {
default:
fmt.Printf("unexpected type %T", u)
case *time.Time:
x, _ := v.(*time.Time)
*x = x.In(time.UTC)
case *pq.NullTime:
x, _ := v.(*pq.NullTime)
*x = pq.NullTime{Time: x.Time.In(time.UTC), Valid: x.Valid}
}
}
}