diff --git a/go.mod b/go.mod index 0e5f9ef..bf6449b 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( ) require ( - github.com/bytedance/sonic v1.11.2 // indirect + github.com/bytedance/sonic v1.11.3 // indirect github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/chenzhuoyu/iasm v0.9.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect diff --git a/go.sum b/go.sum index c5afd30..aa71315 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/bytedance/sonic v1.11.1 h1:JC0+6c9FoWYYxakaoa+c5QTtJeiSZNeByOBhXtAFSn github.com/bytedance/sonic v1.11.1/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= github.com/bytedance/sonic v1.11.2 h1:ywfwo0a/3j9HR8wsYGWsIWl2mvRsI950HyoxiBERw5A= github.com/bytedance/sonic v1.11.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= +github.com/bytedance/sonic v1.11.3 h1:jRN+yEjakWh8aK5FzrciUHG8OFXK+4/KrAX/ysEtHAA= +github.com/bytedance/sonic v1.11.3/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0= diff --git a/goextVersion.go b/goextVersion.go index b70571d..67fe519 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.413" +const GoextVersion = "0.0.414" -const GoextVersionTimestamp = "2024-03-11T21:00:30+0100" +const GoextVersionTimestamp = "2024-03-16T19:42:59+0100" diff --git a/rfctime/date.go b/rfctime/date.go index 85caf2b..a6e1429 100644 --- a/rfctime/date.go +++ b/rfctime/date.go @@ -102,6 +102,13 @@ func (t *Date) UnmarshalBSONValue(bt bsontype.Type, data []byte) error { return err } + if tt == "" { + t.Year = 0 + t.Month = 0 + t.Day = 0 + return nil + } + v, err := time.Parse(t.FormatStr(), tt) if err != nil { return err @@ -114,7 +121,10 @@ func (t *Date) UnmarshalBSONValue(bt bsontype.Type, data []byte) error { } func (t Date) MarshalBSONValue() (bsontype.Type, []byte, error) { - return bson.MarshalValue(t.TimeUTC().Format(t.FormatStr())) + if t.IsZero() { + return bson.MarshalValue("") + } + return bson.MarshalValue(t.String()) } func (t Date) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { @@ -242,6 +252,10 @@ func (t *Date) ParseString(v string) error { return nil } +func (t Date) IsZero() bool { + return t.Year == 0 && t.Month == 0 && t.Day == 0 +} + func NewDate(t time.Time) Date { return Date{ Year: t.Year(),