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 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.
Click to show internal directories.
Click to hide internal directories.