diff --git a/goextVersion.go b/goextVersion.go index 25dc374..35ecc49 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.404" +const GoextVersion = "0.0.405" -const GoextVersionTimestamp = "2024-03-10T15:25:30+0100" +const GoextVersionTimestamp = "2024-03-10T15:28:26+0100" diff --git a/rfctime/date.go b/rfctime/date.go index 86444b3..c2d3a47 100644 --- a/rfctime/date.go +++ b/rfctime/date.go @@ -67,36 +67,20 @@ func (t *Date) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &str); err != nil { return err } - t0, err := time.Parse(t.FormatStr(), str) - if err != nil { - return err - } - t.Year = t0.Year() - t.Month = int(t0.Month()) - t.Day = t0.Day() - return nil + return t.ParseString(str) } func (t Date) MarshalJSON() ([]byte, error) { - str := t.TimeUTC().Format(t.FormatStr()) + str := t.String() return json.Marshal(str) } func (t Date) MarshalText() ([]byte, error) { - b := make([]byte, 0, len(t.FormatStr())) - return t.TimeUTC().AppendFormat(b, t.FormatStr()), nil + return []byte(t.String()), nil } func (t *Date) UnmarshalText(data []byte) error { - var err error - v, err := time.Parse(t.FormatStr(), string(data)) - if err != nil { - return err - } - t.Year = v.Year() - t.Month = int(v.Month()) - t.Day = v.Day() - return nil + return t.ParseString(string(data)) } func (t *Date) UnmarshalBSONValue(bt bsontype.Type, data []byte) error { @@ -166,7 +150,7 @@ func (t Date) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val } func (t Date) Serialize() string { - return t.TimeUTC().Format(t.FormatStr()) + return t.String() } func (t Date) FormatStr() string {