Documentation
¶
Overview ¶
Package time provides template functions for measuring and displaying time.
Index ¶
- type Namespace
- func (ns *Namespace) AsTime(v any, args ...any) (any, error)
- func (ns *Namespace) Duration(unit any, number any) (time.Duration, error)
- func (ns *Namespace) Format(layout string, v any) (string, error)
- func (ns *Namespace) In(timeZoneName string, t time.Time) (time.Time, error)
- func (ns *Namespace) Now() time.Time
- func (ns *Namespace) ParseDuration(s any) (time.Duration, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace provides template functions for the "time" namespace.
func (*Namespace) AsTime ¶
AsTime converts the textual representation of the datetime string into a time.Time interface.
func (*Namespace) Duration ¶
Duration converts the given number to a time.Duration. Unit is one of nanosecond/ns, microsecond/us/µs, millisecond/ms, second/s, minute/m or hour/h.
func (*Namespace) Format ¶
Format converts the textual representation of the datetime string in v into time.Time if needed and formats it with the given layout.
func (*Namespace) In ¶
In returns the time t in the IANA time zone specified by timeZoneName. If timeZoneName is "" or "UTC", the time is returned in UTC. If timeZoneName is "Local", the time is returned in the system's local time zone. Otherwise, timeZoneName must be a valid IANA location name (e.g., "Europe/Oslo").
func (*Namespace) ParseDuration ¶
ParseDuration parses the duration string s. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". See https://golang.org/pkg/time/#ParseDuration