clock

package
v0.0.0-...-11eb462 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

clock is a package for providing time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvenlySpaced

type EvenlySpaced struct {
	T     time.Time
	Delta time.Duration
}

EvenlySpaced is a clock providing evenly-spaced times with every call to Now: T, T+Delta, T + 2*Delta, ...

&EvenlySpaced{Delta: ...} is ready to use, although starts at 0001-01-01 0:00:00 (the ero value of time.Time).

func (*EvenlySpaced) Now

func (es *EvenlySpaced) Now() time.Time

type Interface

type Interface interface {
	Now() time.Time
}

Interface defines a clock, which can provide time.

var System Interface = systemClock{}

System is a clock which uses time.Now() to provide time.

type Specific

type Specific struct {
	// Times is the slice of times to generate.
	Times []time.Time

	// WrapAround controls the behavior once the Specific clock runs out of times.
	// If false (default), Now() panics. Otherwise, Now() wraps around and starts
	// back at the beginning of the provided slice.
	WrapAround bool
	// contains filtered or unexported fields
}

Specific is a clock providing specific times, in sequence.

&Specific{Time: ...} is ready to use.

func (*Specific) Now

func (s *Specific) Now() time.Time

Jump to

Keyboard shortcuts

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