time

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT Imports: 8 Imported by: 0

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

func IsEnabled(cfg *Config) bool

IsEnabled for time.

func MustParseDuration

func MustParseDuration(s string) time.Duration

MustParseDuration for time.

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

func (c *Config) IsNTP() bool

IsNTP for configuration.

func (*Config) IsNTS

func (c *Config) IsNTS() bool

IsNTS for configuration.

type Duration

type Duration = time.Duration

Duration is an alias of time.Duration.

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.

Jump to

Keyboard shortcuts

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