clock

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package clock is the time source of components that show the time or arm countdowns: the wall clock in the shell, internal/fakeclock in 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
	// AfterFunc runs fn once d has passed; stop disarms it, reporting
	// whether it was still armed.
	AfterFunc(d time.Duration, fn func()) (stop func() bool)
}

Clock reads the time and arms one-shot timers.

type Wall

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

Wall is the machine's wall clock: Now reads it in the time zone set now, not the one the shell started in, and Changes ticks when the zone changes or the clock jumps.

func NewWall

func NewWall(zonePath string) (*Wall, error)

NewWall starts a wall clock that follows the zone set in zonePath.

func (*Wall) AfterFunc

func (w *Wall) AfterFunc(d time.Duration, fn func()) func() bool

AfterFunc runs fn on its own goroutine once d has passed.

func (*Wall) Changes

func (w *Wall) Changes() (<-chan struct{}, func())

Changes ticks after every change of the time zone and every jump of the clock; stop ends the feed.

func (*Wall) Close

func (w *Wall) Close() error

Close stops the clock and closes every feed of its changes.

func (*Wall) Now

func (w *Wall) Now() time.Time

Now is the current time in the current zone.

Directories

Path Synopsis
Package clocktest starts the shell's wall clock for a test, on a zone file of the test's own.
Package clocktest starts the shell's wall clock for a test, on a zone file of the test's own.

Jump to

Keyboard shortcuts

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