This commit is contained in:
Mike Schwörer 2023-04-13 14:40:07 +02:00
parent c5e23ab451
commit c13db6802e
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
2 changed files with 8 additions and 0 deletions

View File

@ -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))
}

View File

@ -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))
}