diff --git a/rfctime/rfc3339.go b/rfctime/rfc3339.go index a05b0d8..3a8190e 100644 --- a/rfctime/rfc3339.go +++ b/rfctime/rfc3339.go @@ -81,7 +81,7 @@ func (t *RFC3339Time) UnmarshalBSONValue(bt bsontype.Type, data []byte) error { return errors.New(fmt.Sprintf("cannot unmarshal %v into RFC3339Time", bt)) } var tt time.Time - err := bson.Unmarshal(data, &tt) + err := bson.RawValue{Type: bt, Value: data}.Unmarshal(&tt) if err != nil { return err } @@ -116,6 +116,12 @@ func (t RFC3339Time) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueRead return err } + if val.Kind() == reflect.Ptr { + val.Set(reflect.ValueOf(&t)) + } else { + val.Set(reflect.ValueOf(t)) + } + return nil }