diff --git a/rfctime/rfc3339.go b/rfctime/rfc3339.go index e493f55..0e350ff 100644 --- a/rfctime/rfc3339.go +++ b/rfctime/rfc3339.go @@ -66,6 +66,10 @@ func (t *RFC3339Time) UnmarshalText(data []byte) error { } func (t *RFC3339Time) UnmarshalBSONValue(bt bsontype.Type, data []byte) error { + if bt == bsontype.Null { + *t = RFC3339Time{} + return nil + } if bt != bsontype.DateTime { return errors.New(fmt.Sprintf("cannot unmarshal %v into RFC3339Time", bt)) } diff --git a/rfctime/rfc3339Nano.go b/rfctime/rfc3339Nano.go index a14b856..8383b32 100644 --- a/rfctime/rfc3339Nano.go +++ b/rfctime/rfc3339Nano.go @@ -66,6 +66,10 @@ func (t *RFC3339NanoTime) UnmarshalText(data []byte) error { } func (t *RFC3339NanoTime) UnmarshalBSONValue(bt bsontype.Type, data []byte) error { + if bt == bsontype.Null { + *t = RFC3339NanoTime{} + return nil + } if bt != bsontype.DateTime { return errors.New(fmt.Sprintf("cannot unmarshal %v into RFC3339NanoTime", bt)) }