clocks – github.com/bep/clocks Index | Files

package clocks

import "github.com/bep/clocks"

Index

Variables

var TimeCupFinalNorway1976 = time.Date(1976, time.October, 24, 12, 15, 2, 127686412, time.UTC)

TimeCupFinalNorway1976 is the start time in UTC for the final match of the 1976 Norwegian Football Cup. This is typically used in tests where you need a historic time with a special meaning.

Types

type Clock

type Clock interface {
	Now() time.Time
	Since(t time.Time) time.Duration
	Until(t time.Time) time.Duration

	// Offset returns the offset of this clock relative to the system clock.
	Offset() time.Duration
}

Clock provides the sub set of methods in time.Time that this package provides.

func Fixed

func Fixed(t time.Time) Clock

Fixed returns a Clock that always returns the given time.

func Start

func Start(t time.Time) Clock

Start creates a new Clock starting at t.

func System

func System() Clock

System is a Clock that uses the system clock, meaning it just delegates to time.Now() etc.

Source Files

clock.go

Version
v0.5.0 (latest)
Published
Aug 8, 2022
Platform
linux/amd64
Imports
1 packages
Last checked
3 days ago

Tools for package owners.