time

package
v2.167.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Hour is an alias of time.Hour.
	Hour = time.Hour

	// Microsecond is an alias of time.Microsecond.
	Microsecond = time.Microsecond

	// Millisecond is an alias of time.Millisecond.
	Millisecond = time.Millisecond

	// Minute is an alias of time.Minute.
	Minute = time.Minute

	// Nanosecond is an alias of time.Nanosecond.
	Nanosecond = time.Nanosecond

	// Second is an alias of time.Second.
	Second = time.Second

	// RFC3339 is an alias of time.RFC3339.
	RFC3339 = time.RFC3339
)

Variables

View Source
var ErrNotFound = errors.New("time: network not found")

ErrNotFound for metrics.

Module for fx.

Functions

func MustParseDuration

func MustParseDuration(s string) time.Duration

MustParseDuration for time.

func Sleep

func Sleep(d Duration)

Sleep is just an alias to time.Sleep.

Types

type Config

type Config struct {
	Kind    string `yaml:"kind,omitempty" json:"kind,omitempty" toml:"kind,omitempty"`
	Address string `yaml:"address,omitempty" json:"address,omitempty" toml:"address,omitempty"`
}

Config for time.

func (*Config) IsEnabled added in v2.115.0

func (c *Config) IsEnabled() bool

IsEnabled for time.

type Duration

type Duration = time.Duration

Duration is an alias of time.Duration.

func ParseDuration

func ParseDuration(s string) (Duration, error)

ParseDuration is just an alias to time.ParseDuration.

func Since

func Since(t Time) Duration

Since is just an alias to time.Since.

type NTPNetwork

type NTPNetwork struct {
	// contains filtered or unexported fields
}

NTPNetwork implements the Network interface for NTP.

func NewNTPNetwork

func NewNTPNetwork(address string) *NTPNetwork

NewNTPNetwork creates a new NTP network with an address. https://en.wikipedia.org/wiki/Network_Time_Protocol

func (*NTPNetwork) Now

func (n *NTPNetwork) Now() (Time, error)

Now returns the current time from the NTP server.

type NTSNetwork

type NTSNetwork struct {
	// contains filtered or unexported fields
}

NTSNetwork implements the Network interface for NTS.

func NewNTSNetwork

func NewNTSNetwork(address string) *NTSNetwork

NewNTSNetwork creates a new NTS network with an address. https://datatracker.ietf.org/doc/html/rfc8915

func (*NTSNetwork) Now

func (n *NTSNetwork) Now() (Time, error)

Now returns the current time from the NTS server.

type Network

type Network interface {
	// Now from the network.
	Now() (Time, error)
}

Network for time.

func NewNetwork

func NewNetwork(cfg *Config) (Network, error)

NewNetwork for time.

type Time

type Time = time.Time

Time is an alias of time.Time.

func Now

func Now() Time

Now is just an alias to time.Now.

Jump to

Keyboard shortcuts

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