time

package
v1.618.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// 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 (
	// Now is just an alias to time.Now.
	Now = time.Now

	// ParseDuration is just an alias to time.ParseDuration.
	ParseDuration = time.ParseDuration

	// Since is just an alias to time.Since.
	Since = time.Since

	// Sleep is just an alias to time.Sleep.
	Sleep = time.Sleep
)
View Source
var ErrNotFound = errors.New("time: network not found")

ErrNotFound for metrics.

Module for fx.

Functions

func IsEnabled added in v1.176.0

func IsEnabled(cfg *Config) bool

IsEnabled for time.

func MustParseDuration added in v1.150.0

func MustParseDuration(s string) time.Duration

MustParseDuration for time.

Types

type Config added in v1.176.0

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) IsNTP added in v1.179.0

func (c *Config) IsNTP() bool

IsNTP for configuration.

func (*Config) IsNTS added in v1.179.0

func (c *Config) IsNTS() bool

IsNTS for configuration.

type Duration added in v1.426.0

type Duration = time.Duration

Duration is an alias of time.Duration.

type NTPNetwork added in v1.518.0

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

NTPNetwork implements the Network interface for NTP.

func NewNTPNetwork added in v1.518.0

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 added in v1.518.0

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

Now returns the current time from the NTP server.

type NTSNetwork added in v1.518.0

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

NTSNetwork implements the Network interface for NTS.

func NewNTSNetwork added in v1.518.0

func NewNTSNetwork(address string) *NTSNetwork

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

func (*NTSNetwork) Now added in v1.518.0

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

Now returns the current time from the NTS server.

type Network added in v1.179.0

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

Network for time.

func NewNetwork added in v1.179.0

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

NewNetwork for time.

type Time added in v1.426.0

type Time = time.Time

Time is an alias of time.Time.

Jump to

Keyboard shortcuts

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