From 1fbae343a4ff3f0b9ed3b9d85a711ea42486b762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Tue, 6 Jun 2023 11:26:46 +0200 Subject: [PATCH] Fix RFC3339 serialization --- rfctime/rfc3339.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 }