v0.0.405
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m36s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m36s
This commit is contained in:
parent
102a280dda
commit
0927fdc4d7
@ -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"
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user