blob: 13c53666f1fd4a32ceeba5e271a3f74d670f985e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
package example
import (
"fmt"
"time"
bare "git.sr.ht/~runxiyu/go-bareish"
)
type Time time.Time
func (t *Time) Unmarshal(r *bare.Reader) error {
st, err := r.ReadString()
if err != nil {
return fmt.Errorf("Time.Unmarshal: read string: %e", err)
}
tm, err := time.Parse(time.RFC3339, st)
if err != nil {
return fmt.Errorf("Time.Unmarshal: parse time: %e", err)
}
*t = Time(tm)
return nil
}
|