time

package
v0.0.0-...-42d6f5d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package time provides template functions for measuring and displaying time.

Index

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 New

func New(timeFormatter htime.TimeFormatter, location *time.Location) *Namespace

New returns a new instance of the time-namespaced template functions.

func (*Namespace) AsTime

func (ns *Namespace) AsTime(v any, args ...any) (any, error)

AsTime converts the textual representation of the datetime string into a time.Time interface.

func (*Namespace) Duration

func (ns *Namespace) Duration(unit any, number any) (_time.Duration, error)

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

func (ns *Namespace) Format(layout string, v any) (string, error)

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) Now

func (ns *Namespace) Now() _time.Time

Now returns the current local time or `clock` time

func (*Namespace) ParseDuration

func (ns *Namespace) ParseDuration(s any) (_time.Duration, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL