File: time.go

package info (click to toggle)
golang-sourcehut-sircmpwn-go-bare 0.0~git20210406.ab86bc2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 268 kB
  • sloc: makefile: 5
file content (25 lines) | stat: -rw-r--r-- 404 bytes parent folder | download
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"

	"git.sr.ht/~sircmpwn/go-bare"
)

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
}