Cleaning up null values in json

This commit is contained in:
Matthew Dillon 2014-12-06 14:32:58 -09:00
parent bc6e585b8d
commit 8dc07e3cc8
21 changed files with 222 additions and 92 deletions

View file

@ -5,6 +5,7 @@ import (
"time"
"github.com/lib/pq"
"github.com/thermokarst/bactdb/models"
)
func normalizeTime(t ...interface{}) {
@ -15,9 +16,9 @@ func normalizeTime(t ...interface{}) {
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}
case *models.NullTime:
x, _ := v.(*models.NullTime)
*x = models.NullTime{pq.NullTime{Time: x.Time.In(time.UTC), Valid: x.Valid}}
}
}
}