Documentation ¶
Overview ¶
Package agdtime contains time-related utilities.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
Clock is an interface for time-related operations.
TODO(a.garipov): Expand with operations like After or Tick.
TODO(a.garipov): Move to golibs/timeutil.
type Location ¶
Location is a wrapper around time.Location that can de/serialize itself from and to JSON.
TODO(a.garipov): Move to timeutil.
Example ¶
package main import ( "bytes" "encoding/json" "fmt" "github.com/AdguardTeam/AdGuardDNS/internal/agdtime" ) func main() { var req struct { TimeZone *agdtime.Location `json:"tmz"` } l, err := agdtime.LoadLocation("Europe/Brussels") if err != nil { panic(err) } req.TimeZone = l buf := &bytes.Buffer{} err = json.NewEncoder(buf).Encode(req) if err != nil { panic(err) } fmt.Print(buf) req.TimeZone = nil err = json.NewDecoder(buf).Decode(&req) if err != nil { panic(err) } fmt.Printf("%+v\n", req) }
Output: {"tmz":"Europe/Brussels"} {TimeZone:Europe/Brussels}
func LoadLocation ¶
LoadLocation is a wrapper around time.LoadLocation that returns a *Location instead.
func (Location) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface for Location.
func (*Location) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface for *Location.
type SystemClock ¶
type SystemClock struct{}
SystemClock is a Clock that uses the functions from package time.