clock

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package clock provides an injectable time source for paper-board services.

Real returns wall-clock time in UTC. Fake is settable for tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock returns the current time. All implementations MUST return UTC.

type Fake

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

Fake is a controllable clock for tests. Safe for concurrent use.

func NewFake

func NewFake(t time.Time) *Fake

NewFake returns a Fake initialised at t (normalised to UTC).

func (*Fake) Advance

func (f *Fake) Advance(d time.Duration)

Advance moves the fake clock forward (or back, if d is negative) by d.

func (*Fake) Now

func (f *Fake) Now() time.Time

Now returns the currently set fake time (UTC).

func (*Fake) Set

func (f *Fake) Set(t time.Time)

Set replaces the fake time (normalised to UTC).

type Real

type Real struct{}

Real is the production wall-clock implementation.

func (Real) Now

func (Real) Now() time.Time

Now returns time.Now() converted to UTC.

Jump to

Keyboard shortcuts

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