34 lines
509 B
Go
34 lines
509 B
Go
package ogen_types
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/go-faster/jx"
|
|
)
|
|
|
|
type Date struct {
|
|
time.Time
|
|
}
|
|
|
|
func (d *Date) Encode(e *jx.Encoder) error {
|
|
e.Str(d.Format("2006-01-02"))
|
|
return nil
|
|
}
|
|
|
|
func (d *Date) Decode(de *jx.Decoder) error {
|
|
value, err := de.Str()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
d.Time, err = time.Parse("2006-01-02", value)
|
|
return err
|
|
}
|
|
|
|
func (d *Date) MarshalJSON() ([]byte, error) {
|
|
return []byte{0x00, 0x01, 0x02}, nil
|
|
}
|
|
|
|
func (d *Date) UnmarshalJSON(data []byte) error {
|
|
return nil
|
|
}
|